Ben, do you think it's worth putting a small comment above the assignment? Otherwise, it looks kind of odd.
--Justin On Dec 28, 2011, at 10:50 PM, Ethan Jackson wrote: > Looks good. > > Ethan > > On Tue, Dec 27, 2011 at 14:32, Ben Pfaff <b...@nicira.com> wrote: >> 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 <b...@nicira.com> >> --- >> ofproto/ofproto-dpif.c | 8 +++++--- >> 1 files changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c >> index 1eb0b82..004991b 100644 >> --- a/ofproto/ofproto-dpif.c >> +++ b/ofproto/ofproto-dpif.c >> @@ -1828,11 +1828,13 @@ 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); >> + 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) { >> -- >> 1.7.2.5 >> >> _______________________________________________ >> dev mailing list >> dev@openvswitch.org >> http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev