Luigi Rizzo wrote: > sorry but all this just does not make sense to me. > > sizeof(foo) should give the same result irrespective of > where you use it. > > Perhaps the best thing would be to put a > > printf("struct ip_fw has size %d\n", sizeof(struct ip_fw)); > > both in ipfw2.c and somewhere in ip_fw2.c and see if there is > a mismatch between the two numbers.
I have to assume that what didn't make sense was that his patch worked? 8-). He's making the valid point that for: struct foo *fee; It's possible that: sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) because of end-padding, which is not accounted for in arrays, and that inter-structure padding depends on ordering of elements (for a good example of this, see the struct direct name element reference macro, which is also padding independent). Basically, end-padding happens because arrays of structures need to have their first element properly aligned, so there is a pad added after each element to ensure that the following element starts on an alignment boundary. I still say that on 486 and higher, the "disallow unaligned access" bit in the processor control register should be enabled, so your kernel will panic if you try this. 8-). -- Terry To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message