In file included from /usr/include/string.h:640:0,
                  from ./lib/string.h:20,
                  from /usr/include/netinet/icmp6.h:22,
                  from ../lib/flow.h:21,
                  from ../lib/flow.c:18:
In function 'memset',
     inlined from 'flow_push_vlan_uninit' at ../lib/flow.c:2188:19:
/usr/include/x86_64-linux-gnu/bits/string3.h:81:30: error:
call to '__warn_memset_zero_len' declared with attribute warning:
memset used with constant zero length parameter; this could be
due to transposed parameters [-Werror]
        __warn_memset_zero_len ();
                               ^
cc1: all warnings being treated as errors
make[2]: *** [lib/flow.lo] Error 1

At the same time, fix some similar bounds checks related to
the same commit.

Signed-off-by: Darrell Ball <[email protected]>
Fixes: f0fb825a3785 ("Add support for 802.1ad (QinQ tunneling)")
CC: Eric Garver <[email protected]>
---

v1->v2: Change some cosmetic bounds checks.

 lib/flow.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index f628526..8e7d3ee 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -2167,10 +2167,10 @@ void
 flow_pop_vlan(struct flow *flow, struct flow_wildcards *wc)
 {
     int n = flow_count_vlan_headers(flow);
-    if (n == 0) {
+    if (n <= 0) {
         return;
     }
-    if (wc) {
+    if ((wc) && (n > 1)) {
         memset(&wc->masks.vlans[1], 0xff,
                sizeof(union flow_vlan_hdr) * (n - 1));
     }
@@ -2184,7 +2184,9 @@ flow_push_vlan_uninit(struct flow *flow, struct 
flow_wildcards *wc)
 {
     if (wc) {
         int n = flow_count_vlan_headers(flow);
-        memset(wc->masks.vlans, 0xff, sizeof(union flow_vlan_hdr) * n);
+        if (n > 0) {
+            memset(wc->masks.vlans, 0xff, sizeof(union flow_vlan_hdr) * n);
+        }
     }
     memmove(&flow->vlans[1], &flow->vlans[0],
             sizeof(union flow_vlan_hdr) * (FLOW_MAX_VLAN_HEADERS - 1));
-- 
1.9.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to