Commit 7e57fbb2 authored by Alexander Alemayhu's avatar Alexander Alemayhu Committed by David S. Miller

bpf: reduce compiler warnings by adding fallthrough comments

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: default avatarDavid Binderman <dcb314@hotmail.com>
Signed-off-by: default avatarAlexander Alemayhu <alexander@alemayhu.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2be4cb97
...@@ -701,6 +701,7 @@ static bool may_access_direct_pkt_data(struct bpf_verifier_env *env, ...@@ -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 */ /* dst_input() and dst_output() can't write for now */
if (t == BPF_WRITE) if (t == BPF_WRITE)
return false; return false;
/* fallthrough */
case BPF_PROG_TYPE_SCHED_CLS: case BPF_PROG_TYPE_SCHED_CLS:
case BPF_PROG_TYPE_SCHED_ACT: case BPF_PROG_TYPE_SCHED_ACT:
case BPF_PROG_TYPE_XDP: case BPF_PROG_TYPE_XDP:
...@@ -2007,6 +2008,7 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg, ...@@ -2007,6 +2008,7 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg,
case BPF_JGT: case BPF_JGT:
/* Unsigned comparison, the minimum value is 0. */ /* Unsigned comparison, the minimum value is 0. */
false_reg->min_value = 0; false_reg->min_value = 0;
/* fallthrough */
case BPF_JSGT: case BPF_JSGT:
/* If this is false then we know the maximum val is val, /* If this is false then we know the maximum val is val,
* otherwise we know the min val is val+1. * 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, ...@@ -2017,6 +2019,7 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg,
case BPF_JGE: case BPF_JGE:
/* Unsigned comparison, the minimum value is 0. */ /* Unsigned comparison, the minimum value is 0. */
false_reg->min_value = 0; false_reg->min_value = 0;
/* fallthrough */
case BPF_JSGE: case BPF_JSGE:
/* If this is false then we know the maximum value is val - 1, /* If this is false then we know the maximum value is val - 1,
* otherwise we know the mimimum value is val. * 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, ...@@ -2055,6 +2058,7 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg,
case BPF_JGT: case BPF_JGT:
/* Unsigned comparison, the minimum value is 0. */ /* Unsigned comparison, the minimum value is 0. */
true_reg->min_value = 0; true_reg->min_value = 0;
/* fallthrough */
case BPF_JSGT: case BPF_JSGT:
/* /*
* If this is false, then the val is <= the register, if it is * 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, ...@@ -2066,6 +2070,7 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg,
case BPF_JGE: case BPF_JGE:
/* Unsigned comparison, the minimum value is 0. */ /* Unsigned comparison, the minimum value is 0. */
true_reg->min_value = 0; true_reg->min_value = 0;
/* fallthrough */
case BPF_JSGE: case BPF_JSGE:
/* If this is false then constant < register, if it is true then /* If this is false then constant < register, if it is true then
* the register < constant. * the register < constant.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment