Message ID | 20221105102552.80052-1-tegongkang@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp918251wru; Sat, 5 Nov 2022 03:35:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Gj3I1sLYa/KL97kItyic6eMXdlyeKCl+M65f+jTDU004sqhbkVcpJOj64X1gigCH9zO24 X-Received: by 2002:a62:51c3:0:b0:56b:a0e2:3c51 with SMTP id f186-20020a6251c3000000b0056ba0e23c51mr40275428pfb.68.1667644525600; Sat, 05 Nov 2022 03:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667644525; cv=none; d=google.com; s=arc-20160816; b=fqcMZPTA/LseY/3/RPRLVPKDJiVeL4mX6xmsIx8xkXRtwW/gfMXiBPSW8YeWphRPGX YYQgqFVbdYsSN3lGMOfWr2ukZYaEuGTA5P8WLjlNFmAX+YvQ+L2s5msHYfdzpK1pnsep PbJaUqE4DcTj8ef5wLUU1LH2NrfRooBgiXYS7SpunknegG3M3Kbogqn5oMyX/w18VP6d xYshQraIMJ7/SIJw8XrCcJBlhQD+YBVK8WLjWYnvpsq4+b0pujc4YGd998h+hIa3B9Y9 q3gMkjDewUwk69d2Yn1dpJ1ruAtoAjG/DHDNxDnHhXwqoF2FJKexmuzZXWJXP7m+W+jm ykwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=U3pVfup+yG64ldWhowKF8wBUHo0xoRLBn7/G0ZGa/OA=; b=f7i6WtNf7rXh5yhBZwizkSsKsMG4V6LEdjOgfyuOsbyKxDvuSaH0lC0VZzqqfet7xK +USYbwRw7s8v7Z/1RouQGnOMT/Qhv2sgLePk4rdUiHLFjdfVcHwhmoN787GSWnHRo5vA WzEemkkUwoaGOzvOMZsbPK6f57vwJT8xx1ZrIYey9CY09erfgmh7S5kOnhzkrZmkOl2V QJYObn3/UjFNJ1z2ZO1NHGPJB1IiFD7/+7rNTYX05/Xs3S1E3XvNf3uIdP5Z28XC6PCD 5VDqjFXRI8O+IT5yFUYhPCf4fgvymLAGIP9fofNErnjLyYxkiJ7WZdAUDU4QlB0o/lYA Z2HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=byP6G7+7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a17090aaa0c00b00213d512f07csi2356384pjq.182.2022.11.05.03.35.10; Sat, 05 Nov 2022 03:35:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=byP6G7+7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbiKEK0B (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Sat, 5 Nov 2022 06:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiKEKZ7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 5 Nov 2022 06:25:59 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1D627B14; Sat, 5 Nov 2022 03:25:59 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id g129so6390197pgc.7; Sat, 05 Nov 2022 03:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U3pVfup+yG64ldWhowKF8wBUHo0xoRLBn7/G0ZGa/OA=; b=byP6G7+7l+Wu9gkA3FhuYw5u0UHiR2gM2clNBcYriPSMRMXr/yDbo49D7cyLHUBA3O HfKSu9FbbMvQoJqr8MkftsK089jHpsy5HMdIqY0v4LMjcvsew8izcLGFlIDD2jf4KIrQ WiYTRuc8fJetOom9oTA3hvBsZcIBprbOdsDICiqjnQ4ES4X8XYjiV7bM4rwIc1Y4h8pN 7JV2Qa3eB8q0ULTSa4RSTLv8WYoTN8jNixAIB0eK53KW5c4HB4PHkILrAs7fn8Th6bSe 3spZMxwPDso0ZEKrH7qttZ4+8w9eXBXogo/YiTV3Z3lZ5KgEZUtiu2H4R5EevmgyNdTD 1yXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U3pVfup+yG64ldWhowKF8wBUHo0xoRLBn7/G0ZGa/OA=; b=NLeHRSdszvXAiBeco8l71emMecpN6xEHKKWZCw3evkTuCDEwyMLSlh9dnlNMy4dbOx J10xNTPqbzjIl+KIkmN/c4b6XLAbH1ol5N4FtHzWFXtb1ISAejoYtydPQDUYuQmpO5gi G3TgyVG3NZY+DZg8UPtaBJl2Ucwu2s4QAqlU82LFeL2lT7uyAXJXbuuvTBYO3YYi2tSa bAA30Z8RlfTOphW5mkrVeYoo3GwKSLVdRUivb1Xv8deStE7Jb/2elTpNXm+d9a1sAF1V 8csetj+83PJeo/VN4sbvxLs7PJSrSoDnpdCEZngC4JtCcKU1/OulMYX0qX4m9t/eRYK5 phhQ== X-Gm-Message-State: ACrzQf0pQFoeWsZrNOvw+8Sf+QbkImIw+OpImaSSynIczYRoTEDW2xPU 9+QBt4b8W7ObHqRWvWJ7bnU= X-Received: by 2002:a65:5241:0:b0:46e:f67c:c108 with SMTP id q1-20020a655241000000b0046ef67cc108mr33506139pgp.362.1667643958451; Sat, 05 Nov 2022 03:25:58 -0700 (PDT) Received: from uftrace.. ([14.5.161.231]) by smtp.gmail.com with ESMTPSA id w14-20020aa79a0e000000b0056beae3dee2sm1050109pfj.145.2022.11.05.03.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 03:25:58 -0700 (PDT) From: Kang Minchul <tegongkang@gmail.com> To: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@kernel.org>, Magnus Karlsson <magnus.karlsson@intel.com>, Maciej Fijalkowski <maciej.fijalkowski@intel.com>, Jonathan Lemon <jonathan.lemon@gmail.com> Cc: Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kang Minchul <tegongkang@gmail.com> Subject: [PATCH v2] selftests/bpf: Fix unsigned expression compared with zero Date: Sat, 5 Nov 2022 19:25:52 +0900 Message-Id: <20221105102552.80052-1-tegongkang@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748651294046312456?= X-GMAIL-MSGID: =?utf-8?q?1748652026202658329?= |
Series |
[v2] selftests/bpf: Fix unsigned expression compared with zero
|
|
Commit Message
Kang Minchul
Nov. 5, 2022, 10:25 a.m. UTC
Variable ret is compared with 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
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 <tegongkang@gmail.com> > --- > 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) {
2022년 11월 6일 (일) 오전 1:16, Randy Dunlap <rdunlap@infradead.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. > ~Randy Thanks for your kind feedback! I guess I have to change the message more precisely. I'll send the amended patch (PATCH v3) as you mentioned. Regards, Kang Minchul
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) {