selftests: filesystems: fix warn_unused_result build warnings
PATCH 1/1 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(".");
| ^~~~~~~~~~~--- .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
tools/testing/selftests/filesystems/statmount/statmount_test.c +10 -2
@@ -125,8 +125,16 @@ 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_perror ("fchdir to original root" ); + + ret =chroot ("." ); +if (ret ==-1 ) +ksft_perror ("chroot to original root" ); +umount2 (root_mntpoint,MNT_DETACH );rmdir (root_mntpoint); }
Signature · 1 line
2.34.1
Quoted 5 lines · Amer Al Shanawany
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]
Quoted 8 lines
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 <[email protected]>
Quoted 27 lines
--- .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/filesystems/statmount/statmount_test.c +10
-2@@ -125,8 +125,16 @@ 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_perror ("fchdir to original root" ); + + ret =chroot ("." ); +if (ret ==-1 ) +ksft_perror ("chroot to original root" ); +umount2 (root_mntpoint,MNT_DETACH );rmdir (root_mntpoint); }
Signature · 2 lines
BR, Muhammad Usama Anjum
Quoted 35 lines · Muhammad Usama Anjum
Quoted 5 lines · Amer Al Shanawany
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]Quoted 8 lines
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 <[email protected]>Reviewed-by Muhammad Usama Anjum <[email protected]>Quoted 19 lines
--- .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/filesystems/statmount/statmount_test.c +5
-2@@ -125,8 +125,16 @@ 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_perror ("fchdir to original root" );
Quoted 8 lines
tools/testing/selftests/filesystems/statmount/statmount_test.c static uint32_t old_root_id, old_parent_id; · line 140
Quoted 8 lines
tools/testing/selftests/filesystems/statmount/statmount_test.c +5
-0+ + ret =chroot ("." ); +if (ret ==-1 ) +ksft_perror ("chroot to original root" ); +umount2 (root_mntpoint,MNT_DETACH );rmdir (root_mntpoint); }
Hi,
Can you please consider this patch?
Thank you
Amer
Quoted 46 lines · Amer Al Shanawany
Quoted 35 lines · Muhammad Usama Anjum
Quoted 5 lines · Amer Al Shanawany
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]Quoted 8 lines
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 <[email protected]>Reviewed-by Muhammad Usama Anjum <[email protected]>Quoted 19 lines
--- .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/filesystems/statmount/statmount_test.c +5
-2@@ -125,8 +125,16 @@ 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_perror ("fchdir to original root" );Quoted 8 lines
tools/testing/selftests/filesystems/statmount/statmount_test.c static uint32_t old_root_id, old_parent_id; · line 140
Quoted 8 lines
tools/testing/selftests/filesystems/statmount/statmount_test.c +5
-0+ + ret =chroot ("." ); +if (ret ==-1 ) +ksft_perror ("chroot to original root" ); +umount2 (root_mntpoint,MNT_DETACH );rmdir (root_mntpoint); }Hi,
Quoted 8 lines
Can you please consider this patch?
Thank you
Amer
Hello,
Could you please consider this simple patch for fixing build warnings for kselftest ?
Thank you
Amer
Shuah Khan
maintainerQuoted 55 lines · Amer Al Shanawany
Quoted 46 lines · Amer Al Shanawany
Quoted 35 lines · Muhammad Usama Anjum
Quoted 5 lines · Amer Al Shanawany
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]Quoted 8 lines
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 <[email protected]>Reviewed-by Muhammad Usama Anjum <[email protected]>Quoted 19 lines
--- .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/filesystems/statmount/statmount_test.c +5
-2@@ -125,8 +125,16 @@ 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_perror ("fchdir to original root" );Quoted 8 lines
tools/testing/selftests/filesystems/statmount/statmount_test.c static uint32_t old_root_id, old_parent_id; · line 140
Quoted 8 lines
tools/testing/selftests/filesystems/statmount/statmount_test.c +5
-0+ + ret =chroot ("." ); +if (ret ==-1 ) +ksft_perror ("chroot to original root" ); +umount2 (root_mntpoint,MNT_DETACH );rmdir (root_mntpoint); }Hi,
Quoted 8 lines
Can you please consider this patch?
Thank you
Amer
Quoted 7 lines
Hello,
Could you please consider this simple patch for fixing build warnings for kselftest ?
Thank you
Amer
Applied to linux-kselftest fixes branch for the next rc.
thanks,
-- Shuah