Hi Christophe

On 16/01/2026 10:48, Christophe Leroy (CS GROUP) wrote:
> Following warning is encountered when building selftests on powerpc/32.
> 
>   CC       csum
> csum.c: In function 'recv_get_packet_csum_status':
> csum.c:710:50: warning: format '%lu' expects argument of type 'long unsigned 
> int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
>   710 |                         error(1, 0, "cmsg: len=%lu expected=%lu",
>       |                                                ~~^
>       |                                                  |
>       |                                                  long unsigned int
>       |                                                %u
>   711 |                               cm->cmsg_len, CMSG_LEN(sizeof(struct 
> tpacket_auxdata)));
>       |                               ~~~~~~~~~~~~
>       |                                 |
>       |                                 size_t {aka unsigned int}
> csum.c:710:63: warning: format '%lu' expects argument of type 'long unsigned 
> int', but argument 5 has type 'unsigned int' [-Wformat=]
>   710 |                         error(1, 0, "cmsg: len=%lu expected=%lu",
>       |                                                             ~~^
>       |                                                               |
>       |                                                               long 
> unsigned int
>       |                                                             %u
> 
> cm->cmsg_len has type __kernel_size_t and CMSG() macro has the type
> returned by sizeof() which is size_t.
> 
> size_t is 'unsigned int' on some platforms and 'unsigned long' on
> other ones so use %zu instead of %lu.
> 
> This fixes commit 91a7de85600d ("selftests/net: add csum offload test").
> 
> Signed-off-by: Christophe Leroy (CS GROUP) <[email protected]>

Reviewed-by: Maxime Chevallier <[email protected]>

Maxime

> ---
> v2: Removed use %zu instead of %u and removed Fixes tag
> ---
>  tools/testing/selftests/net/lib/csum.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/lib/csum.c 
> b/tools/testing/selftests/net/lib/csum.c
> index 27437590eeb53..e28884ce3ab39 100644
> --- a/tools/testing/selftests/net/lib/csum.c
> +++ b/tools/testing/selftests/net/lib/csum.c
> @@ -707,7 +707,7 @@ static uint32_t recv_get_packet_csum_status(struct msghdr 
> *msg)
>                             cm->cmsg_level, cm->cmsg_type);
>  
>               if (cm->cmsg_len != CMSG_LEN(sizeof(struct tpacket_auxdata)))
> -                     error(1, 0, "cmsg: len=%lu expected=%lu",
> +                     error(1, 0, "cmsg: len=%zu expected=%zu",
>                             cm->cmsg_len, CMSG_LEN(sizeof(struct 
> tpacket_auxdata)));
>  
>               aux = (void *)CMSG_DATA(cm);


Reply via email to