From: Maria Matejka Date: Tue, 4 Feb 2025 09:41:05 +0000 (+0100) Subject: Fixed SAME_TYPE to work with obviously nonzero pointers without warnings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87236d8cb6feb145fe59baee1321b36a3da89b4f;p=thirdparty%2Fbird.git Fixed SAME_TYPE to work with obviously nonzero pointers without warnings --- diff --git a/lib/birdlib.h b/lib/birdlib.h index bc7c334cb..ab96f99b7 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -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 diff --git a/lib/resource.c b/lib/resource.c index 8a923792f..a389403b0 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -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);