Hi Eric,
On 08/12/2017 08:41 AM, Eric Blake wrote:
Here's an idea: Instead of using struct ip6 { ... } QEMU_PACKED, use
struct ip6 {
...
};
QEMU_BUG_ON(sizeof(struct ip6) != 32);
so that the compiler explicitly chokes if it introduced any padding, and
then we know all our accesses are naturally aligned which shuts up the
warning.
Following your suggestion I tried:
#define QEMU_BUG_STRUCT_UNALIGNED(s) \
QEMU_BUILD_BUG_ON(sizeof(s) != sizeof(s QEMU_PACKED))
QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
but this gives:
qemu/slirp/ip6.h:157:1: warning: 'packed' attribute ignored when parsing
type [-Wignored-attributes]
QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qemu/slirp/ip6.h:155:49: note: expanded from macro
'QEMU_BUG_STRUCT_UNALIGNED'
QEMU_BUILD_BUG_ON(sizeof(s) != sizeof(s QEMU_PACKED))
^~~~~~~~~~~
qemu/include/qemu/compiler.h:40:37: note: expanded from macro 'QEMU_PACKED'
# define QEMU_PACKED __attribute__((packed))
^~~~~~
1 warning generated.