Skip to content

Commit 32f3c53

Browse files
committed
tree: always initialize ns variable
With some more aggressive CFLAGS/LDFLAGS optimized for size the compiler gets confused and can't figure out if 'n' is initialized or not. ../libnvme/src/nvme/tree.c: In function ‘__nvme_scan_namespace’: ../libnvme/src/nvme/tree.c:2598:22: error: ‘n’ may be used uninitialized [-Werror=maybe-uninitialized] 2598 | n->sysfs_dir = path; | ~~~~~~~~~~~~~^~~~~~ ../libnvme/src/nvme/tree.c:2583:25: note: ‘n’ was declared here 2583 | struct nvme_ns *n; | ^ Signed-off-by: Daniel Wagner <[email protected]>
1 parent 9d031be commit 32f3c53

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

libnvme/src/nvme/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2573,7 +2573,7 @@ static int __nvme_scan_namespace(struct nvme_global_ctx *ctx,
25732573
{
25742574
_cleanup_free_ char *blkdev = NULL;
25752575
_cleanup_free_ char *path = NULL;
2576-
struct nvme_ns *n;
2576+
struct nvme_ns *n = NULL;
25772577
int ret;
25782578

25792579
blkdev = nvme_ns_generic_to_blkdev(name);

0 commit comments

Comments
 (0)