diff options
author | Rob Clark | 2016-08-02 15:16:02 -0500 |
---|---|---|
committer | Rob Clark | 2016-08-02 15:22:45 -0500 |
commit | b214b05ccd433c484a6a65e491a1a51b19e4811d (patch) | |
tree | f0704c06633f10660ad16efe70bde0b9b59d8cfb | |
parent | f19cd3a52827a2368040649c2fc5e7e75db10d08 (diff) | |
download | external-libdrm-b214b05ccd433c484a6a65e491a1a51b19e4811d.tar.gz external-libdrm-b214b05ccd433c484a6a65e491a1a51b19e4811d.tar.xz external-libdrm-b214b05ccd433c484a6a65e491a1a51b19e4811d.zip |
list: fix an issue with android build using clang
Sorry, I don't understand the android build system enough to say *which*
version of clang this effects, but either "clang-2812033" or
"clang-3016494" (probably the later).
But when 'sample' is undefined (ie. unitialized variable), the result is
not as well defined as it is with gcc. Instead use a typeof() cast with
a defined value (ie. zero).
This fixes a crash that was reported on android.
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
-rw-r--r-- | util_double_list.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util_double_list.h b/util_double_list.h index 5d01f52d..7e48b26c 100644 --- a/util_double_list.h +++ b/util_double_list.h | |||
@@ -110,7 +110,7 @@ static inline void list_delinit(struct list_head *item) | |||
110 | #ifndef container_of | 110 | #ifndef container_of |
111 | #define container_of(ptr, sample, member) \ | 111 | #define container_of(ptr, sample, member) \ |
112 | (void *)((char *)(ptr) \ | 112 | (void *)((char *)(ptr) \ |
113 | - ((char *)&(sample)->member - (char *)(sample))) | 113 | - ((char *)&((typeof(sample))0)->member)) |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | #define LIST_FOR_EACH_ENTRY(pos, head, member) \ | 116 | #define LIST_FOR_EACH_ENTRY(pos, head, member) \ |