From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57C11C4332F for ; Sat, 5 Nov 2022 16:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbiKEQQr (ORCPT ); Sat, 5 Nov 2022 12:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiKEQQp (ORCPT ); Sat, 5 Nov 2022 12:16:45 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ADA713D4E; Sat, 5 Nov 2022 09:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=hMlRvmOztseL8Ey9AQ1Tl95aMzXuJGidMzIyJVt4wQA=; b=kS9KqMtlGyn4E07pJekbylaDY7 IZSzpqI+ZtrvOtf46C0bfg/SW1A0KK2W7OhydzSADx5uwxf99rd+Yk+Md06SWn4aDil1o8tS1W/4x 2A5PHBczERCRSSYLt2e091A26eF5TJQ0oNLyUHVLOHX+xZBa1u24uH1KhfVMJiL0Jx2KOtfRpuJYk Yvr++K+vjv5ep4XwSDDI5Ddk41Oy/s8mJ6avT89luwNwG/+Q6YM/Mt5rXlZnj5kHza8n3VcMb//5v 4/upmGhgfhaZvZokjY5olgoUQdTqK9Us5JbL8XlYFjqQtqFhG84gs80DCuu43HWJ95WUOPZGPTWYZ Ya/dCSpg==; Received: from [2601:1c2:d80:3110::a2e7] by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1orLqS-006set-5F; Sat, 05 Nov 2022 16:16:32 +0000 Message-ID: Date: Sat, 5 Nov 2022 09:16:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v2] selftests/bpf: Fix unsigned expression compared with zero Content-Language: en-US To: Kang Minchul , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon Cc: Martin KaFai Lau , Song Liu , Yonghong Song , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221105102552.80052-1-tegongkang@gmail.com> From: Randy Dunlap In-Reply-To: <20221105102552.80052-1-tegongkang@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi-- On 11/5/22 03:25, Kang Minchul wrote: > Variable ret is compared with zero even though it was set as u32. It's OK to compare a u32 == to zero, but 'ret' is compared to < 0, which it cannot be. Better explanation here would be good. Thanks. > So u32 to int conversion is needed. > > Signed-off-by: Kang Minchul > --- > 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) { -- ~Randy