public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix two assignments in if conditions
@ 2022-11-01  7:29 korantwork
       [not found] ` <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread
From: korantwork @ 2022-11-01  7:29 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, linux-kernel, Xinghui Li

From: Xinghui Li <[email protected]>

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 <[email protected]>
---
 io_uring/net.c  | 16 +++++++++-------
 io_uring/poll.c |  7 ++++---
 2 files changed, 13 insertions(+), 10 deletions(-)

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..e1cb81cca44c 100644
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -596,9 +596,10 @@ 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) {
-		apoll = container_of(entry, struct async_poll, cache);
+	} else if (!(issue_flags & IO_URING_F_UNLOCKED)) {
+		entry = io_alloc_cache_get(&ctx->apoll_cache);
+		if (entry != NULL)
+			apoll = container_of(entry, struct async_poll, cache);
 	} else {
 		apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
 		if (unlikely(!apoll))
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io_uring: fix two assignments in if conditions
       [not found] ` <[email protected]>
@ 2022-11-02  8:06   ` Xinghui Li
  0 siblings, 0 replies; 2+ messages in thread
From: Xinghui Li @ 2022-11-02  8:06 UTC (permalink / raw)
  To: kernel test robot, axboe, Pavel Begunkov
  Cc: llvm, oe-kbuild-all, io-uring, linux-kernel



在 2022/11/1 23:10,“kernel test robot”<[email protected]> 写入:

>    Hi,
>
>    Thank you for the patch! Perhaps something to improve:
>
>	......
>    If you fix the issue, kindly add following tag where applicable
>    | Reported-by: kernel test robot <[email protected]>
>
>    All warnings (new ones prefixed by >>):
>
>    >> io_uring/poll.c:601:7: warning: variable 'apoll' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>                       if (entry != NULL)
>                           ^~~~~~~~~~~~~
>       io_uring/poll.c:608:2: note: uninitialized use occurs here
>               apoll->double_poll = NULL;
>               ^~~~~
>       io_uring/poll.c:601:3: note: remove the 'if' if its condition is always true
>                       if (entry != NULL)
>                       ^~~~~~~~~~~~~~~~~~
>       io_uring/poll.c:594:26: note: initialize the variable 'apoll' to silence this warning
>               struct async_poll *apoll;
>                                       ^
>                                        = NULL
>       1 warning generated. 
>
>
>    vim +601 io_uring/poll.c
>
It is do a problem, I will sent v2.
Thanks a lot!
    -- 
    0-DAY CI Kernel Test Service
    https://01.org/lkp



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-02  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-01  7:29 [PATCH] io_uring: fix two assignments in if conditions korantwork
     [not found] ` <[email protected]>
2022-11-02  8:06   ` Xinghui Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox