* [PATCHv3] selftests: bpf: xskxceiver: ksft_print_msg: fix format type error
@ 2023-11-09 17:43 Anders Roxell
2023-11-10 3:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 3+ messages in thread
From: Anders Roxell @ 2023-11-09 17:43 UTC (permalink / raw)
To: bjorn, magnus.karlsson, maciej.fijalkowski, andrii.nakryiko
Cc: netdev, bpf, linux-kernel, Anders Roxell
Crossbuilding selftests/bpf for architecture arm64, format specifies
type error show up like.
xskxceiver.c:912:34: error: format specifies type 'int' but the argument
has type '__u64' (aka 'unsigned long long') [-Werror,-Wformat]
ksft_print_msg("[%s] expected meta_count [%d], got meta_count [%d]\n",
~~
%llu
__func__, pkt->pkt_nb, meta->count);
^~~~~~~~~~~
xskxceiver.c:929:55: error: format specifies type 'unsigned long long' but
the argument has type 'u64' (aka 'unsigned long') [-Werror,-Wformat]
ksft_print_msg("Frag invalid addr: %llx len: %u\n", addr, len);
~~~~ ^~~~
Fixing the issues by casting to (unsigned long long) and changing the
specifiers to be %llu from %d and %u, since with u64s it might be %llx
or %lx, depending on architecture.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
tools/testing/selftests/bpf/xskxceiver.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index 591ca9637b23..b604c570309a 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -908,8 +908,9 @@ static bool is_metadata_correct(struct pkt *pkt, void *buffer, u64 addr)
struct xdp_info *meta = data - sizeof(struct xdp_info);
if (meta->count != pkt->pkt_nb) {
- ksft_print_msg("[%s] expected meta_count [%d], got meta_count [%d]\n",
- __func__, pkt->pkt_nb, meta->count);
+ ksft_print_msg("[%s] expected meta_count [%d], got meta_count [%llu]\n",
+ __func__, pkt->pkt_nb,
+ (unsigned long long)meta->count);
return false;
}
@@ -926,11 +927,13 @@ static bool is_frag_valid(struct xsk_umem_info *umem, u64 addr, u32 len, u32 exp
if (addr >= umem->num_frames * umem->frame_size ||
addr + len > umem->num_frames * umem->frame_size) {
- ksft_print_msg("Frag invalid addr: %llx len: %u\n", addr, len);
+ ksft_print_msg("Frag invalid addr: %llx len: %u\n",
+ (unsigned long long)addr, len);
return false;
}
if (!umem->unaligned_mode && addr % umem->frame_size + len > umem->frame_size) {
- ksft_print_msg("Frag crosses frame boundary addr: %llx len: %u\n", addr, len);
+ ksft_print_msg("Frag crosses frame boundary addr: %llx len: %u\n",
+ (unsigned long long)addr, len);
return false;
}
@@ -1029,7 +1032,8 @@ static int complete_pkts(struct xsk_socket_info *xsk, int batch_size)
u64 addr = *xsk_ring_cons__comp_addr(&xsk->umem->cq, idx + rcvd - 1);
ksft_print_msg("[%s] Too many packets completed\n", __func__);
- ksft_print_msg("Last completion address: %llx\n", addr);
+ ksft_print_msg("Last completion address: %llx\n",
+ (unsigned long long)addr);
return TEST_FAILURE;
}
@@ -1513,8 +1517,9 @@ static int validate_tx_invalid_descs(struct ifobject *ifobject)
}
if (stats.tx_invalid_descs != ifobject->xsk->pkt_stream->nb_pkts / 2) {
- ksft_print_msg("[%s] tx_invalid_descs incorrect. Got [%u] expected [%u]\n",
- __func__, stats.tx_invalid_descs,
+ ksft_print_msg("[%s] tx_invalid_descs incorrect. Got [%llu] expected [%u]\n",
+ __func__,
+ (unsigned long long)stats.tx_invalid_descs,
ifobject->xsk->pkt_stream->nb_pkts);
return TEST_FAILURE;
}
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCHv3] selftests: bpf: xskxceiver: ksft_print_msg: fix format type error
2023-11-09 17:43 [PATCHv3] selftests: bpf: xskxceiver: ksft_print_msg: fix format type error Anders Roxell
@ 2023-11-10 3:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-10 3:30 UTC (permalink / raw)
To: Anders Roxell
Cc: bjorn, magnus.karlsson, maciej.fijalkowski, andrii.nakryiko,
netdev, bpf, linux-kernel
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Thu, 9 Nov 2023 18:43:28 +0100 you wrote:
> Crossbuilding selftests/bpf for architecture arm64, format specifies
> type error show up like.
>
> xskxceiver.c:912:34: error: format specifies type 'int' but the argument
> has type '__u64' (aka 'unsigned long long') [-Werror,-Wformat]
> ksft_print_msg("[%s] expected meta_count [%d], got meta_count [%d]\n",
> ~~
> %llu
> __func__, pkt->pkt_nb, meta->count);
> ^~~~~~~~~~~
> xskxceiver.c:929:55: error: format specifies type 'unsigned long long' but
> the argument has type 'u64' (aka 'unsigned long') [-Werror,-Wformat]
> ksft_print_msg("Frag invalid addr: %llx len: %u\n", addr, len);
> ~~~~ ^~~~
>
> [...]
Here is the summary with links:
- [PATCHv3] selftests: bpf: xskxceiver: ksft_print_msg: fix format type error
https://git.kernel.org/bpf/bpf/c/fe69a1b1b6ed
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHv3] selftests: bpf: xskxceiver: ksft_print_msg: fix format type error
[not found] <<20231109174328.1774571-1-anders.roxell@linaro.org>
@ 2023-11-21 20:50 ` Daniel Xu
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Xu @ 2023-11-21 20:50 UTC (permalink / raw)
To: anders.roxell
Cc: Andrii Nakryiko, bjorn, bpf@vger.kernel.org, linux-kernel,
maciej.fijalkowski, magnus.karlsson, netdev
Hi,
I'm hitting the same error on bpf-next/master for native x86-64 build:
3cbbf9192abd ("Merge branch 'selftests-bpf-update-multiple-prog_tests-to-use-assert_-macros'"
Applying this patch helped.
Does this need to go onto bpf-next as well?
Thanks,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-21 20:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-09 17:43 [PATCHv3] selftests: bpf: xskxceiver: ksft_print_msg: fix format type error Anders Roxell
2023-11-10 3:30 ` patchwork-bot+netdevbpf
[not found] <<20231109174328.1774571-1-anders.roxell@linaro.org>
2023-11-21 20:50 ` Daniel Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).