bpf: reduce compiler warnings by adding fallthrough comments
authorAlexander Alemayhu <alexander@alemayhu.com>
Mon, 13 Feb 2017 23:02:35 +0000 (00:02 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Feb 2017 19:32:12 +0000 (14:32 -0500)
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>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/verifier.c

index 1a754e5d2695c58bc76346657623a4b01b64fc19..d2bded2b250c876750b869d08273ceae0b181cbd 100644 (file)
@@ -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.