diff mbox series

selftests: remove unused variable in close_range test

Message ID 20220823224811.12758-1-adelg@google.com
State New
Headers show
Series selftests: remove unused variable in close_range test | expand

Commit Message

Andrew Delgadilo Aug. 23, 2022, 10:48 p.m. UTC
From: Andrew Delgadillo <adelg@google.com>

commit 2c5db60e46ad ("tests: add close_range() tests") adds the
close_range test under the core namespace. In its current form, the
close_range test has an unused variable, namely, ret. For those building
with -Werror,-Wall, this breaks the build.

Without this patch:
$ make -C tools/testing/selftests/ TARGETS=core V=1 CFLAGS="-Werror -Wall"
> make: Entering directory '/.../kernel-src/tools/testing/selftests'
> make[1]: Entering directory '/.../kernel-src/tools/testing/selftests/core'
> gcc -Werror -Wall    close_range_test.c  -o /.../kernel-src/tools/testing/selftests/core/close_range_test
> close_range_test.c: In function 'core_close_range':
> close_range_test.c:55:16: error: unused variable 'ret' [-Werror=unused-variable]
>   55 |         int i, ret;
>      |                ^~~
> cc1: all warnings being treated as errors
> make[1]: *** [../lib.mk:135: /.../kernel-src/tools/testing/selftests/core/close_range_test] Error 1
> make[1]: Leaving directory '/.../kernel-src/tools/testing/selftests/core'
> make: *** [Makefile:155: all] Error 2
> make: Leaving directory '/.../kernel-src/tools/testing/selftests'

With this patch:
$ make -C tools/testing/selftests/ TARGETS=core V=1 CFLAGS="-Werror -Wall"
> make: Entering directory '/.../kernel-src/tools/testing/selftests'
> make[1]: Entering directory '/.../kernel-src/tools/testing/selftests/core'
> gcc -Werror -Wall    close_range_test.c  -o /.../kernel-src/tools/testing/selftests/core/close_range_test
> make[1]: Leaving directory '/.../kernel-src/tools/testing/selftests/core'
> make: Leaving directory '/.../kernel-src/tools/testing/selftests'

Fixes: 2c5db60e46ad ("tests: add close_range() tests")
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Delgadillo <adelg@google.com>
---
 tools/testing/selftests/core/close_range_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/core/close_range_test.c b/tools/testing/selftests/core/close_range_test.c
index 749239930ca83..17c76c6c13cb9 100644
--- a/tools/testing/selftests/core/close_range_test.c
+++ b/tools/testing/selftests/core/close_range_test.c
@@ -52,7 +52,7 @@  static inline int sys_close_range(unsigned int fd, unsigned int max_fd,
 
 TEST(core_close_range)
 {
-	int i, ret;
+	int i;
 	int open_fds[101];
 
 	for (i = 0; i < ARRAY_SIZE(open_fds); i++) {