]> www.infradead.org Git - users/hch/block.git/commitdiff
io_uring: fix two assignments in if conditions
authorXinghui Li <korantli@tencent.com>
Wed, 2 Nov 2022 08:25:03 +0000 (16:25 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 5 Nov 2022 15:31:37 +0000 (09:31 -0600)
Fixes two errors:

"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>
Link: https://lore.kernel.org/r/20221102082503.32236-1-korantwork@gmail.com
[axboe: style tweaks]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/net.c
io_uring/poll.c

index b7192e3e4d2d467fcf31521d62c3474737381c06..9a07e79cc0e60ff0b1c3e8bc3a73d78e500790bd 100644 (file)
@@ -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) {
+                       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)) {
index 0d9f49c575e0f5e5e8ae4014884769f26d4e3beb..589b60fc740ac75f9288a9b9b396bd9a63508c2e 100644 (file)
@@ -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 alloc_apoll;
                apoll = container_of(entry, struct async_poll, cache);
        } else {
+alloc_apoll:
                apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
                if (unlikely(!apoll))
                        return NULL;