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

Message ID 20221105183656.86077-1-tegongkang@gmail.com
State New
Headers
Series [v3] selftests/bpf: Fix u32 variable compared with less than zero |

Commit Message

Kang Minchul Nov. 5, 2022, 6:36 p.m. UTC
  Variable ret is compared with less than zero even though it was set as u32.
So u32 to int conversion is needed.

Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
 tools/testing/selftests/bpf/xskxceiver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Randy Dunlap Nov. 5, 2022, 6:45 p.m. UTC | #1
On 11/5/22 11:36, Kang Minchul wrote:
> Variable ret is compared with less than zero even though it was set as u32.
> So u32 to int conversion is needed.
> 
> Signed-off-by: Kang Minchul <tegongkang@gmail.com>

Acked-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
>   tools/testing/selftests/bpf/xskxceiver.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index 681a5db80dae..162d3a516f2c 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c
> @@ -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) {
  
Björn Töpel Nov. 6, 2022, 12:21 p.m. UTC | #2
Kang Minchul <tegongkang@gmail.com> writes:

> Variable ret is compared with less than zero even though it was set as u32.
> So u32 to int conversion is needed.
>
> Signed-off-by: Kang Minchul <tegongkang@gmail.com>

Acked-by: Björn Töpel <bjorn@kernel.org>
  
patchwork-bot+netdevbpf@kernel.org Nov. 8, 2022, 1 a.m. UTC | #3
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

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.
> 
> Signed-off-by: Kang Minchul <tegongkang@gmail.com>
> ---
>  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!
  

Patch

diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index 681a5db80dae..162d3a516f2c 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -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) {