Skip to content

Commit 4dd1e3c

Browse files
committed
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 <blp@nicira.com>
1 parent 968131c commit 4dd1e3c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

ofproto/ofproto-dpif.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2010, 2011 Nicira Networks.
2+
* Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1816,11 +1816,15 @@ bundle_send_learning_packets(struct ofbundle *bundle)
18161816
if (e->port.p != bundle) {
18171817
struct ofpbuf *learning_packet;
18181818
struct ofport_dpif *port;
1819+
void *port_void;
18191820
int ret;
18201821

1821-
learning_packet = bond_compose_learning_packet(bundle->bond, e->mac,
1822-
e->vlan,
1823-
(void **)&port);
1822+
/* The assignment to "port" is unnecessary but makes "grep"ing for
1823+
* struct ofport_dpif more effective. */
1824+
learning_packet = bond_compose_learning_packet(bundle->bond,
1825+
e->mac, e->vlan,
1826+
&port_void);
1827+
port = port_void;
18241828
ret = send_packet(port, learning_packet);
18251829
ofpbuf_delete(learning_packet);
18261830
if (ret) {

0 commit comments

Comments
 (0)