Skip to contentSkip to conversation

selftests/bpf: Suppress warning message of an unused variable.

PATCH Applied [email protected] 3 participants 3 messages Feb 4, 2024 – Feb 5, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Suppress warning message of an unused variable.

From: Kui-Feng Lee <[email protected]>

"r" is used to receive the return value of test_1 in bpf_testmod.c, but it is not actually used. So, we remove "r" and change the return type to "void".

---
 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 6 ++----
 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.h | 2 +-
 tools/testing/selftests/bpf/progs/struct_ops_module.c | 3 +--
 3 files changed, 4 insertions(+), 7 deletions(-)
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c +2 -4
index 4754c662b39f..a06daebc75c9 100644
@@ -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;
 }
@@ -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 = {
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.h +1 -1
index ca5435751c79..537beca42896 100644
@@ -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 */
tools/testing/selftests/bpf/progs/struct_ops_module.c +1 -2
index e44ac55195ca..b78746b3cef3 100644
@@ -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")
Signature · 1 line
2.34.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On 2/3/24 10:12 PM, [email protected] wrote:

From: Kui-Feng Lee <[email protected]>

"r" is used to receive the return value of test_1 in bpf_testmod.c, but it is not actually used. So, we remove "r" and change the return type to "void".

#2 lore raw
In reply to [email protected]
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 11 lines · On Sat, 3 Feb 2024 22:12:04 -0800 you wrote:

From: Kui-Feng Lee <[email protected]>

"r" is used to receive the return value of test_1 in bpf_testmod.c, but it is not actually used. So, we remove "r" and change the return type to "void".

[...]

Here is the summary with links:
- [bpf-next] selftests/bpf: Suppress warning message of an unused variable.

    https://git.kernel.org/bpf/bpf-next/c/169e65006964

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html