Skip to contentSkip to conversation

NVMe: fix uninitialized iod compiler warning

PATCH New Keith Busch 2 participants 2 messages Jul 25, 2012 – Jul 26, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NVMe: fix uninitialized iod compiler warning

Signed-off-by Keith Busch <keith.busch at intel.com>
---
 drivers/block/nvme.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/block/nvme.c +1 -1
index 38b9c73..4692c8e 100644
@@ -1158,7 +1158,7 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns,
 	struct nvme_admin_cmd cmd;
 	struct nvme_command c;
 	int status, length;
-	struct nvme_iod *iod;
+	struct nvme_iod *iod = NULL;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 NVMe: fix uninitialized iod compiler warning

drivers/block/nvme.c static int nvme_user_admin_cmd(struct nvme_ns *ns, · line 1161

Quoted 4 lines · Keith Busch
drivers/block/nvme.c +1 -1
 	int status, length;
-	struct nvme_iod *iod;
+	struct nvme_iod *iod = NULL;

So this is a compiler bug. And it's not present in every compiler version; it didn't occur on my machine until I upgraded gcc recently. There's no way that iod can be used uninitialised. The correct way to indicate this is:

+ struct nvme_iod *uninitialized_var(iod);