public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v2] io_uring: fix two assignments in if conditions
@ 2022-11-02  8:25 korantwork
  2022-11-02 14:19 ` Jens Axboe
  2022-11-05 15:31 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: korantwork @ 2022-11-02  8:25 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: linux-kernel, io-uring, Xinghui Li, kernel test robot

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]>
Reported-by: kernel test robot <[email protected]>
---
 io_uring/net.c  | 16 +++++++++-------
 io_uring/poll.c |  7 +++++--
 2 files changed, 14 insertions(+), 9 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..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;
-- 
2.34.1


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

* Re: [PATCH v2] io_uring: fix two assignments in if conditions
  2022-11-02  8:25 [PATCH v2] io_uring: fix two assignments in if conditions korantwork
@ 2022-11-02 14:19 ` Jens Axboe
  2022-11-03  2:50   ` Xinghui Li
  2022-11-05 15:31 ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2022-11-02 14:19 UTC (permalink / raw)
  To: korantwork, asml.silence
  Cc: linux-kernel, io-uring, Xinghui Li, kernel test robot

On 11/2/22 2:25 AM, [email protected] wrote:
> 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 .

I'm not super excited about this patch as the previous one
wasn't even compiled? Did you test this one, compile and runtime?

-- 
Jens Axboe



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

* Re: [PATCH v2] io_uring: fix two assignments in if conditions
  2022-11-02 14:19 ` Jens Axboe
@ 2022-11-03  2:50   ` Xinghui Li
  2022-11-05 15:29     ` Jens Axboe
  0 siblings, 1 reply; 5+ messages in thread
From: Xinghui Li @ 2022-11-03  2:50 UTC (permalink / raw)
  To: Jens Axboe, asml.silence
  Cc: linux-kernel, io-uring, Xinghui Li, kernel test robot



在 2022/11/2 22:19,“Jens Axboe”<[email protected]> 写入:

>    On 11/2/22 2:25 AM, [email protected] wrote:
>    > 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 . 
>
>    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.



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

* Re: [PATCH v2] io_uring: fix two assignments in if conditions
  2022-11-03  2:50   ` Xinghui Li
@ 2022-11-05 15:29     ` Jens Axboe
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-11-05 15:29 UTC (permalink / raw)
  To: Xinghui Li, asml.silence
  Cc: linux-kernel, io-uring, Xinghui Li, kernel test robot

On 11/2/22 8:50 PM, Xinghui Li wrote:
> 
> 
> ?? 2022/11/2 22:19??Jens Axboe?<[email protected]> ??:
> 
>>    On 11/2/22 2:25 AM, [email protected] wrote:
>>    > 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 . 
>>
>>    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.

-- 
Jens Axboe

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

* Re: [PATCH v2] io_uring: fix two assignments in if conditions
  2022-11-02  8:25 [PATCH v2] io_uring: fix two assignments in if conditions korantwork
  2022-11-02 14:19 ` Jens Axboe
@ 2022-11-05 15:31 ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-11-05 15:31 UTC (permalink / raw)
  To: korantwork, asml.silence
  Cc: kernel test robot, linux-kernel, io-uring, Xinghui Li

On Wed, 2 Nov 2022 16:25:03 +0800, [email protected] wrote:
> 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) &&
> 
> [...]

Applied, thanks!

[1/1] io_uring: fix two assignments in if conditions
      commit: c71afa164bfe91f0825c359940899e539abcb6b7

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-11-05 15:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-02  8:25 [PATCH v2] io_uring: fix two assignments in if conditions korantwork
2022-11-02 14:19 ` Jens Axboe
2022-11-03  2:50   ` Xinghui Li
2022-11-05 15:29     ` Jens Axboe
2022-11-05 15:31 ` Jens Axboe

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