On 08/12/2017 06:47 AM, Samuel Thibault wrote:
> Eric Blake, on sam. 12 août 2017 06:41:30 -0500, wrote:
>> Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use
>>
>> struct ip6 {
>> ...
>> };
>> QEMU_BUG_ON(sizeof(struct ip6) != 32);
> 
> That's an interesting way indeed.  I however wonder whether there may be
> not-so-uncommon systems where the compiler aligns some fields just for
> performance or such.

If it does, the BUG_ON will flag it, and we'll deal with it as needed
for that platform, perhaps by adding:

...
}
#ifdef WEIRD_PLATFORM
  QEMU_PACKED
#endif
 ;
QEMU_BUG_ON(...);

But as long as the BUG_ON doesn't flag anything, we can use the struct
as-is.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to