[Mesa-dev] [PATCH 2/5] util/list: fix member access within null pointer
Emil Velikov
emil.l.velikov at gmail.com
Fri Feb 10 10:46:25 UTC 2017
On 10 February 2017 at 09:26, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> On 07.02.2017 19:34, Bartosz Tomczyk wrote:
>>
>> ---
>> configure.ac | 3 +++
>> src/util/list.h | 9 +++++++++
>> 2 files changed, 12 insertions(+)
>>
>> diff --git a/configure.ac b/configure.ac
>> index a6ceee95a3..87f635c1a3 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -415,6 +415,9 @@ AC_C_BIGENDIAN(
>> little_endian=no
>> )
>>
>> +dnl Chek for typeof support
>> +AC_C_TYPEOF()
>> +
>> dnl Check for POWER8 Architecture
>> PWR8_CFLAGS="-mpower8-vector"
>> have_pwr8_intrinsics=no
>> diff --git a/src/util/list.h b/src/util/list.h
>> index 07eb9f3e6a..eaaac43fec 100644
>> --- a/src/util/list.h
>> +++ b/src/util/list.h
>> @@ -171,10 +171,19 @@ static inline void list_validate(struct list_head
>> *list)
>> * 'sample' MUST be initialized, or else the result is undefined!
>> */
>> #ifndef container_of
>> +#if HAVE_TYPEOF
>> +#define container_of_typed(ptr, type, member) ({ \
>> + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
>> + (type *)( (char *)__mptr - offsetof(type,member) );})
>
>
> I believe this syntax is a GCC extension. Do all compilers with typeof also
> support that extension? This is something to be checked especially on
> Windows. Apart from that, the change looks good to me.
>
HAVE_TYPEOF will only be set if the compiler supports the typeof
extension, so we should be safe ;-)
For the patch
Acked-by: Emil Velikov <emil.velikov at collabora.com>
-Emil
More information about the mesa-dev
mailing list