ip(6)_tables.h: return type difference in ip(6)t_get_target
Patrick Schaaf
bof at bof.de
Fri Sep 9 11:03:59 CEST 2005
>> Back to my original post: Is there a reason not to change the code as I
>> proposed?
>
> Your code change is wrong. See below for proof code. Remember that
> a "pointer + integer" always advances the pointer according to the
> type of the thing pointed to, i.e. by "integer*sizeof(*pointer)".
> And casting seems to have precedence over "+"...
Damn, my proof code was nonsensical in that it not tested for the
"casting seems to" property. Corrected code below. So, casting
has higher precedence than "+". Which does not make your proposed
change more correct, it's just wrong in a different way :)
best regards
Patrick
$ cat foo.c
struct foo { int a; };
struct bar { int a; int b; };
int main(int argc, char **argv)
{
struct foo fooarray[10];
struct foo *bar = fooarray;
printf("struct foo *: %p %p\n", bar, bar + 1);
printf("struct bar *: %p %p\n", bar, (struct bar *) bar + 1);
printf("void *: %p %p\n", bar, (void *) bar + 1);
return 0;
}
$ gcc -o foo foo.c
$ ./foo
struct foo *: 0xbffff878 0xbffff87c
struct bar *: 0xbffff878 0xbffff880
void *: 0xbffff878 0xbffff879
More information about the netfilter-devel
mailing list