From patchwork Mon Feb 13 23:02:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Alemayhu X-Patchwork-Id: 727617 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vMh0Z2SD3z9s06 for ; Tue, 14 Feb 2017 10:02:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=alemayhu-com.20150623.gappssmtp.com header.i=@alemayhu-com.20150623.gappssmtp.com header.b="0z8I9qLz"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbdBMXCw (ORCPT ); Mon, 13 Feb 2017 18:02:52 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:36435 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbdBMXCu (ORCPT ); Mon, 13 Feb 2017 18:02:50 -0500 Received: by mail-lf0-f48.google.com with SMTP id z134so58153246lff.3 for ; Mon, 13 Feb 2017 15:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alemayhu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hdezsVttQmSl+7PmmGIJqsW7lVse+xpcGMhmpRnHRlY=; b=0z8I9qLzu9t0M8fiKba5/PkzemwMC/xRXsLaqL6v3BiSUc6vJAKxp5Hh4/QAn21J4k FcL++Q0VD3oOW+WRaw3FR5NktaVqIE4ozEvQaNxdzJRCgifazcGINLYUSxz2HYT2kMgn MpIgnwbgMU1mAIlfLBALdeYBF0DD+A4PPYT0SvnVlJJLMT4b/boDwqh3O0cmpQYTd6NM L1c/0ZLsAcNBvBGBU4tu4lWsBkM5CrRfhslwq5iwB5yJOFdtJBfKs+tSi0rjiXORZ0Z5 6VCp/V6HQzVI9CmBtSBSj2S32sZfvK8ntyjqQkhG8G1NWa6YPPAatvOX772AB6P6BFzq SHRA== 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:mime-version :content-transfer-encoding; bh=hdezsVttQmSl+7PmmGIJqsW7lVse+xpcGMhmpRnHRlY=; b=ckNP+7JsfcWlwF943gaSyf+AUH+pFoS7cL+ZfspKlNOuJkdXxsa/RtqFhsrmPAmyWl 9MFz1Bx+nxhXU+9CbWQnbgOMPnQSwQ0DkVPouuyP2gPwCeQc1sfsMeqbXm3xYwc0gEhT u9pBAgRfBahDs2Un2wEP5kz/ZV5hcnuRA6B2d8RW1v7SdemD/ni5gpYuhyI+gUbaooxy BbSJF4LcL9XLBAC9sYFKtUWok32PCGhluV09g4Mq+EYIPNkrnxy81xUDrMoKTjO+fB9n aVpAqqgHlD8wL8rfXSHWwwZ6JQA6sjcgQPE+EOrH36WTX+dvU3sP4jOLIsBOKOUyrpZI Ygfg== X-Gm-Message-State: AMke39l6Gb0kNstxAys+zALxrv0iXwWRwo6DNqkgPCT2UWHLyrTdutt1iu4BOkgPJ1MiTw== X-Received: by 10.25.20.84 with SMTP id k81mr7371421lfi.172.1487026968710; Mon, 13 Feb 2017 15:02:48 -0800 (PST) Received: from localhost ([2a02:fe0:c020:30f0::5]) by smtp.gmail.com with ESMTPSA id w4sm3009030ljd.23.2017.02.13.15.02.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2017 15:02:48 -0800 (PST) From: Alexander Alemayhu To: netdev@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, brouer@redhat.com, dcb314@hotmail.com, jbacik@fb.com, Alexander Alemayhu Subject: [PATCH] bpf: reduce compiler warnings by adding fallthrough comments Date: Tue, 14 Feb 2017 00:02:35 +0100 Message-Id: <20170213230235.12677-1-alexander@alemayhu.com> X-Mailer: git-send-email 2.11.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fixes the following warnings: kernel/bpf/verifier.c: In function ‘may_access_direct_pkt_data’: kernel/bpf/verifier.c:702:6: warning: this statement may fall through [-Wimplicit-fallthrough=] if (t == BPF_WRITE) ^ kernel/bpf/verifier.c:704:2: note: here case BPF_PROG_TYPE_SCHED_CLS: ^~~~ kernel/bpf/verifier.c: In function ‘reg_set_min_max_inv’: kernel/bpf/verifier.c:2057:23: warning: this statement may fall through [-Wimplicit-fallthrough=] true_reg->min_value = 0; ~~~~~~~~~~~~~~~~~~~~^~~ kernel/bpf/verifier.c:2058:2: note: here case BPF_JSGT: ^~~~ kernel/bpf/verifier.c:2068:23: warning: this statement may fall through [-Wimplicit-fallthrough=] true_reg->min_value = 0; ~~~~~~~~~~~~~~~~~~~~^~~ kernel/bpf/verifier.c:2069:2: note: here case BPF_JSGE: ^~~~ kernel/bpf/verifier.c: In function ‘reg_set_min_max’: kernel/bpf/verifier.c:2009:24: warning: this statement may fall through [-Wimplicit-fallthrough=] false_reg->min_value = 0; ~~~~~~~~~~~~~~~~~~~~~^~~ kernel/bpf/verifier.c:2010:2: note: here case BPF_JSGT: ^~~~ kernel/bpf/verifier.c:2019:24: warning: this statement may fall through [-Wimplicit-fallthrough=] false_reg->min_value = 0; ~~~~~~~~~~~~~~~~~~~~~^~~ kernel/bpf/verifier.c:2020:2: note: here case BPF_JSGE: ^~~~ Reported-by: David Binderman Signed-off-by: Alexander Alemayhu Acked-by: Daniel Borkmann Acked-by: Alexei Starovoitov --- Using gcc (GCC) 7.0.1 20170204 (Red Hat 7.0.1-0.6) kernel/bpf/verifier.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 1a754e5d2695..d2bded2b250c 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -701,6 +701,7 @@ static bool may_access_direct_pkt_data(struct bpf_verifier_env *env, /* dst_input() and dst_output() can't write for now */ if (t == BPF_WRITE) return false; + /* fallthrough */ case BPF_PROG_TYPE_SCHED_CLS: case BPF_PROG_TYPE_SCHED_ACT: case BPF_PROG_TYPE_XDP: @@ -2007,6 +2008,7 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg, case BPF_JGT: /* Unsigned comparison, the minimum value is 0. */ false_reg->min_value = 0; + /* fallthrough */ case BPF_JSGT: /* If this is false then we know the maximum val is val, * otherwise we know the min val is val+1. @@ -2017,6 +2019,7 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg, case BPF_JGE: /* Unsigned comparison, the minimum value is 0. */ false_reg->min_value = 0; + /* fallthrough */ case BPF_JSGE: /* If this is false then we know the maximum value is val - 1, * otherwise we know the mimimum value is val. @@ -2055,6 +2058,7 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg, case BPF_JGT: /* Unsigned comparison, the minimum value is 0. */ true_reg->min_value = 0; + /* fallthrough */ case BPF_JSGT: /* * If this is false, then the val is <= the register, if it is @@ -2066,6 +2070,7 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg, case BPF_JGE: /* Unsigned comparison, the minimum value is 0. */ true_reg->min_value = 0; + /* fallthrough */ case BPF_JSGE: /* If this is false then constant < register, if it is true then * the register < constant.