Skip to contentSkip to conversation

selftests/bpf: remove unused duration variable from cgroup_attach_multi

PATCH In review [email protected] 3 participants 3 messages Oct 15 – Oct 16

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

PATCH 1/1 selftests/bpf: remove unused duration variable from cgroup_attach_multi

From: Palak Raval <[email protected]>

The duration variable is not referenced anywhere in the file.

Remove the unused variable.

---
 tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c | 1 -
 1 file changed, 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c +0 -1
index db0b7bac78d1..9037e98f6f76 100644
@@ -81,7 +81,6 @@ void serial_test_cgroup_attach_multi(void)
 	DECLARE_LIBBPF_OPTS(bpf_prog_attach_opts, attach_opts);
 	int allow_prog[7] = {-1};
 	unsigned long long value;
-	__u32 duration = 0;
 	int i = 0;
 
 	for (i = 0; i < ARRAY_SIZE(allow_prog); i++) {
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] selftests/bpf: build failure from removing duration required by CHECK macro --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] selftests/bpf: build failure from removing duration required by CHECK macro --

commit d7de4f4763b56d10ac8f8dca1287b007d98057b7
Author: Palak Raval <[email protected]>

selftests/bpf: remove unused duration variable from cgroup_attach_multi

This commit removes the duration variable from serial_test_cgroup_attach_multi() under the assumption that it is unused.

tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c void serial_test_cgroup_attach_multi(void) · line 86

Quoted 12 lines
tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c +0 -1
index db0b7bac78d15..9037e98f6f760 100644
@@ -81,7 +81,6 @@ void serial_test_cgroup_attach_multi(void)
 	DECLARE_LIBBPF_OPTS(bpf_prog_attach_opts, attach_opts);
 	int allow_prog[7] = {-1};
 	unsigned long long value;
-	__u32 duration = 0;
 	int i = 0;
 
 	for (i = 0; i < ARRAY_SIZE(allow_prog); i++) {

[Severity: Low]
Will removing this variable cause a build failure?

The BPF selftest framework's deprecated CHECK() macro implicitly requires the duration variable to be present in the caller's scope, as it expands to _CHECK(condition, tag, duration, format...).

Because serial_test_cgroup_attach_multi() uses CHECK() right below this, and extensively throughout its body:

	for (i = 0; i < ARRAY_SIZE(allow_prog); i++) {
		allow_prog[i] = prog_load_cnt(1, 1 << i);
		if (CHECK(allow_prog[i] < 0, "prog_load",
			  "verifier output:\n%s\n-------\n", bpf_log_buf))
			goto err;
	}

removing the duration variable causes an undeclared identifier compilation error.

To safely remove the duration variable, the test must first be migrated to the modern ASSERT_*() macros.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1