2024-05-21 03:03:40

by Michael Ellerman

[permalink] [raw]
Subject: [PATCH] selftests/openat2: Fix build warnings on ppc64

Fix warnings like:

openat2_test.c: In function ‘test_openat2_flags’:
openat2_test.c:303:73: warning: format ‘%llX’ expects argument of type
‘long long unsigned int’, but argument 5 has type ‘__u64’ {aka ‘long
unsigned int’} [-Wformat=]

By switching to unsigned long long for u64 for ppc64 builds.

Signed-off-by: Michael Ellerman <[email protected]>
---
tools/testing/selftests/openat2/openat2_test.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
index 9024754530b2..5790ab446527 100644
--- a/tools/testing/selftests/openat2/openat2_test.c
+++ b/tools/testing/selftests/openat2/openat2_test.c
@@ -5,6 +5,7 @@
*/

#define _GNU_SOURCE
+#define __SANE_USERSPACE_TYPES__ // Use ll64
#include <fcntl.h>
#include <sched.h>
#include <sys/stat.h>
--
2.45.1



2024-05-25 04:32:56

by Muhammad Usama Anjum

[permalink] [raw]
Subject: Re: [PATCH] selftests/openat2: Fix build warnings on ppc64

I was looking at if we can add this flag for ppc64 for all selftests
somewhere. But there isn't any suitable place other than in KHDR_INCLUDES.
But there is a series already trying to add _GNU_SOURCE to it. Once that
gets accepted, we may add this flag there by removing the definitions from
individual files. But until then the current solution seems fine:

Reviewed-by: Muhammad Usama Anjum <[email protected]>

On 5/20/24 8:03 PM, Michael Ellerman wrote:
> Fix warnings like:
>
> openat2_test.c: In function ‘test_openat2_flags’:
> openat2_test.c:303:73: warning: format ‘%llX’ expects argument of type
> ‘long long unsigned int’, but argument 5 has type ‘__u64’ {aka ‘long
> unsigned int’} [-Wformat=]
>
> By switching to unsigned long long for u64 for ppc64 builds.
>
> Signed-off-by: Michael Ellerman <[email protected]>
> ---
> tools/testing/selftests/openat2/openat2_test.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
> index 9024754530b2..5790ab446527 100644
> --- a/tools/testing/selftests/openat2/openat2_test.c
> +++ b/tools/testing/selftests/openat2/openat2_test.c
> @@ -5,6 +5,7 @@
> */
>
> #define _GNU_SOURCE
> +#define __SANE_USERSPACE_TYPES__ // Use ll64
> #include <fcntl.h>
> #include <sched.h>
> #include <sys/stat.h>

--
BR,
Muhammad Usama Anjum

2024-05-29 08:56:29

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH] selftests/openat2: Fix build warnings on ppc64

Muhammad Usama Anjum <[email protected]> writes:
> I was looking at if we can add this flag for ppc64 for all selftests
> somewhere. But there isn't any suitable place other than in KHDR_INCLUDES.
> But there is a series already trying to add _GNU_SOURCE to it.

IMHO adding other flags to KHDR_INCLUDES is not the right solution, it
conflates unrelated things. Some tests may want the kernel headers but
not _GNU_SOURCE, or vice versa.

Adding a separate define for "standard kselftest flags" would be
preferable, and then something like __SANE_USERSPACE_TYPES__ would make
sense being added to it.

> Reviewed-by: Muhammad Usama Anjum <[email protected]>

Thanks.

cheers

> On 5/20/24 8:03 PM, Michael Ellerman wrote:
>> Fix warnings like:
>>
>> openat2_test.c: In function ‘test_openat2_flags’:
>> openat2_test.c:303:73: warning: format ‘%llX’ expects argument of type
>> ‘long long unsigned int’, but argument 5 has type ‘__u64’ {aka ‘long
>> unsigned int’} [-Wformat=]
>>
>> By switching to unsigned long long for u64 for ppc64 builds.
>>
>> Signed-off-by: Michael Ellerman <[email protected]>
>> ---
>> tools/testing/selftests/openat2/openat2_test.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
>> index 9024754530b2..5790ab446527 100644
>> --- a/tools/testing/selftests/openat2/openat2_test.c
>> +++ b/tools/testing/selftests/openat2/openat2_test.c
>> @@ -5,6 +5,7 @@
>> */
>>
>> #define _GNU_SOURCE
>> +#define __SANE_USERSPACE_TYPES__ // Use ll64
>> #include <fcntl.h>
>> #include <sched.h>
>> #include <sys/stat.h>
>
> --
> BR,
> Muhammad Usama Anjum

2024-05-29 22:20:31

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] selftests/openat2: Fix build warnings on ppc64

On 5/20/24 21:03, Michael Ellerman wrote:
> Fix warnings like:
>
> openat2_test.c: In function ‘test_openat2_flags’:
> openat2_test.c:303:73: warning: format ‘%llX’ expects argument of type
> ‘long long unsigned int’, but argument 5 has type ‘__u64’ {aka ‘long
> unsigned int’} [-Wformat=]
>
> By switching to unsigned long long for u64 for ppc64 builds.
>
> Signed-off-by: Michael Ellerman <[email protected]>
> ---
> tools/testing/selftests/openat2/openat2_test.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
> index 9024754530b2..5790ab446527 100644
> --- a/tools/testing/selftests/openat2/openat2_test.c
> +++ b/tools/testing/selftests/openat2/openat2_test.c
> @@ -5,6 +5,7 @@
> */
>
> #define _GNU_SOURCE
> +#define __SANE_USERSPACE_TYPES__ // Use ll64
> #include <fcntl.h>
> #include <sched.h>
> #include <sys/stat.h>

Applied to linux-kselftest fixes for the next rc.

Michael, If you want to take this through, let me know, I can drop this.

thanks,
-- Shuah