Skip to content

Commit

Permalink
selftests/bpf: Suppress warning message of an unused variable.
Browse files Browse the repository at this point in the history
"r" is used to receive the return value of test_2 in bpf_testmod.c, but it
is not actually used. So, we remove "r" and change the return type to
"void".

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401300557.z5vzn8FM-lkp@intel.com/
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240204061204.1864529-1-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
  • Loading branch information
Kui-Feng Lee authored and Martin KaFai Lau committed Feb 5, 2024
1 parent 7e42863 commit 169e650
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,8 @@ static const struct bpf_verifier_ops bpf_testmod_verifier_ops = {
static int bpf_dummy_reg(void *kdata)
{
struct bpf_testmod_ops *ops = kdata;
int r;

r = ops->test_2(4, 3);
ops->test_2(4, 3);

return 0;
}
Expand All @@ -570,9 +569,8 @@ static int bpf_testmod_test_1(void)
return 0;
}

static int bpf_testmod_test_2(int a, int b)
static void bpf_testmod_test_2(int a, int b)
{
return 0;
}

static struct bpf_testmod_ops __bpf_testmod_ops = {
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct bpf_iter_testmod_seq {

struct bpf_testmod_ops {
int (*test_1)(void);
int (*test_2)(int a, int b);
void (*test_2)(int a, int b);
};

#endif /* _BPF_TESTMOD_H */
3 changes: 1 addition & 2 deletions tools/testing/selftests/bpf/progs/struct_ops_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ int BPF_PROG(test_1)
}

SEC("struct_ops/test_2")
int BPF_PROG(test_2, int a, int b)
void BPF_PROG(test_2, int a, int b)
{
test_2_result = a + b;
return a + b;
}

SEC(".struct_ops.link")
Expand Down

0 comments on commit 169e650

Please sign in to comment.