From: Abhinav Jain <jain.abhinav177@gmail.com>
To: shuah@kernel.org, brauner@kernel.org, mszeredi@redhat.com,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com,
jain.abhinav177@gmail.com
Subject: [PATCH] selftests: filesystems: add return value checks
Date: Mon, 10 Jun 2024 20:09:09 +0000 [thread overview]
Message-ID: <20240610200909.55819-1-jain.abhinav177@gmail.com> (raw)
Add ksft_exit_fail_msg() return value checks for fchdir() & chroot()
to address the selftests statmount test compile warnings
statmount_test.c:127:2: warning: ignoring return value of ‘fchdir’,
declared with attribute warn_unused_result [-Wunused-result]
127 | fchdir(orig_root);
| ^~~~~~~~~~~~~~~~~
statmount_test.c:128:2: warning: ignoring return value of ‘chroot’,
declared with attribute warn_unused_result [-Wunused-result]
128 | chroot(".");
| ^~~~~~~~~~~
Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
.../filesystems/statmount/statmount_test.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test.c b/tools/testing/selftests/filesystems/statmount/statmount_test.c
index e6d7c4f1c85b..b5e1247233b6 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
@@ -125,8 +125,17 @@ static uint32_t old_root_id, old_parent_id;
static void cleanup_namespace(void)
{
- fchdir(orig_root);
- chroot(".");
+ int ret;
+
+ ret = fchdir(orig_root);
+ if (ret == -1)
+ ksft_exit_fail_msg("changing current directory: %s\n",
+ strerror(errno));
+
+ ret = chroot(".");
+ if (ret == -1)
+ ksft_exit_fail_msg("chroot: %s\n", strerror(errno));
+
umount2(root_mntpoint, MNT_DETACH);
rmdir(root_mntpoint);
}
--
2.34.1
next reply other threads:[~2024-06-10 20:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 20:09 Abhinav Jain [this message]
2024-06-11 15:31 ` [PATCH] selftests: filesystems: add return value checks Shuah Khan
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=20240610200909.55819-1-jain.abhinav177@gmail.com \
--to=jain.abhinav177@gmail.com \
--cc=brauner@kernel.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/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