diff options
author | Jarno Rajahalme <jrajahalme@nicira.com> | 2014-08-05 13:51:19 -0700 |
---|---|---|
committer | Jarno Rajahalme <jrajahalme@nicira.com> | 2014-08-05 13:51:19 -0700 |
commit | 02334943a07e2e9a40e350397192d7793b9962f4 (patch) | |
tree | 38b4f00ded77466d6b88be2c80475ac7d7d51db8 /ofproto/connmgr.c | |
parent | 43d47da4adc16e2b17840247389c5637534cdf0c (diff) | |
download | openvswitch-02334943a07e2e9a40e350397192d7793b9962f4.tar.gz |
Fix strict aliasing violations with GCC 4.1 and 4.4.
The typical use of struct sockaddr_storage is flagged as a strict
aliasing violation by GCC 4.4.7. Using an explicit union lets the
compiler know that accessing the same location via different types is
not an error.
GCC 4.1.2 had a similar complaint about a cast of ukey's key_buf to
nlattr. After this patch there are no further warnings with the
XenServer build, so we could start treating warnings as errors in the
builds.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ofproto/connmgr.c')
-rw-r--r-- | ofproto/connmgr.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index 89af6b665..5e2c9c92e 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -734,12 +734,16 @@ update_in_band_remotes(struct connmgr *mgr) /* Add all the remotes. */ HMAP_FOR_EACH (ofconn, hmap_node, &mgr->controllers) { const char *target = rconn_get_target(ofconn->rconn); - struct sockaddr_storage ss; + union { + struct sockaddr_storage ss; + struct sockaddr_in in; + } sa; if (ofconn->band == OFPROTO_IN_BAND - && stream_parse_target_with_default_port(target, OFP_OLD_PORT, &ss) - && ss.ss_family == AF_INET) { - addrs[n_addrs++] = *(struct sockaddr_in *) &ss; + && stream_parse_target_with_default_port(target, OFP_OLD_PORT, + &sa.ss) + && sa.ss.ss_family == AF_INET) { + addrs[n_addrs++] = sa.in; } } for (i = 0; i < mgr->n_extra_remotes; i++) { |