diff options
author | Yonghong Song <yonghong.song@linux.dev> | 2023-07-28 07:57:40 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-07-28 17:54:04 +0200 |
commit | 09fedc731874123e0f6e5e5e3572db0c60378c2a (patch) | |
tree | df81445bfd8e43df82cae48c9fc523d0f445e224 /kernel/bpf/verifier.c | |
parent | Merge branch 'bpf-support-new-insns-from-cpu-v4' (diff) | |
download | linux-09fedc731874123e0f6e5e5e3572db0c60378c2a.tar.xz linux-09fedc731874123e0f6e5e5e3572db0c60378c2a.zip |
bpf: Fix compilation warning with -Wparentheses
The kernel test robot reported compilation warnings when -Wparentheses is
added to KBUILD_CFLAGS with gcc compiler. The following is the error message:
.../bpf-next/kernel/bpf/verifier.c: In function ‘coerce_reg_to_size_sx’:
.../bpf-next/kernel/bpf/verifier.c:5901:14:
error: suggest parentheses around comparison in operand of ‘==’ [-Werror=parentheses]
if (s64_max >= 0 == s64_min >= 0) {
~~~~~~~~^~~~
.../bpf-next/kernel/bpf/verifier.c: In function ‘coerce_subreg_to_size_sx’:
.../bpf-next/kernel/bpf/verifier.c:5965:14:
error: suggest parentheses around comparison in operand of ‘==’ [-Werror=parentheses]
if (s32_min >= 0 == s32_max >= 0) {
~~~~~~~~^~~~
To fix the issue, add proper parentheses for the above '>=' condition
to silence the warning/error.
I tried a few clang compilers like clang16 and clang18 and they do not emit
such warnings with -Wparentheses.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307281133.wi0c4SqG-lkp@intel.com/
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230728055740.2284534-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/verifier.c')
-rw-r--r-- | kernel/bpf/verifier.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 0b1ada93582b..e7b1af016841 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5898,7 +5898,7 @@ static void coerce_reg_to_size_sx(struct bpf_reg_state *reg, int size) s64_min = min(init_s64_max, init_s64_min); /* both of s64_max/s64_min positive or negative */ - if (s64_max >= 0 == s64_min >= 0) { + if ((s64_max >= 0) == (s64_min >= 0)) { reg->smin_value = reg->s32_min_value = s64_min; reg->smax_value = reg->s32_max_value = s64_max; reg->umin_value = reg->u32_min_value = s64_min; @@ -5962,7 +5962,7 @@ static void coerce_subreg_to_size_sx(struct bpf_reg_state *reg, int size) s32_max = max(init_s32_max, init_s32_min); s32_min = min(init_s32_max, init_s32_min); - if (s32_min >= 0 == s32_max >= 0) { + if ((s32_min >= 0) == (s32_max >= 0)) { reg->s32_min_value = s32_min; reg->s32_max_value = s32_max; reg->u32_min_value = (u32)s32_min; |