]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Type checking in SKIP_BACK macro
authorMaria Matejka <mq@ucw.cz>
Wed, 13 Oct 2021 09:33:48 +0000 (11:33 +0200)
committerMaria Matejka <mq@ucw.cz>
Mon, 22 Nov 2021 18:05:43 +0000 (19:05 +0100)
lib/birdlib.h

index 431b7c0d856acabc7c060d7739d5cd7a63b46837..2e642d384d72f075f309aa34f46f3552b17cd508 100644 (file)
@@ -16,7 +16,7 @@
 struct align_probe { char x; long int y; };
 
 #define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
-#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
+#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); ASSERT_DIE(&_ptr->i == p); _ptr; })
 #define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
 #define CPU_STRUCT_ALIGN (sizeof(struct align_probe))