Skip to contentSkip to conversation

selftests/filesystems/mount-notify: fix unused unused result warning

PATCH New Chen Linxuan 1 participant 1 message Jun 23, 2025 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 selftests/filesystems/mount-notify: fix unused unused result 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("/");
      |                 ^~~~~~~~~~

---
Changes in v3:
- Apply changes suggested by Muhammad Usama Anjum
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Apply changes suggested by Shuah Khan
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 .../filesystems/mount-notify/mount-notify_test.c       | 10 +++++-----
 .../filesystems/mount-notify/mount-notify_test_ns.c    | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)
tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c +5 -5
index 5a3b0ace1a88c..30ed5e00800ba 100644
@@ -458,12 +458,12 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
-		unshare(CLONE_NEWNS);
-		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
-		umount2("/a", MNT_DETACH);
+		ASSERT_EQ(chdir("/"), 0);
+		ASSERT_EQ(unshare(CLONE_NEWNS), 0);
+		ASSERT_EQ(mount("", "/", NULL, MS_REC | MS_PRIVATE, NULL), 0);
+		ASSERT_EQ(umount2("/a", MNT_DETACH), 0);
 		// This triggers a detach in the other namespace
-		rmdir("/a");
+		ASSERT_EQ(rmdir("/a"), 0);
 		exit(0);
 	}
 	wait(NULL);
tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c +5 -5
index d91946e69591a..11a2cfeb1eb94 100644
@@ -486,12 +486,12 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
-		unshare(CLONE_NEWNS);
-		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
-		umount2("/a", MNT_DETACH);
+		ASSERT_EQ(chdir("/"), 0);
+		ASSERT_EQ(unshare(CLONE_NEWNS), 0);
+		ASSERT_EQ(mount("", "/", NULL, MS_REC | MS_PRIVATE, NULL), 0);
+		ASSERT_EQ(umount2("/a", MNT_DETACH), 0);
 		// This triggers a detach in the other namespace
-		rmdir("/a");
+		ASSERT_EQ(rmdir("/a"), 0);
 		exit(0);
 	}
 	wait(NULL);
Signature · 1 line
2.43.0