util: fix container_of() macro

Fixes a bunch of warnings of the kind
../src/evdev.h:378:32: warning: variable 'f' is uninitialized when used here [-Wuninitialized]
        return container_of(dispatch, f, base);

Just typecasting NULL means we can ignore sample but for the type.

https://bugs.freedesktop.org/show_bug.cgi?id=100976

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Tested-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
This commit is contained in:
Peter Hutterer 2017-05-10 12:33:10 +10:00
parent 89490d2b34
commit 3925936969

View file

@ -87,7 +87,7 @@ bool list_empty(const struct list *list);
#define container_of(ptr, sample, member) \
(__typeof__(sample))((char *)(ptr) - \
((char *)&(sample)->member - (char *)(sample)))
((char *)&((typeof(sample))0)->member))
#define list_for_each(pos, head, member) \
for (pos = 0, pos = container_of((head)->next, pos, member); \