From 4dd1e3cabbd109e322553a7b3d4c875e697d2069 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 2 Jan 2012 12:46:17 -0800 Subject: [PATCH] ofproto-dpif: Fix GCC warning. gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48) warned: ofproto/ofproto-dpif.c: In function 'bundle_send_learning_packets': ofproto/ofproto-dpif.c:1835: warning: dereferencing type-punned pointer will break strict-aliasing rules I agree that its analysis matches what the C standard says. This commit fixes the problem and avoids the warning. The assignment to 'port' isn't actually necessary. I included it because I like to have a variable with the correct type near the use of that type through a "void *". Then "grep" for that type is more effective, and the compiler will be able to diagnose any later change to (in this case) the type of the first parameter to send_packet(). Signed-off-by: Ben Pfaff --- ofproto/ofproto-dpif.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 031aa71e..df7a56a6 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1816,11 +1816,15 @@ bundle_send_learning_packets(struct ofbundle *bundle) if (e->port.p != bundle) { struct ofpbuf *learning_packet; struct ofport_dpif *port; + void *port_void; int ret; - learning_packet = bond_compose_learning_packet(bundle->bond, e->mac, - e->vlan, - (void **)&port); + /* The assignment to "port" is unnecessary but makes "grep"ing for + * struct ofport_dpif more effective. */ + learning_packet = bond_compose_learning_packet(bundle->bond, + e->mac, e->vlan, + &port_void); + port = port_void; ret = send_packet(port, learning_packet); ofpbuf_delete(learning_packet); if (ret) { -- 2.30.2