cppcheck sept 18 redux
Vitaliy Margolen
wine-devel at kievinfo.com
Tue Sep 22 20:30:45 CDT 2009
Henri Verbeet wrote:
> 2009/9/22 Vitaliy Margolen <wine-devel at kievinfo.com>:
>> It does dereference the pointer. Here is your simple test. Compile it and
>> run it. See what happens.
>>
>> #include <stdio.h>
>>
>> typedef struct _s_test
>> {
>> void *pointer;
>> } s_test;
>>
>> int main()
>> {
>> s_test *s = NULL;
>> long diff = (const char*)s->pointer - (const char*)s;
>> printf("diff=%ld\n", diff);
>>
>> return 0;
>> }
>>
>> Vitaliy.
>>
>
> That's not really what the code does. Try changing "void *pointer" to
> "char pointer[32]".
Right, haven't checked the definition of the DEVMODEW. Indeed it does work
for an array, since it is part of the structure. So "s->pointer" will be
(char *)s + FIELD_OFFSET(s,pointer).
Still it's a bad construct to use, for exactly the reason we are having this
discussion.
Vitaliy.
More information about the wine-devel
mailing list