* [PATCH] selftests/bpf: Remove unused variable
@ 2024-11-18 9:34 Zhu Jun
2024-11-18 16:40 ` Yonghong Song
0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2024-11-18 9:34 UTC (permalink / raw)
To: shuah; +Cc: bpf, linux-kselftest, linux-kernel, zhujun2, martin.lau, ast
the variable is never referenced in the code, just remove them.
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
tools/testing/selftests/bpf/prog_tests/log_buf.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/log_buf.c b/tools/testing/selftests/bpf/prog_tests/log_buf.c
index 27676a04d0b6..5d1678b15d8b 100644
--- a/tools/testing/selftests/bpf/prog_tests/log_buf.c
+++ b/tools/testing/selftests/bpf/prog_tests/log_buf.c
@@ -191,7 +191,6 @@ static void bpf_prog_load_log_buf(void)
ASSERT_LT(fd, 0, "bad_fd");
if (fd >= 0)
close(fd);
- fd = -1;
free(log_buf);
}
@@ -259,7 +258,6 @@ static void bpf_btf_load_log_buf(void)
ASSERT_LT(fd, 0, "bad_fd");
if (fd >= 0)
close(fd);
- fd = -1;
cleanup:
free(log_buf);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/bpf: Remove unused variable
2024-11-18 9:34 [PATCH] selftests/bpf: Remove unused variable Zhu Jun
@ 2024-11-18 16:40 ` Yonghong Song
0 siblings, 0 replies; 2+ messages in thread
From: Yonghong Song @ 2024-11-18 16:40 UTC (permalink / raw)
To: Zhu Jun, shuah; +Cc: bpf, linux-kselftest, linux-kernel, martin.lau, ast
On 11/18/24 1:34 AM, Zhu Jun wrote:
> the variable is never referenced in the code, just remove them.
>
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
> tools/testing/selftests/bpf/prog_tests/log_buf.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/log_buf.c b/tools/testing/selftests/bpf/prog_tests/log_buf.c
> index 27676a04d0b6..5d1678b15d8b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/log_buf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/log_buf.c
> @@ -191,7 +191,6 @@ static void bpf_prog_load_log_buf(void)
> ASSERT_LT(fd, 0, "bad_fd");
> if (fd >= 0)
> close(fd);
> - fd = -1;
>
> free(log_buf);
> }
This patch failed to apply to latest bpf-next.
$ git apply ~/p1.txt
error: patch failed: tools/testing/selftests/bpf/prog_tests/log_buf.c:191
error: tools/testing/selftests/bpf/prog_tests/log_buf.c: patch does not apply
The reason is the above 'fd = -1' already gone:
188 ASSERT_OK_PTR(strstr(log_buf, "R0 !read_ok"), "bad_log_0");
189 ASSERT_LT(fd, 0, "bad_fd");
190 if (fd >= 0)
191 close(fd);
192
193 free(log_buf);
194 }
> @@ -259,7 +258,6 @@ static void bpf_btf_load_log_buf(void)
> ASSERT_LT(fd, 0, "bad_fd");
> if (fd >= 0)
> close(fd);
> - fd = -1;
>
> cleanup:
> free(log_buf);
There are more redundant 'fd = -1' in function bpf_btf_load_log_buf(),
you may want to remove them as well.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-18 16:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 9:34 [PATCH] selftests/bpf: Remove unused variable Zhu Jun
2024-11-18 16:40 ` Yonghong Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).