mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/filesystems: Use return value of the function 'chdir()'
@ 2025-07-10  0:19 Alessandro Zanni
  2025-09-08 14:03 ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Zanni @ 2025-07-10  0:19 UTC (permalink / raw)
  To: shuah, brauner, amir73il, jhubbard, jack, mszeredi
  Cc: Alessandro Zanni, linux-kselftest, linux-kernel

Fix to use the return value of the function 'chdir("/")' and check if the
return is either 0 (ok) or 1 (not ok, so the test stops).

The patch fies the solves the following errors:
mount-notify_test.c:468:17: warning: ignoring return value of ‘chdir’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
  468 |                 chdir("/");

mount-notify_test_ns.c:489:17: warning: ignoring return value of
‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-
result]
  489 |                 chdir("/");

To reproduce the issue, use the command:
make kselftest TARGET=filesystems/statmount

Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
---
 .../selftests/filesystems/mount-notify/mount-notify_test.c      | 2 +-
 .../selftests/filesystems/mount-notify/mount-notify_test_ns.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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 5a3b0ace1a88..a7f899599d52 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
@@ -458,7 +458,7 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		ASSERT_EQ(0, chdir("/"));
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
index d91946e69591..dc9eb3087a1a 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
@@ -486,7 +486,7 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		ASSERT_EQ(0, chdir("/"));
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
-- 
2.43.0


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

* Re: [PATCH] selftests/filesystems: Use return value of the function 'chdir()'
  2025-07-10  0:19 [PATCH] selftests/filesystems: Use return value of the function 'chdir()' Alessandro Zanni
@ 2025-09-08 14:03 ` Jan Kara
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2025-09-08 14:03 UTC (permalink / raw)
  To: Alessandro Zanni
  Cc: shuah, brauner, amir73il, jhubbard, jack, mszeredi,
	linux-kselftest, linux-kernel

On Thu 10-07-25 02:19:25, Alessandro Zanni wrote:
> Fix to use the return value of the function 'chdir("/")' and check if the
> return is either 0 (ok) or 1 (not ok, so the test stops).
> 
> The patch fies the solves the following errors:
> mount-notify_test.c:468:17: warning: ignoring return value of ‘chdir’
> declared with attribute ‘warn_unused_result’ [-Wunused-result]
>   468 |                 chdir("/");
> 
> mount-notify_test_ns.c:489:17: warning: ignoring return value of
> ‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-
> result]
>   489 |                 chdir("/");
> 
> To reproduce the issue, use the command:
> make kselftest TARGET=filesystems/statmount
> 
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  .../selftests/filesystems/mount-notify/mount-notify_test.c      | 2 +-
>  .../selftests/filesystems/mount-notify/mount-notify_test_ns.c   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> 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 5a3b0ace1a88..a7f899599d52 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> @@ -458,7 +458,7 @@ TEST_F(fanotify, rmdir)
>  	ASSERT_GE(ret, 0);
>  
>  	if (ret == 0) {
> -		chdir("/");
> +		ASSERT_EQ(0, chdir("/"));
>  		unshare(CLONE_NEWNS);
>  		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
>  		umount2("/a", MNT_DETACH);
> diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> index d91946e69591..dc9eb3087a1a 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> @@ -486,7 +486,7 @@ TEST_F(fanotify, rmdir)
>  	ASSERT_GE(ret, 0);
>  
>  	if (ret == 0) {
> -		chdir("/");
> +		ASSERT_EQ(0, chdir("/"));
>  		unshare(CLONE_NEWNS);
>  		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
>  		umount2("/a", MNT_DETACH);
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* [PATCH] selftests/filesystems: Use return value of the function 'chdir()'
@ 2025-09-08 17:35 Alessandro Zanni
  0 siblings, 0 replies; 4+ messages in thread
From: Alessandro Zanni @ 2025-09-08 17:35 UTC (permalink / raw)
  To: shuah, brauner, amir73il, jhubbard, jack, mszeredi
  Cc: Alessandro Zanni, linux-kselftest, linux-kernel

Fix to use the return value of the function 'chdir("/")' and check if the
return is either 0 (ok) or 1 (not ok, so the test stops).

The patch fies the solves the following errors:
mount-notify_test.c:468:17: warning: ignoring return value of ‘chdir’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
  468 |                 chdir("/");

mount-notify_test_ns.c:489:17: warning: ignoring return value of
‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-
result]
  489 |                 chdir("/");

To reproduce the issue, use the command:
make kselftest TARGET=filesystems/statmount

Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 .../selftests/filesystems/mount-notify/mount-notify_test.c      | 2 +-
 .../selftests/filesystems/mount-notify/mount-notify_test_ns.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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 5a3b0ace1a88..a7f899599d52 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
@@ -458,7 +458,7 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		ASSERT_EQ(0, chdir("/"));
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
index d91946e69591..dc9eb3087a1a 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
@@ -486,7 +486,7 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		ASSERT_EQ(0, chdir("/"));
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
-- 
2.43.0


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

* [PATCH] selftests/filesystems: Use return value of the function 'chdir()'
@ 2025-09-08 17:34 Alessandro Zanni
  0 siblings, 0 replies; 4+ messages in thread
From: Alessandro Zanni @ 2025-09-08 17:34 UTC (permalink / raw)
  To: shuah, brauner, amir73il, jhubbard, jack, mszeredi
  Cc: Alessandro Zanni, linux-kselftest, linux-kernel

Fix to use the return value of the function 'chdir("/")' and check if the
return is either 0 (ok) or 1 (not ok, so the test stops).

The patch fies the solves the following errors:
mount-notify_test.c:468:17: warning: ignoring return value of ‘chdir’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
  468 |                 chdir("/");

mount-notify_test_ns.c:489:17: warning: ignoring return value of
‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-
result]
  489 |                 chdir("/");

To reproduce the issue, use the command:
make kselftest TARGET=filesystems/statmount

Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
---
 .../selftests/filesystems/mount-notify/mount-notify_test.c      | 2 +-
 .../selftests/filesystems/mount-notify/mount-notify_test_ns.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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 5a3b0ace1a88..a7f899599d52 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
@@ -458,7 +458,7 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		ASSERT_EQ(0, chdir("/"));
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
index d91946e69591..dc9eb3087a1a 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
@@ -486,7 +486,7 @@ TEST_F(fanotify, rmdir)
 	ASSERT_GE(ret, 0);
 
 	if (ret == 0) {
-		chdir("/");
+		ASSERT_EQ(0, chdir("/"));
 		unshare(CLONE_NEWNS);
 		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
 		umount2("/a", MNT_DETACH);
-- 
2.43.0


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

end of thread, other threads:[~2025-09-08 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-10  0:19 [PATCH] selftests/filesystems: Use return value of the function 'chdir()' Alessandro Zanni
2025-09-08 14:03 ` Jan Kara
2025-09-08 17:34 Alessandro Zanni
2025-09-08 17:35 Alessandro Zanni

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®