Linux Kernel Selftest development
 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; 8+ 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] 8+ messages in thread

* Re: [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
  2024-05-04 17:17   ` Amer Al Shanawany
  0 siblings, 1 reply; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ messages in thread

* [PATCH] selftests: filesystems: fix warn_unused_result build warnings
@ 2024-08-10 13:53 Abhinav Jain
  2024-08-16 13:11 ` Shuah Khan
  0 siblings, 1 reply; 8+ messages in thread
From: Abhinav Jain @ 2024-08-10 13:53 UTC (permalink / raw)
  To: shuah, brauner, linux-kselftest, linux-kernel
  Cc: skhan, javier.carrasco.cruz, Abhinav Jain

Add return value checks for read & write calls in test_listmount_ns
function. This patch resolves below compilation warnings:

```
statmount_test_ns.c: In function ‘test_listmount_ns’:

statmount_test_ns.c:322:17: warning: ignoring return value of ‘write’
declared with attribute ‘warn_unused_result’ [-Wunused-result]

statmount_test_ns.c:323:17: warning: ignoring return value of ‘read’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
```

Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
 .../selftests/filesystems/statmount/statmount_test_ns.c    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c b/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
index e044f5fc57fd..70cb0c8b21cf 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
@@ -319,8 +319,11 @@ static void test_listmount_ns(void)
 		 * Tell our parent how many mounts we have, and then wait for it
 		 * to tell us we're done.
 		 */
-		write(child_ready_pipe[1], &nr_mounts, sizeof(nr_mounts));
-		read(parent_ready_pipe[0], &cval, sizeof(cval));
+		if (write(child_ready_pipe[1], &nr_mounts, sizeof(nr_mounts)) !=
+					sizeof(nr_mounts))
+			ret = NSID_ERROR;
+		if (read(parent_ready_pipe[0], &cval, sizeof(cval)) != sizeof(cval))
+			ret = NSID_ERROR;
 		exit(NSID_PASS);
 	}
 
-- 
2.34.1


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

* Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings
  2024-08-10 13:53 [PATCH] selftests: filesystems: fix warn_unused_result build warnings Abhinav Jain
@ 2024-08-16 13:11 ` Shuah Khan
  2024-09-03 17:45   ` Shuah Khan
  0 siblings, 1 reply; 8+ messages in thread
From: Shuah Khan @ 2024-08-16 13:11 UTC (permalink / raw)
  To: Abhinav Jain, shuah, brauner, linux-kselftest, linux-kernel
  Cc: javier.carrasco.cruz, Shuah Khan

On 8/10/24 07:53, Abhinav Jain wrote:
> Add return value checks for read & write calls in test_listmount_ns
> function. This patch resolves below compilation warnings:
> 
> ```
> statmount_test_ns.c: In function ‘test_listmount_ns’:
> 
> statmount_test_ns.c:322:17: warning: ignoring return value of ‘write’
> declared with attribute ‘warn_unused_result’ [-Wunused-result]
> 
> statmount_test_ns.c:323:17: warning: ignoring return value of ‘read’
> declared with attribute ‘warn_unused_result’ [-Wunused-result]
> ```
> 
> Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
> ---
>   .../selftests/filesystems/statmount/statmount_test_ns.c    | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c b/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
> index e044f5fc57fd..70cb0c8b21cf 100644
> --- a/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
> @@ -319,8 +319,11 @@ static void test_listmount_ns(void)
>   		 * Tell our parent how many mounts we have, and then wait for it
>   		 * to tell us we're done.
>   		 */
> -		write(child_ready_pipe[1], &nr_mounts, sizeof(nr_mounts));
> -		read(parent_ready_pipe[0], &cval, sizeof(cval));
> +		if (write(child_ready_pipe[1], &nr_mounts, sizeof(nr_mounts)) !=
> +					sizeof(nr_mounts))
> +			ret = NSID_ERROR;
> +		if (read(parent_ready_pipe[0], &cval, sizeof(cval)) != sizeof(cval))
> +			ret = NSID_ERROR;
>   		exit(NSID_PASS);
>   	}
>   

Hi Christian,

Let me know if it is okay to take this patch through kselftest tree.
The change looks good to me.

thanks,
-- Shuah

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

* Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings
  2024-08-16 13:11 ` Shuah Khan
@ 2024-09-03 17:45   ` Shuah Khan
  0 siblings, 0 replies; 8+ messages in thread
From: Shuah Khan @ 2024-09-03 17:45 UTC (permalink / raw)
  To: Abhinav Jain, shuah
  Cc: javier.carrasco.cruz, Shuah Khan, linux-kselftest, brauner,
	linux-kernel

On 8/16/24 07:11, Shuah Khan wrote:
> On 8/10/24 07:53, Abhinav Jain wrote:
>> Add return value checks for read & write calls in test_listmount_ns
>> function. This patch resolves below compilation warnings:
>>
>> ```
>> statmount_test_ns.c: In function ‘test_listmount_ns’:
>>
>> statmount_test_ns.c:322:17: warning: ignoring return value of ‘write’
>> declared with attribute ‘warn_unused_result’ [-Wunused-result]
>>
>> statmount_test_ns.c:323:17: warning: ignoring return value of ‘read’
>> declared with attribute ‘warn_unused_result’ [-Wunused-result]
>> ```
>>
>> Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
>> ---

> Hi Christian,
> 
> Let me know if it is okay to take this patch through kselftest tree.
> The change looks good to me.
> 
> thanks,
> -- Shuah

Thank you for the patch.

Applied to linux-kselftest next for Linux 6.12-rc1

thanks,
-- Shuah

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

end of thread, other threads:[~2024-09-03 17:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-10 13:53 [PATCH] selftests: filesystems: fix warn_unused_result build warnings Abhinav Jain
2024-08-16 13:11 ` Shuah Khan
2024-09-03 17:45   ` Shuah Khan
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 18:49 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