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
changes/88/3188/1
Holger Hans Peter Freyther 12 years ago
parent 5652cfc0e8
commit 0b369c582b
  1. 10
      openbsc/src/e1_input.c

@ -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;

Loading…
Cancel
Save