From 48cdf650d9d3b7a92f216f999c24307c6d103528 Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Fri, 9 Oct 2015 11:20:36 +0200 Subject: [PATCH] improve container_of macro --- src/main/common/utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/common/utils.h b/src/main/common/utils.h index 87467f465..ca1ec1042 100644 --- a/src/main/common/utils.h +++ b/src/main/common/utils.h @@ -42,9 +42,9 @@ http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html #else // non ISO variant from linux kernel; checks ptr type, but triggers 'ISO C forbids braced-groups within expressions [-Wpedantic]' // __extension__ is here to disable this warning -#define container_of(ptr, type, member) __extension__ ({ \ +#define container_of(ptr, type, member) ( __extension__ ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) + (type *)( (char *)__mptr - offsetof(type,member) );})) static inline int16_t cmp16(uint16_t a, uint16_t b) { return a-b; } static inline int32_t cmp32(uint32_t a, uint32_t b) { return a-b; } -- 2.11.4.GIT