From 07c01c732f00148389ff01254b5ee652f7f2ee38 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 4 Feb 2025 10:41:05 +0100 Subject: [PATCH] Fixed SAME_TYPE to work with obviously nonzero pointers without warnings --- lib/birdlib.h | 3 ++- lib/resource.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/birdlib.h b/lib/birdlib.h index d7c8f5922..5a004d9a2 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); -- 2.47.2