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

From: Arnd Bergmann
Date: Thu Jan 30 2020 - 10:37:09 EST


On Thu, Jan 30, 2020 at 4:04 PM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
>
> 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.

Initializing the nvme_result in nvme_features() would do it, as would
setting it in the error path in __nvme_submit_sync_cmd() -- either
way the compiler cannot be confused about whether it is initialized
later on.

Arnd