From: Maria Matejka Date: Wed, 13 Oct 2021 09:33:48 +0000 (+0200) Subject: Type checking in SKIP_BACK macro X-Git-Tag: 3.0-alpha0~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d7e42cc593b3c99f8eacaaa506194aeb3a5cf85;p=thirdparty%2Fbird.git Type checking in SKIP_BACK macro --- diff --git a/lib/birdlib.h b/lib/birdlib.h index 431b7c0d8..2e642d384 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -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))