Re: [PATCH] nvme: fix uninitialized-variable warning

From: Christoph Hellwig
Date: Thu Jan 30 2020 - 10:05:08 EST


On Tue, Jan 07, 2020 at 10:42:08PM +0100, Arnd Bergmann wrote:
> Fixes: mmtom ("init/Kconfig: enable -O3 for all arches")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> 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;

This one is just gross. I think we'll need to find some other fix
that doesn't obsfucate the code as much.

>
> 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)

OTOH if this shuts up a compiler warning I'd be perfectly fine with it.