mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RESEND] selftests: Suppress unused variable warning
@ 2025-06-10  2:07 Chen Linxuan
  2025-06-18 21:23 ` Shuah Khan
  0 siblings, 1 reply; 8+ messages in thread
From: Chen Linxuan @ 2025-06-10  2:07 UTC (permalink / raw)
  To: Shuah Khan, Christian Brauner, Amir Goldstein, John Hubbard,
	Miklos Szeredi, Jan Kara, Chen Linxuan
  Cc: zhanjun, niecheng1, linux-kselftest, linux-kernel

When running `make kselftest`, the following compilation warning was encountered:

mount-notify_test.c: In function ‘fanotify_rmdir’:
mount-notify_test.c:490:17: warning: ignoring return value of ‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  490 |                 chdir("/");
      |                 ^~~~~~~~~~

This patch addresses the warning by
explicitly suppressing the unused result of the `chdir` function.

Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 .../selftests/filesystems/mount-notify/mount-notify_test.c    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
index 63ce708d93ed0..34afe27b7978f 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
@@ -465,7 +465,9 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		// Suppress -Wunused-result
+		// Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34
+		(void) !chdir("/");
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-20  2:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-10  2:07 [PATCH RESEND] selftests: Suppress unused variable warning Chen Linxuan
2025-06-18 21:23 ` Shuah Khan
2025-06-19  7:46   ` Chen Linxuan
2025-06-19 17:00     ` Shuah Khan
2025-06-19 19:00       ` John Hubbard
2025-06-19 21:40         ` Shuah Khan
2025-06-19 21:43           ` Shuah Khan
2025-06-20  2:06           ` Chen Linxuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®