Skip to content

Commit fe69a1b

Browse files
roxellAlexei Starovoitov
authored andcommitted
selftests: bpf: xskxceiver: ksft_print_msg: fix format type error
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> Link: https://lore.kernel.org/r/20231109174328.1774571-1-anders.roxell@linaro.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 89cdf9d commit fe69a1b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tools/testing/selftests/bpf/xskxceiver.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,9 @@ static bool is_metadata_correct(struct pkt *pkt, void *buffer, u64 addr)
908908
struct xdp_info *meta = data - sizeof(struct xdp_info);
909909

910910
if (meta->count != pkt->pkt_nb) {
911-
ksft_print_msg("[%s] expected meta_count [%d], got meta_count [%d]\n",
912-
__func__, pkt->pkt_nb, meta->count);
911+
ksft_print_msg("[%s] expected meta_count [%d], got meta_count [%llu]\n",
912+
__func__, pkt->pkt_nb,
913+
(unsigned long long)meta->count);
913914
return false;
914915
}
915916

@@ -926,11 +927,13 @@ static bool is_frag_valid(struct xsk_umem_info *umem, u64 addr, u32 len, u32 exp
926927

927928
if (addr >= umem->num_frames * umem->frame_size ||
928929
addr + len > umem->num_frames * umem->frame_size) {
929-
ksft_print_msg("Frag invalid addr: %llx len: %u\n", addr, len);
930+
ksft_print_msg("Frag invalid addr: %llx len: %u\n",
931+
(unsigned long long)addr, len);
930932
return false;
931933
}
932934
if (!umem->unaligned_mode && addr % umem->frame_size + len > umem->frame_size) {
933-
ksft_print_msg("Frag crosses frame boundary addr: %llx len: %u\n", addr, len);
935+
ksft_print_msg("Frag crosses frame boundary addr: %llx len: %u\n",
936+
(unsigned long long)addr, len);
934937
return false;
935938
}
936939

@@ -1029,7 +1032,8 @@ static int complete_pkts(struct xsk_socket_info *xsk, int batch_size)
10291032
u64 addr = *xsk_ring_cons__comp_addr(&xsk->umem->cq, idx + rcvd - 1);
10301033

10311034
ksft_print_msg("[%s] Too many packets completed\n", __func__);
1032-
ksft_print_msg("Last completion address: %llx\n", addr);
1035+
ksft_print_msg("Last completion address: %llx\n",
1036+
(unsigned long long)addr);
10331037
return TEST_FAILURE;
10341038
}
10351039

@@ -1513,8 +1517,9 @@ static int validate_tx_invalid_descs(struct ifobject *ifobject)
15131517
}
15141518

15151519
if (stats.tx_invalid_descs != ifobject->xsk->pkt_stream->nb_pkts / 2) {
1516-
ksft_print_msg("[%s] tx_invalid_descs incorrect. Got [%u] expected [%u]\n",
1517-
__func__, stats.tx_invalid_descs,
1520+
ksft_print_msg("[%s] tx_invalid_descs incorrect. Got [%llu] expected [%u]\n",
1521+
__func__,
1522+
(unsigned long long)stats.tx_invalid_descs,
15181523
ifobject->xsk->pkt_stream->nb_pkts);
15191524
return TEST_FAILURE;
15201525
}

0 commit comments

Comments
 (0)