Skip to contentSkip to conversation

selftests/bpf: Fix u32 variable compared with less than zero

PATCH Applied Kang Minchul 4 participants 4 messages Nov 5, 2022 – Nov 8, 2022

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 selftests/bpf: Fix u32 variable compared with less than zero

Variable ret is compared with less than zero even though it was set as u32. So u32 to int conversion is needed.

---
 tools/testing/selftests/bpf/xskxceiver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/xskxceiver.c +2 -1
index 681a5db80dae..162d3a516f2c 100644
@@ -1006,7 +1006,8 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd
 {
 	struct xsk_socket_info *xsk = ifobject->xsk;
 	bool use_poll = ifobject->use_poll;
-	u32 i, idx = 0, ret, valid_pkts = 0;
+	u32 i, idx = 0, valid_pkts = 0;
+	int ret;
 
 	while (xsk_ring_prod__reserve(&xsk->tx, BATCH_SIZE, &idx) < BATCH_SIZE) {
 		if (use_poll) {
Signature · 1 line
2.34.1
Acked-by on v3 1/1
#1 lore raw
Quoted 4 lines · Kang Minchul

Variable ret is compared with less than zero even though it was set as u32. So u32 to int conversion is needed.

Thanks.

Quoted 18 lines
---
  tools/testing/selftests/bpf/xskxceiver.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/xskxceiver.c +2 -1
index 681a5db80dae..162d3a516f2c 100644
@@ -1006,7 +1006,8 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd
  {
  	struct xsk_socket_info *xsk = ifobject->xsk;
  	bool use_poll = ifobject->use_poll;
-	u32 i, idx = 0, ret, valid_pkts = 0;
+	u32 i, idx = 0, valid_pkts = 0;
+	int ret;
 
  	while (xsk_ring_prod__reserve(&xsk->tx, BATCH_SIZE, &idx) < BATCH_SIZE) {
  		if (use_poll) {
#3 lore raw
In reply to Kang Minchul
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 7 lines · On Sun, 6 Nov 2022 03:36:56 +0900 you wrote:

Variable ret is compared with less than zero even though it was set as u32. So u32 to int conversion is needed.

---
 tools/testing/selftests/bpf/xskxceiver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Here is the summary with links:
- [v3] selftests/bpf: Fix u32 variable compared with less than zero

    https://git.kernel.org/bpf/bpf-next/c/e8f50c4f0c14

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html