* [PATCH] bpf: reduce compiler warnings by adding fallthrough comments
@ 2017-02-13 23:02 Alexander Alemayhu
2017-02-13 23:18 ` Daniel Borkmann
2017-02-14 19:32 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Alemayhu @ 2017-02-13 23:02 UTC (permalink / raw)
To: netdev; +Cc: ast, daniel, brouer, dcb314, jbacik, Alexander Alemayhu
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 <dcb314@hotmail.com>
Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
---
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.
--
2.11.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: reduce compiler warnings by adding fallthrough comments
2017-02-13 23:02 [PATCH] bpf: reduce compiler warnings by adding fallthrough comments Alexander Alemayhu
@ 2017-02-13 23:18 ` Daniel Borkmann
2017-02-14 0:00 ` Alexei Starovoitov
2017-02-14 19:32 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2017-02-13 23:18 UTC (permalink / raw)
To: Alexander Alemayhu, netdev; +Cc: ast, brouer, dcb314, jbacik
On 02/14/2017 12:02 AM, Alexander Alemayhu wrote:
> 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 <dcb314@hotmail.com>
> Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
These fall-through comments are fine for net-next tree.
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: reduce compiler warnings by adding fallthrough comments
2017-02-13 23:18 ` Daniel Borkmann
@ 2017-02-14 0:00 ` Alexei Starovoitov
0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2017-02-14 0:00 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: Alexander Alemayhu, netdev, ast, brouer, dcb314, jbacik
On Tue, Feb 14, 2017 at 12:18:05AM +0100, Daniel Borkmann wrote:
> >kernel/bpf/verifier.c:2019:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
> > false_reg->min_value = 0;
> > ~~~~~~~~~~~~~~~~~~~~~^~~
> >
> >Reported-by: David Binderman <dcb314@hotmail.com>
> >Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
>
> These fall-through comments are fine for net-next tree.
>
> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
lgtm as well
Acked-by: Alexei Starovoitov <ast@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: reduce compiler warnings by adding fallthrough comments
2017-02-13 23:02 [PATCH] bpf: reduce compiler warnings by adding fallthrough comments Alexander Alemayhu
2017-02-13 23:18 ` Daniel Borkmann
@ 2017-02-14 19:32 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-02-14 19:32 UTC (permalink / raw)
To: alexander; +Cc: netdev, ast, daniel, brouer, dcb314, jbacik
From: Alexander Alemayhu <alexander@alemayhu.com>
Date: Tue, 14 Feb 2017 00:02:35 +0100
> Fixes the following warnings:
...
> Reported-by: David Binderman <dcb314@hotmail.com>
> Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-14 19:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-13 23:02 [PATCH] bpf: reduce compiler warnings by adding fallthrough comments Alexander Alemayhu
2017-02-13 23:18 ` Daniel Borkmann
2017-02-14 0:00 ` Alexei Starovoitov
2017-02-14 19:32 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).