aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-09 23:10:16 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-09 23:11:29 +0100
commit0b369c582b94c2b409417bcaed0fcdd90d925d9e (patch)
tree9cd304e5a70e101136c314f3c69ab2bfe1ad3c18
parent5652cfc0e82ef1cc42ae2e61b68409ec933ce39c (diff)
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
-rw-r--r--openbsc/src/e1_input.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index b1dfe9b1d..9b205b7d0 100644
--- a/openbsc/src/e1_input.c
+++ b/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;