[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200107214215.935781-1-arnd@arndb.de>
Date: Tue, 7 Jan 2020 22:42:08 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...com>,
Christoph Hellwig <hch@....de>,
Sagi Grimberg <sagi@...mberg.me>
Cc: Oleksandr Natalenko <oleksandr@...hat.com>,
Arnd Bergmann <arnd@...db.de>,
Chaitanya Kulkarni <chaitanya.kulkarni@....com>,
Hannes Reinecke <hare@...e.de>,
Marta Rybczynska <mrybczyn@...ray.eu>,
Bart Van Assche <bvanassche@....org>,
linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] nvme: fix uninitialized-variable warning
gcc -O3 adds a bogus warning in this file:
In file included from include/linux/compiler_types.h:68,
from <command-line>:
drivers/nvme/host/core.c: In function 'nvme_set_queue_count':
include/linux/compiler-gcc.h:71:45: error: 'res.u32' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^~~~~~~~~~~~
drivers/nvme/host/core.c:1167:20: note: 'res.u32' was declared here
union nvme_result res;
^~~
Slightly rearrange the code, enough to let gcc understand
better what is going on and not warn about it.
Fixes: mmtom ("init/Kconfig: enable -O3 for all arches")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
drivers/nvme/host/core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 667f18f465be..6f0991e8c5cc 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -825,14 +825,15 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
int ret;
req = nvme_alloc_request(q, cmd, flags, qid);
- if (IS_ERR(req))
- return PTR_ERR(req);
+ ret = PTR_ERR_OR_ZERO(req);
+ if (ret < 0)
+ return ret;
req->timeout = timeout ? timeout : ADMIN_TIMEOUT;
if (buffer && bufflen) {
ret = blk_rq_map_kern(q, req, buffer, bufflen, GFP_KERNEL);
- if (ret)
+ if (ret < 0)
goto out;
}
--
2.20.0
Powered by blists - more mailing lists