e1_input: Fix compiler warning by using offsetof

Use the offsetof/__builtin_offsetof to determine the
offset of a variable inside a structure instead of going
via a NULL pointer and taking the address.

This fixes:
warning: variably modified ‘dummyhalen_offset’ at file scope
This commit is contained in:
Holger Hans Peter Freyther 2010-11-09 23:10:16 +01:00
parent 5652cfc0e8
commit 0b369c582b
1 changed files with 5 additions and 5 deletions

View File

@ -110,11 +110,11 @@ struct lapd_header {
u_int8_t control_foo; /* fake UM's ... */
} __attribute__((packed));
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->hatype == 2, hatype_offset);
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->halen == 4, halen_offset);
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->addr == 6, addr_offset);
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->protocol == 14, proto_offset);
static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size);
static_assert(offsetof(struct fake_linux_lapd_header, hatype) == 2, hatype_offset);
static_assert(offsetof(struct fake_linux_lapd_header, halen) == 4, halen_offset);
static_assert(offsetof(struct fake_linux_lapd_header, addr) == 6, addr_offset);
static_assert(offsetof(struct fake_linux_lapd_header, protocol) == 14, proto_offset);
static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size);
static int pcap_fd = -1;