ofp-util: Avoid gcc warning on NetBSD
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>
Thu, 20 Feb 2014 02:11:00 +0000 (11:11 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 20 Feb 2014 16:29:50 +0000 (08:29 -0800)
Avoid the following warning caused by the combination
of NetBSD's htons implementation and gcc bug.
Now --enable-Werror build succeeds on NetBSD-6.

    lib/ofp-util.c: In function 'ofputil_match_from_ofp10_match':
    lib/ofp-util.c:174:15: error: integer overflow in expression

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-util.c

index aa25e67..fca18de 100644 (file)
@@ -169,9 +169,11 @@ ofputil_match_from_ofp10_match(const struct ofp10_match *ofmatch,
         match->wc.masks.vlan_tci = htons(0xffff);
     } else {
         ovs_be16 vid, pcp, tci;
+        uint16_t hpcp;
 
         vid = ofmatch->dl_vlan & htons(VLAN_VID_MASK);
-        pcp = htons((ofmatch->dl_vlan_pcp << VLAN_PCP_SHIFT) & VLAN_PCP_MASK);
+        hpcp = (ofmatch->dl_vlan_pcp << VLAN_PCP_SHIFT) & VLAN_PCP_MASK;
+        pcp = htons(hpcp);
         tci = vid | pcp | htons(VLAN_CFI);
         match->flow.vlan_tci = tci & match->wc.masks.vlan_tci;
     }