Skip to content

Commit 3389703

Browse files
tbzatekigaw
authored andcommitted
linux: Explicitly initialize auto-cleanup variables
gcc complains about potentially uninitialized variables. Signed-off-by: Tomas Bzatek <[email protected]>
1 parent a681e83 commit 3389703

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/nvme/linux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int nvme_fw_download_seq(int fd, __u32 size, __u32 xfer, __u32 offset,
124124

125125
int nvme_get_telemetry_max(int fd, enum nvme_telemetry_da *da, size_t *data_tx)
126126
{
127-
_cleanup_free_ struct nvme_id_ctrl *id_ctrl;
127+
_cleanup_free_ struct nvme_id_ctrl *id_ctrl = NULL;
128128
int err;
129129

130130
id_ctrl = __nvme_alloc(sizeof(*id_ctrl));
@@ -385,7 +385,7 @@ int nvme_namespace_detach_ctrls(int fd, __u32 nsid, __u16 num_ctrls,
385385

386386
int nvme_get_ana_log_len(int fd, size_t *analen)
387387
{
388-
_cleanup_free_ struct nvme_id_ctrl *ctrl;
388+
_cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
389389
int ret;
390390

391391
ctrl = __nvme_alloc(sizeof(*ctrl));
@@ -405,7 +405,7 @@ int nvme_get_ana_log_len(int fd, size_t *analen)
405405

406406
int nvme_get_logical_block_size(int fd, __u32 nsid, int *blksize)
407407
{
408-
_cleanup_free_ struct nvme_id_ns *ns;
408+
_cleanup_free_ struct nvme_id_ns *ns = NULL;
409409
__u8 flbas;
410410
int ret;
411411

@@ -426,7 +426,7 @@ int nvme_get_logical_block_size(int fd, __u32 nsid, int *blksize)
426426

427427
static int __nvme_set_attr(const char *path, const char *value)
428428
{
429-
_cleanup_fd_ int fd;
429+
_cleanup_fd_ int fd = -1;
430430

431431
fd = open(path, O_WRONLY);
432432
if (fd < 0) {

0 commit comments

Comments
 (0)