LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: filesystems: fix warn_unused_result build warnings
@ 2024-04-17 18:49 Amer Al Shanawany
  2024-04-19 16:41 ` Muhammad Usama Anjum
  0 siblings, 1 reply; 5+ messages in thread
From: Amer Al Shanawany @ 2024-04-17 18:49 UTC (permalink / raw
  To: Shuah Khan, Christian Brauner, Miklos Szeredi, linux-kselftest,
	linux-kernel
  Cc: Javier Carrasco

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>
---
 .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++--
 1 file changed, 10 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..e8c019d72cbf 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
@@ -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);
 }
-- 
2.34.1


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

* Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings
  2024-04-17 18:49 [PATCH] selftests: filesystems: fix warn_unused_result build warnings Amer Al Shanawany
@ 2024-04-19 16:41 ` Muhammad Usama Anjum
  2024-05-04 17:17   ` Amer Al Shanawany
  0 siblings, 1 reply; 5+ messages in thread
From: Muhammad Usama Anjum @ 2024-04-19 16:41 UTC (permalink / raw
  To: Amer Al Shanawany, Shuah Khan, Christian Brauner, Miklos Szeredi,
	linux-kselftest, linux-kernel
  Cc: Muhammad Usama Anjum, Javier Carrasco

On 4/17/24 11:49 PM, Amer Al Shanawany wrote:
> 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>

> ---
>  .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++--
>  1 file changed, 10 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..e8c019d72cbf 100644
> --- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
> @@ -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);
>  }

-- 
BR,
Muhammad Usama Anjum

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

* Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings
  2024-04-19 16:41 ` Muhammad Usama Anjum
@ 2024-05-04 17:17   ` Amer Al Shanawany
  2024-06-03 11:17     ` Amer Al Shanawany
  0 siblings, 1 reply; 5+ messages in thread
From: Amer Al Shanawany @ 2024-05-04 17:17 UTC (permalink / raw
  To: Muhammad Usama Anjum, Shuah Khan, Christian Brauner,
	Miklos Szeredi, linux-kselftest, linux-kernel
  Cc: Javier Carrasco

On 4/19/24 18:41, Muhammad Usama Anjum wrote:
> On 4/17/24 11:49 PM, Amer Al Shanawany wrote:
>> 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>
>
>> ---
>>  .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++--
>>  1 file changed, 10 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..e8c019d72cbf 100644
>> --- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
>> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
>> @@ -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);
>>  }
Hi,

Can you please consider this patch?

Thank  you

Amer


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

* Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings
  2024-05-04 17:17   ` Amer Al Shanawany
@ 2024-06-03 11:17     ` Amer Al Shanawany
  2024-06-11 15:23       ` Shuah Khan
  0 siblings, 1 reply; 5+ messages in thread
From: Amer Al Shanawany @ 2024-06-03 11:17 UTC (permalink / raw
  To: Muhammad Usama Anjum, Shuah Khan, Christian Brauner,
	Miklos Szeredi, linux-kselftest, linux-kernel
  Cc: Javier Carrasco

On 5/4/24 19:17, Amer Al Shanawany wrote:
> On 4/19/24 18:41, Muhammad Usama Anjum wrote:
>> On 4/17/24 11:49 PM, Amer Al Shanawany wrote:
>>> 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>
>>
>>> ---
>>>  .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++--
>>>  1 file changed, 10 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..e8c019d72cbf 100644
>>> --- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
>>> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
>>> @@ -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);
>>>  }
> Hi,
>
> 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

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

* Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings
  2024-06-03 11:17     ` Amer Al Shanawany
@ 2024-06-11 15:23       ` Shuah Khan
  0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2024-06-11 15:23 UTC (permalink / raw
  To: Amer Al Shanawany, Muhammad Usama Anjum, Shuah Khan,
	Christian Brauner, Miklos Szeredi, linux-kselftest, linux-kernel
  Cc: Javier Carrasco, Shuah Khan

On 6/3/24 05:17, Amer Al Shanawany wrote:
> On 5/4/24 19:17, Amer Al Shanawany wrote:
>> On 4/19/24 18:41, Muhammad Usama Anjum wrote:
>>> On 4/17/24 11:49 PM, Amer Al Shanawany wrote:
>>>> 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>
>>>
>>>> ---
>>>>   .../selftests/filesystems/statmount/statmount_test.c | 12 ++++++++++--
>>>>   1 file changed, 10 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..e8c019d72cbf 100644
>>>> --- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
>>>> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
>>>> @@ -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);
>>>>   }
>> Hi,
>>
>> 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

Applied to linux-kselftest fixes branch for the next rc.

thanks,
-- Shuah




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

end of thread, other threads:[~2024-06-11 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-17 18:49 [PATCH] selftests: filesystems: fix warn_unused_result build warnings Amer Al Shanawany
2024-04-19 16:41 ` Muhammad Usama Anjum
2024-05-04 17:17   ` Amer Al Shanawany
2024-06-03 11:17     ` Amer Al Shanawany
2024-06-11 15:23       ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).