Skip to contentSkip to conversation

selftests/bpf: Fix unsigned expression compared with zero

PATCH Superseded Kang Minchul 1 participant 2 messages Nov 5, 2022

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Fix unsigned expression compared with zero

Variable ret is compared with zero even though it have 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
#1 lore raw

2022년 11월 5일 (토) 오후 7:18, Kang Minchul <[email protected]>님이 작성:

Quoted 24 lines

Variable ret is compared with zero even though it have 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 -2
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) {
--
Quoted 2 lines

2.34.1

I just found a grammatical error in the commit message. I'll resend this with the correct message. Sorry for the inconvenience.

Regards,

Kang Minchul