]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed SAME_TYPE to work with obviously nonzero pointers without warnings
authorMaria Matejka <mq@ucw.cz>
Tue, 4 Feb 2025 09:41:05 +0000 (10:41 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 12 Feb 2025 11:40:04 +0000 (12:40 +0100)
lib/birdlib.h
lib/resource.c

index bc7c334cb36bfc68c8ff5f433fa0a934dd625cb1..ab96f99b726a187b96c1ad70786cfece5ea1b5f6 100644 (file)
@@ -21,8 +21,9 @@
 
 /* Ugly structure offset handling macros */
 
+extern char invalid_nonzero_pointer[0];
 #define SAME_TYPE(a, b)        ({ int _ = ((a) != (b)); !_; })
-#define TYPE_CAST(from, to, what) ( SAME_TYPE(((from) NULL), (what)), ((to) (what)))
+#define TYPE_CAST(from, to, what) ( SAME_TYPE(((from) invalid_nonzero_pointer), (what)), ((to) (what)))
 
 #ifdef offsetof
 #define OFFSETOF offsetof
index 8a923792fc04854e0865b7115c5abcb60982ca62..a389403b026edc455ac8d7738fda21171e4efc0f 100644 (file)
@@ -30,6 +30,8 @@
  * is freed upon shutdown of the module.
  */
 
+char invalid_nonzero_pointer[0];
+
 static void pool_dump(struct dump_request *, resource *);
 static void pool_free(resource *);
 static resource *pool_lookup(resource *, unsigned long);