From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: Chen Linxuan <chenlinxuan@uniontech.com>,
Shuah Khan <shuah@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Amir Goldstein <amir73il@gmail.com>,
John Hubbard <jhubbard@nvidia.com>,
Miklos Szeredi <mszeredi@redhat.com>, Jan Kara <jack@suse.cz>
Cc: zhanjun@uniontech.com, niecheng1@uniontech.com,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] selftests/filesystems/mount-notify: fix unused unused result warning
Date: Fri, 20 Jun 2025 19:46:05 +0500 [thread overview]
Message-ID: <213adda0-1db2-46e7-9342-cc97fbd58d96@collabora.com> (raw)
In-Reply-To: <20250620035125.2938774-2-chenlinxuan@uniontech.com>
On 6/20/25 8:50 AM, Chen Linxuan wrote:
> 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("/");
> | ^~~~~~~~~~
>
> Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> ---
> Changes in v2:
> - Apply changes suggested by Shuah Khan
> - Link to v1: https://lore.kernel.org/all/20250610020758.2798787-2-chenlinxuan@uniontech.com/
> ---
> .../filesystems/mount-notify/mount-notify_test.c | 15 ++++++++++-----
> .../mount-notify/mount-notify_test_ns.c | 15 ++++++++++-----
> 2 files changed, 20 insertions(+), 10 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 5a3b0ace1a88c..f8e0c6b06e2d9 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> @@ -458,12 +458,17 @@ 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);
> + if (chdir("/"))
Please use the APIs provided by the kselftest_harness.h instead of checking
return types manually. For example:
use ASSERT_EQ(chdir("/", 0)).
> + exit(-1);
> + if (unshare(CLONE_NEWNS))
> + exit(-1);
> + if (mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL))
> + exit(-1);
> + if (umount2("/a", MNT_DETACH))
> + exit(-1);
> // This triggers a detach in the other namespace
> - rmdir("/a");
> + if (rmdir("/a"))
> + exit(-1);
> exit(0);
> }
> wait(NULL);
> 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 d91946e69591a..d6a6a7ee87028 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,12 +486,17 @@ 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);
> + if (chdir("/"))
> + exit(-1);
> + if (unshare(CLONE_NEWNS))
> + exit(-1);
> + if (mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL))
> + exit(-1);
> + if (umount2("/a", MNT_DETACH))
> + exit(-1);
> // This triggers a detach in the other namespace
> - rmdir("/a");
> + if (rmdir("/a"))
> + exit(-1);
> exit(0);
> }
> wait(NULL);
next prev parent reply other threads:[~2025-06-20 14:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 3:50 Chen Linxuan
2025-06-20 14:46 ` Muhammad Usama Anjum [this message]
2025-06-20 14:55 ` Chen Linxuan
2025-06-23 4:22 ` Muhammad Usama Anjum
2025-06-23 5:00 ` Chen Linxuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=213adda0-1db2-46e7-9342-cc97fbd58d96@collabora.com \
--to=usama.anjum@collabora.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=chenlinxuan@uniontech.com \
--cc=jack@suse.cz \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=niecheng1@uniontech.com \
--cc=shuah@kernel.org \
--cc=zhanjun@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®