Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: net: csum: Fix printk format in recv_get_packet_csum_status()

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.

The code in question was introduced by
commit 91a7de85600d ("selftests/net: add csum offload test").

Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/8b69b40826553c1dd500d9d25e45883744f3f348.1768556791.git.chleroy@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christophe Leroy (CS GROUP) and committed by
Jakub Kicinski
d321d505 2f52f835

+1 -1
+1 -1
tools/testing/selftests/net/lib/csum.c
··· 707 707 cm->cmsg_level, cm->cmsg_type); 708 708 709 709 if (cm->cmsg_len != CMSG_LEN(sizeof(struct tpacket_auxdata))) 710 - error(1, 0, "cmsg: len=%lu expected=%lu", 710 + error(1, 0, "cmsg: len=%zu expected=%zu", 711 711 cm->cmsg_len, CMSG_LEN(sizeof(struct tpacket_auxdata))); 712 712 713 713 aux = (void *)CMSG_DATA(cm);