Message ID | 20221102082503.32236-1-korantwork@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 l7csp3487009wru; Wed, 2 Nov 2022 01:34:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4WBG7vQ4ft/9i9W4RK5PtlWKfH6xOsaRfPCLsNv8cfl/FBsbMz8S+DPOV1E7RtDCSMNUet X-Received: by 2002:a05:6402:42d0:b0:457:d16e:283d with SMTP id i16-20020a05640242d000b00457d16e283dmr23019267edc.395.1667378054524; Wed, 02 Nov 2022 01:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667378054; cv=none; d=google.com; s=arc-20160816; b=F5izLT+cdGgKFnl7h2/xS3ysThv+Uysnn2P8JCa5rkah1SikCgjn/BMu/JywFAGelb J1BRAJQujOuaIBhJ3OAZcvWXtILNFeWbzoRPmCzxpSU/cW2d6jFGaktcLV70v4YXfb6j m10VIKcwDIOSTG8pqP8EOI7t8NU/ELQvcnG0cYt4Ee0rkNd2LHgupPthKugjqr4WI1iS m3/ROfdxy+XGsE06Hkg9gLAW5eyugXtAL5y9x4s9OTduSawGjj65OPrYpDW41CzjrKoD VtdMXPh1FaqUEwD1y5fkMzkBg8H66H+H7WnVh+4B0GR2UkRC66OkazlGGy1B8+2TNK52 c9xg== 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=hRyHMgHaSqkNxbbATyAsbyQifwj1DbDNtGJlZ1TH0ZA=; b=bdaeDHlo6gC0idh8hKvFSlQFC1zAJ9EjX6vvGAURRXwt1gznNcAUeEy2CboOH6rtNZ BGbaTtxduQNr+viYexz5zIMgwFfWYdVvd6H7Rt1u7zbRU+mZJYQQUv3uRUww3Iwn8qhZ vYUF0ZndUbXcPIhMwwX5t13DBQo+gHU3ZQLUKdtJ3nYJmOiulAPrWhFmzdPY7xF/2BVa nlMRbeNXg1zIMrRgAuArV1KtNeA564TRH1fe0I4tsexOpW3xaF4h8JsF8qdWo8XPaREU EX6Gi6byOQrmXS5Gl4j24apYeMaqq80TJwl4OjQg0vq+/Lny+kmCAHbP5XkMw1plmNn/ 8Ywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=glKaTqBb; 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 sc19-20020a1709078a1300b0078217f3a033si16783506ejc.652.2022.11.02.01.33.50; Wed, 02 Nov 2022 01:34:14 -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=glKaTqBb; 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 S230122AbiKBIZP (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 04:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiKBIZI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 04:25:08 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8373EDEDE; Wed, 2 Nov 2022 01:25:07 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 128so15637603pga.1; Wed, 02 Nov 2022 01:25:07 -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=hRyHMgHaSqkNxbbATyAsbyQifwj1DbDNtGJlZ1TH0ZA=; b=glKaTqBbaso1cyJebYMm+yYb/7RCFfKIbT9tq16O+aXrjgnPNUFRWWSgB//ZsKgsJc Ea/4HuATjpvqm5DyXdrBS9IqpILxOl3zz6mozZ21zMQWpJ5CN7amfttuyRcVaXkzlnfI Z2gkcLyCfacqWqC1m1Mz1CONAs1A+o5liXo6Hd0sgvb77Jmp2S176+5sE+97QkSy1SKX BiCXJA1refmnV9+92jHvzVyaF3yc03RC4MbrRCEYl6QsaDyCvFFURYyZBqxMAFUSfoeP UvINmRnoRsOh7cEusj4tbJwhQ0vtzF5yhlpyRcFF9jePUrYwCJLKXRUHLRl76SyqHgyd McLg== 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=hRyHMgHaSqkNxbbATyAsbyQifwj1DbDNtGJlZ1TH0ZA=; b=J2EIk7Gl8QhXe7SxOPs+7sBEUgv88/DwekLz823l6MRqB8fd1JjALqLbjzT2zRNZqH W5FB3FKum/Aea9vBYVp8XE8PwM4j93cCIUflwJvvj2dwt5VNFGSg1xVkuXmAhti8Hrta kC7J224TCuHfNgg9tlY++9AG6ZowuZjhUU1N/rDShN8nY8u1VLSiRFzuoxXTGAH6eQKV ZWmdCg2kQszLQt1aAaxlhFKNcuJn9ljVvWcdxRmABWcVSv/MlQkAmaxQP+t/m22xbK7/ EeGY29HK8dtpRtSnvhJb2bA5UR+Lpcapb01i4u7vPd1prALccM20cmcSkoZMTXVJiqpb UOjA== X-Gm-Message-State: ACrzQf3q9FsOvgZYbgxrUvXvPVnw+cSNen65fV0Smk7UXKWMlDvi/wDX 16S2UJAEVtRHtWQUYYgAtcDBAwrGiLxc24cg X-Received: by 2002:a05:6a00:1304:b0:555:6d3f:1223 with SMTP id j4-20020a056a00130400b005556d3f1223mr24104749pfu.60.1667377506878; Wed, 02 Nov 2022 01:25:06 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.83]) by smtp.gmail.com with ESMTPSA id w9-20020a17090a780900b0020adf65cebbsm907009pjk.8.2022.11.02.01.25.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Nov 2022 01:25:06 -0700 (PDT) From: korantwork@gmail.com To: axboe@kernel.dk, asml.silence@gmail.com Cc: linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Xinghui Li <korantli@tencent.com>, kernel test robot <lkp@intel.com> Subject: [PATCH v2] io_uring: fix two assignments in if conditions Date: Wed, 2 Nov 2022 16:25:03 +0800 Message-Id: <20221102082503.32236-1-korantwork@gmail.com> X-Mailer: git-send-email 2.36.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?1748278076082217698?= X-GMAIL-MSGID: =?utf-8?q?1748372610738055958?= |
Series |
[v2] io_uring: fix two assignments in if conditions
|
|
Commit Message
Xinghui Li
Nov. 2, 2022, 8:25 a.m. UTC
From: Xinghui Li <korantli@tencent.com> Fixs two error: "ERROR: do not use assignment in if condition 130: FILE: io_uring/net.c:130: + if (!(issue_flags & IO_URING_F_UNLOCKED) && ERROR: do not use assignment in if condition 599: FILE: io_uring/poll.c:599: + } else if (!(issue_flags & IO_URING_F_UNLOCKED) &&" reported by checkpatch.pl in net.c and poll.c . Signed-off-by: Xinghui Li <korantli@tencent.com> Reported-by: kernel test robot <lkp@intel.com> --- io_uring/net.c | 16 +++++++++------- io_uring/poll.c | 7 +++++-- 2 files changed, 14 insertions(+), 9 deletions(-)
Comments
On 11/2/22 2:25 AM, korantwork@gmail.com wrote: > From: Xinghui Li <korantli@tencent.com> > > Fixs two error: > > "ERROR: do not use assignment in if condition > 130: FILE: io_uring/net.c:130: > + if (!(issue_flags & IO_URING_F_UNLOCKED) && > > ERROR: do not use assignment in if condition > 599: FILE: io_uring/poll.c:599: > + } else if (!(issue_flags & IO_URING_F_UNLOCKED) &&" > reported by checkpatch.pl in net.c and poll.c . I'm not super excited about this patch as the previous one wasn't even compiled? Did you test this one, compile and runtime?
在 2022/11/2 22:19,“Jens Axboe”<axboe@kernel.dk> 写入: > On 11/2/22 2:25 AM, korantwork@gmail.com wrote: > > From: Xinghui Li <korantli@tencent.com> > > > > Fixs two error: > > > > "ERROR: do not use assignment in if condition > > 130: FILE: io_uring/net.c:130: > > + if (!(issue_flags & IO_URING_F_UNLOCKED) && > > > > ERROR: do not use assignment in if condition > > 599: FILE: io_uring/poll.c:599: > > + } else if (!(issue_flags & IO_URING_F_UNLOCKED) &&" > > reported by checkpatch.pl in net.c and poll.c . > > I'm not super excited about this patch as the previous one > wasn't even compiled? Did you test this one, compile and runtime? > First of all, I'm really really really SORRY for the last stupid warning and my careless. But I did make kernel and install it in my device. Also, I did the fio test with polling. However, there is no warning be reported by 'make' command. But when I check the patch code with 'smatch', I did find that warning. I realized how stupid that mistake was.... So, in addition to compiling and installing this kernel, I also checked the code using the static analysis tool this time. There is no new error or warning. " make -j64 CHECK="~/workspace/smatch/smatch" C=1 DESCEND objtool CALL scripts/checksyscalls.sh CC io_uring/net.o CC io_uring/poll.o CHECK io_uring/poll.c io_uring/poll.c: note: in included file (through io_uring/io_uring.h): io_uring/slist.h:138:29: warning: no newline at end of file CHECK io_uring/net.c io_uring/poll.c: note: in included file (through include/trace/events/io_uring.h): ./include/linux/io_uring_types.h:151:37: warning: array of flexible structures io_uring/net.c: note: in included file (through io_uring/io_uring.h): io_uring/slist.h:138:29: warning: no newline at end of file io_uring/net.c: note: in included file (through io_uring/io_uring.h): ./include/linux/io_uring_types.h:151:37: warning: array of flexible structures ... BUILD arch/x86/boot/bzImage Kernel: arch/x86/boot/bzImage is ready (#10) " Again, I am ashamed of the previous mistake. And I totally understand if you reject this one.
On 11/2/22 8:50 PM, Xinghui Li wrote: > > > ?? 2022/11/2 22:19??Jens Axboe?<axboe@kernel.dk> ??: > >> On 11/2/22 2:25 AM, korantwork@gmail.com wrote: >> > From: Xinghui Li <korantli@tencent.com> >> > >> > Fixs two error: >> > >> > "ERROR: do not use assignment in if condition >> > 130: FILE: io_uring/net.c:130: >> > + if (!(issue_flags & IO_URING_F_UNLOCKED) && >> > >> > ERROR: do not use assignment in if condition >> > 599: FILE: io_uring/poll.c:599: >> > + } else if (!(issue_flags & IO_URING_F_UNLOCKED) &&" >> > reported by checkpatch.pl in net.c and poll.c . >> >> I'm not super excited about this patch as the previous one >> wasn't even compiled? Did you test this one, compile and runtime? >> > > First of all, I'm really really really SORRY for the last stupid > warning and my careless. But I did make kernel and install it in my > device. Also, I did the fio test with polling. However, there is no > warning be reported by 'make' command. But when I check the patch code > with 'smatch', I did find that warning. I realized how stupid that > mistake was.... So, in addition to compiling and installing this > kernel, I also checked the code using the static analysis tool this > time. There is no new error or warning. > " > make -j64 CHECK="~/workspace/smatch/smatch" C=1 > DESCEND objtool > CALL scripts/checksyscalls.sh > CC io_uring/net.o > CC io_uring/poll.o > CHECK io_uring/poll.c > io_uring/poll.c: note: in included file (through io_uring/io_uring.h): > io_uring/slist.h:138:29: warning: no newline at end of file > CHECK io_uring/net.c > io_uring/poll.c: note: in included file (through include/trace/events/io_uring.h): > ./include/linux/io_uring_types.h:151:37: warning: array of flexible structures > io_uring/net.c: note: in included file (through io_uring/io_uring.h): > io_uring/slist.h:138:29: warning: no newline at end of file > io_uring/net.c: note: in included file (through io_uring/io_uring.h): > ./include/linux/io_uring_types.h:151:37: warning: array of flexible structures > ... > BUILD arch/x86/boot/bzImage > Kernel: arch/x86/boot/bzImage is ready (#10) > " > > Again, I am ashamed of the previous mistake. And I totally understand > if you reject this one. All good, thanks for doing the due diligence this time around for v2. I'll get it applied for 6.2, thanks.
On Wed, 2 Nov 2022 16:25:03 +0800, korantwork@gmail.com wrote: > From: Xinghui Li <korantli@tencent.com> > > Fixs two error: > > "ERROR: do not use assignment in if condition > 130: FILE: io_uring/net.c:130: > + if (!(issue_flags & IO_URING_F_UNLOCKED) && > > [...] Applied, thanks! [1/1] io_uring: fix two assignments in if conditions commit: c71afa164bfe91f0825c359940899e539abcb6b7 Best regards,
diff --git a/io_uring/net.c b/io_uring/net.c index 15dea91625e2..cbd655c88499 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -127,13 +127,15 @@ static struct io_async_msghdr *io_msg_alloc_async(struct io_kiocb *req, struct io_cache_entry *entry; struct io_async_msghdr *hdr; - if (!(issue_flags & IO_URING_F_UNLOCKED) && - (entry = io_alloc_cache_get(&ctx->netmsg_cache)) != NULL) { - hdr = container_of(entry, struct io_async_msghdr, cache); - hdr->free_iov = NULL; - req->flags |= REQ_F_ASYNC_DATA; - req->async_data = hdr; - return hdr; + if (!(issue_flags & IO_URING_F_UNLOCKED)) { + entry = io_alloc_cache_get(&ctx->netmsg_cache); + if (entry != NULL) { + hdr = container_of(entry, struct io_async_msghdr, cache); + hdr->free_iov = NULL; + req->flags |= REQ_F_ASYNC_DATA; + req->async_data = hdr; + return hdr; + } } if (!io_alloc_async_data(req)) { diff --git a/io_uring/poll.c b/io_uring/poll.c index 0d9f49c575e0..4b3b4441e9ca 100644 --- a/io_uring/poll.c +++ b/io_uring/poll.c @@ -596,10 +596,13 @@ static struct async_poll *io_req_alloc_apoll(struct io_kiocb *req, if (req->flags & REQ_F_POLLED) { apoll = req->apoll; kfree(apoll->double_poll); - } else if (!(issue_flags & IO_URING_F_UNLOCKED) && - (entry = io_alloc_cache_get(&ctx->apoll_cache)) != NULL) { + } else if (!(issue_flags & IO_URING_F_UNLOCKED)) { + entry = io_alloc_cache_get(&ctx->apoll_cache); + if (entry == NULL) + goto out; apoll = container_of(entry, struct async_poll, cache); } else { +out: apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC); if (unlikely(!apoll)) return NULL;