Skip to content

Commit 267d2ab

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

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/nvme/util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ char *kv_keymatch(const char *kv, const char *key)
757757
static size_t read_file(const char * fname, char *buffer, size_t *bufsz)
758758
{
759759
char *p;
760-
_cleanup_file_ FILE *file;
760+
_cleanup_file_ FILE *file = NULL;
761761
size_t len;
762762

763763
file = fopen(fname, "re");
@@ -806,7 +806,7 @@ size_t get_entity_name(char *buffer, size_t bufsz)
806806

807807
size_t get_entity_version(char *buffer, size_t bufsz)
808808
{
809-
_cleanup_file_ FILE *file;
809+
_cleanup_file_ FILE *file = NULL;
810810
size_t num_bytes = 0;
811811

812812
/* /proc/sys/kernel/ostype typically contains the string "Linux" */
@@ -928,7 +928,7 @@ int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN])
928928

929929
int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN])
930930
{
931-
_cleanup_fd_ int f;
931+
_cleanup_fd_ int f = -1;
932932
ssize_t n;
933933

934934
f = open("/dev/urandom", O_RDONLY);

0 commit comments

Comments
 (0)