>From aff038e2b57b672a05833cf1af19a4b2e5c88c25 Mon Sep 17 00:00:00 2001 From: Peter Volkov Date: Thu, 14 Jul 2011 13:30:17 +0400 Subject: [PATCH 1/3] Fix warning for strict-aliasing rules gcc-4.5 produces following warnings when -O2 optimisation are enabled: extensions/ebt_among.c: In function 'create_wormhash': extensions/ebt_among.c:250:4: warning: dereferencing type-punned pointer will break strict-aliasing rules extensions/ebt_among.c:261:3: warning: dereferencing type-punned pointer will break strict-aliasing rules --- extensions/ebt_among.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ebt_among.c b/extensions/ebt_among.c index b98f65b..2759b06 100644 --- a/extensions/ebt_among.c +++ b/extensions/ebt_among.c @@ -247,7 +247,7 @@ static struct ebt_mac_wormhash *create_wormhash(const char *arg) ebt_print_error("IP parse error: %.20s", anchor); return NULL; } - if (*(uint32_t*)ip == 0) { + if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) { ebt_print_error("Illegal IP 0.0.0.0"); return NULL; } @@ -258,7 +258,7 @@ static struct ebt_mac_wormhash *create_wormhash(const char *arg) /* we have collected MAC and IP, so we add an entry */ memcpy(((char *) workcopy->pool[nmacs].cmp) + 2, mac, 6); - workcopy->pool[nmacs].ip = *(const uint32_t *) ip; + memcpy(&(workcopy->pool[nmacs].ip), ip, 4); nmacs++; /* re-allocate memory if needed */ -- 1.7.3.4