Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2049aad

Browse files
Amer-shanawanyshuahkh
authored andcommitted
selftests: filesystems: fix warn_unused_result build warnings
Fix the following warnings by adding return check and error messages. statmount_test.c: In function ‘cleanup_namespace’: statmount_test.c:128:9: warning: ignoring return value of ‘fchdir’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 128 | fchdir(orig_root); | ^~~~~~~~~~~~~~~~~ statmount_test.c:129:9: warning: ignoring return value of ‘chroot’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 129 | chroot("."); | ^~~~~~~~~~~ Signed-off-by: Amer Al Shanawany <amer.shanawany@gmail.com> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 4bf15b1 commit 2049aad

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tools/testing/selftests/filesystems/statmount/statmount_test.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,16 @@ static uint32_t old_root_id, old_parent_id;
125125

126126
static void cleanup_namespace(void)
127127
{
128-
fchdir(orig_root);
129-
chroot(".");
128+
int ret;
129+
130+
ret = fchdir(orig_root);
131+
if (ret == -1)
132+
ksft_perror("fchdir to original root");
133+
134+
ret = chroot(".");
135+
if (ret == -1)
136+
ksft_perror("chroot to original root");
137+
130138
umount2(root_mntpoint, MNT_DETACH);
131139
rmdir(root_mntpoint);
132140
}

0 commit comments

Comments
 (0)