[PATCH] selftests: kselftest: Use strerror() on nolibc

zhangjiao2 posted 1 patch 2 months, 2 weeks ago
tools/testing/selftests/kselftest.h | 8 --------
1 file changed, 8 deletions(-)
[PATCH] selftests: kselftest: Use strerror() on nolibc
Posted by zhangjiao2 2 months, 2 weeks ago
From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

Nolibc gained an implementation of strerror() recently.
Use it and drop the ifndef.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 tools/testing/selftests/kselftest.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index e195ec156859..29fedf609611 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -373,15 +373,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_fail_msg(const char *msg,
 
 static inline __noreturn void ksft_exit_fail_perror(const char *msg)
 {
-#ifndef NOLIBC
 	ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
-#else
-	/*
-	 * nolibc doesn't provide strerror() and it seems
-	 * inappropriate to add one, just print the errno.
-	 */
-	ksft_exit_fail_msg("%s: %d)\n", msg, errno);
-#endif
 }
 
 static inline __noreturn void ksft_exit_xfail(void)
-- 
2.33.0
Re: [PATCH] selftests: kselftest: Use strerror() on nolibc
Posted by Shuah Khan 2 months, 2 weeks ago
On 9/10/24 22:42, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> 
> Nolibc gained an implementation of strerror() recently.
> Use it and drop the ifndef.
> 
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> ---
>   tools/testing/selftests/kselftest.h | 8 --------
>   1 file changed, 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> index e195ec156859..29fedf609611 100644
> --- a/tools/testing/selftests/kselftest.h
> +++ b/tools/testing/selftests/kselftest.h
> @@ -373,15 +373,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_fail_msg(const char *msg,
>   
>   static inline __noreturn void ksft_exit_fail_perror(const char *msg)
>   {
> -#ifndef NOLIBC
>   	ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
> -#else
> -	/*
> -	 * nolibc doesn't provide strerror() and it seems
> -	 * inappropriate to add one, just print the errno.
> -	 */
> -	ksft_exit_fail_msg("%s: %d)\n", msg, errno);
> -#endif
>   }
>   
>   static inline __noreturn void ksft_exit_xfail(void)

Adding nolibc maintainers for review.

Willy and Thomas, please review.

thanks,
-- Shuah
Re: [PATCH] selftests: kselftest: Use strerror() on nolibc
Posted by Thomas Weißschuh 2 months, 2 weeks ago
Hi Shuah,

On 2024-09-11 09:36:50+0000, Shuah Khan wrote:
> On 9/10/24 22:42, zhangjiao2 wrote:
> > From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> > 
> > Nolibc gained an implementation of strerror() recently.
> > Use it and drop the ifndef.
> > 
> > Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> > ---
> >   tools/testing/selftests/kselftest.h | 8 --------
> >   1 file changed, 8 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> > index e195ec156859..29fedf609611 100644
> > --- a/tools/testing/selftests/kselftest.h
> > +++ b/tools/testing/selftests/kselftest.h
> > @@ -373,15 +373,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_fail_msg(const char *msg,
> >   static inline __noreturn void ksft_exit_fail_perror(const char *msg)
> >   {
> > -#ifndef NOLIBC
> >   	ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
> > -#else
> > -	/*
> > -	 * nolibc doesn't provide strerror() and it seems
> > -	 * inappropriate to add one, just print the errno.
> > -	 */
> > -	ksft_exit_fail_msg("%s: %d)\n", msg, errno);
> > -#endif
> >   }
> >   static inline __noreturn void ksft_exit_xfail(void)
> 
> Adding nolibc maintainers for review.
> 
> Willy and Thomas, please review.

Acked-by: Thomas Weißschuh <linux@weissschuh.net>

I did the same for another kselftests function when introducing
strerror(). This one was apparently missed or didn't exist yet.


Thomas
Re: [PATCH] selftests: kselftest: Use strerror() on nolibc
Posted by Shuah Khan 2 months, 2 weeks ago
On 9/11/24 09:44, Thomas Weißschuh wrote:
> Hi Shuah,
> 
> On 2024-09-11 09:36:50+0000, Shuah Khan wrote:
>> On 9/10/24 22:42, zhangjiao2 wrote:
>>> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>>>
>>> Nolibc gained an implementation of strerror() recently.
>>> Use it and drop the ifndef.
>>>
>>> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>>> ---
>>>    tools/testing/selftests/kselftest.h | 8 --------
>>>    1 file changed, 8 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
>>> index e195ec156859..29fedf609611 100644
>>> --- a/tools/testing/selftests/kselftest.h
>>> +++ b/tools/testing/selftests/kselftest.h
>>> @@ -373,15 +373,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_fail_msg(const char *msg,
>>>    static inline __noreturn void ksft_exit_fail_perror(const char *msg)
>>>    {
>>> -#ifndef NOLIBC
>>>    	ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
>>> -#else
>>> -	/*
>>> -	 * nolibc doesn't provide strerror() and it seems
>>> -	 * inappropriate to add one, just print the errno.
>>> -	 */
>>> -	ksft_exit_fail_msg("%s: %d)\n", msg, errno);
>>> -#endif
>>>    }
>>>    static inline __noreturn void ksft_exit_xfail(void)
>>
>> Adding nolibc maintainers for review.
>>
>> Willy and Thomas, please review.
> 
> Acked-by: Thomas Weißschuh <linux@weissschuh.net>
> 
> I did the same for another kselftests function when introducing
> strerror(). This one was apparently missed or didn't exist yet.
> 
> 


Thank you. Applied to linux-kselftest next for Linux 6.12-rc1.

thanks,
-- Shuah