[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250513100207.114000-1-chenlinxuan@uniontech.com>
Date: Tue, 13 May 2025 18:01:53 +0800
From: Chen Linxuan <chenlinxuan@...ontech.com>
To: Shuah Khan <shuah@...nel.org>,
Amir Goldstein <amir73il@...il.com>,
Chen Linxuan <chenlinxuan@...ontech.com>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
Miklos Szeredi <mszeredi@...hat.com>
Cc: linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] selftests: Suppress unused variable warning
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@...ontech.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 59a71f22fb118..de847e2b12017 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
@@ -487,7 +487,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
Powered by blists - more mailing lists