From patchwork Mon Mar 20 18:24:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 741125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vn49p6QsDz9s2s for ; Tue, 21 Mar 2017 05:25:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R2HqoZH4"; dkim-atps=neutral Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 46DE8A67; Mon, 20 Mar 2017 18:25:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A926B982 for ; Mon, 20 Mar 2017 18:25:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3A321280 for ; Mon, 20 Mar 2017 18:25:00 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id g2so21357531pge.2 for ; Mon, 20 Mar 2017 11:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6tsz7xbpjcOoov5V32vcH9IdPQdyUvPvLheiS7PtQm4=; b=R2HqoZH4oTpckqzB0ak3jrQIEOIeS175ThFA0gM3iwam+/LRpnb+gYYXyqSLwv0p9V 5ylN3YicIWF3oWIac/vfxWYSnPtgNOt4tqOGAorhSAMblUh4OpsKh0QBCBvt5W8V07t/ TF5WAgRsVLXI5fSH3P1YxMdQTSkwg/NVPI+qpNO761152C8qGg012wM7Zl7k3EZrvdnK V1BezqVYuJrw2dGTPUFhn4b7SV3TrVjAf4GcwhmbvNlfawB1O9D0H+DJZObbeOb2FUf0 vrVfYJT/f6LKKNXS0mzWgleO8BcKI7ln/XaXUKGNWed8Ej9WNiifezyxwQbTruwG6R1k UzSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6tsz7xbpjcOoov5V32vcH9IdPQdyUvPvLheiS7PtQm4=; b=r2MJ6p7ZMrF4NmyUdIEPYedUn9CHrKbrAyhnznaIDW6aY+Ec+IjZd+mc/dzGtlWlLU hEh7MnNdJB/c4575N8Ac0UV2jJ2ykaSiMZjrZuKdcjTyyMCLpJKUAPgeXIbRoyef/1Zz hnhbKS/53yzNKsedw1Tmg0XPvaDqKbim7YHrahE/XitKJYkTUKBgQQYTswvJz8akR6yK YOjIz6Gz917koAPTLJh4JHOPIMhJBzzJJ3OM0ZYnmPxZpJA37wzW/J0FUnTLncgymoPO 5skKhtRlsvjA2706QXZdrCsEepMh50Se56zF415W9bOu2sbTp/S9KXLrM8OwPflpQYgP YdaQ== X-Gm-Message-State: AFeK/H3455LctKIC342x4RgLQVwJhGJ64i/d96A0h+5SJnHJ+hfPGyqzsCv4ut4lR3HAgg== X-Received: by 10.98.26.199 with SMTP id a190mr35272048pfa.63.1490034299765; Mon, 20 Mar 2017 11:24:59 -0700 (PDT) Received: from localhost.localdomain (96-82-111-186-static.hfc.comcastbusiness.net. [96.82.111.186]) by smtp.gmail.com with ESMTPSA id x10sm34621082pff.72.2017.03.20.11.24.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 11:24:59 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Mon, 20 Mar 2017 11:24:49 -0700 Message-Id: <1490034289-77787-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Eric Garver Subject: [ovs-dev] [patch_v2] build: Fix memset with zero size warning. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 Fixes: f0fb825a3785 ("Add support for 802.1ad (QinQ tunneling)") CC: Eric Garver Acked-by: Eric Garver --- 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));