From 267d2ab74793fdf6cb22ef23867f359d6d789f4a Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 29 Dec 2023 18:49:44 +0100 Subject: [PATCH] util: Explicitly initialize auto-cleanup variables gcc complains about potentially uninitialized variables. Signed-off-by: Tomas Bzatek --- src/nvme/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nvme/util.c b/src/nvme/util.c index 78ce14f8..f091da70 100644 --- a/src/nvme/util.c +++ b/src/nvme/util.c @@ -757,7 +757,7 @@ char *kv_keymatch(const char *kv, const char *key) static size_t read_file(const char * fname, char *buffer, size_t *bufsz) { char *p; - _cleanup_file_ FILE *file; + _cleanup_file_ FILE *file = NULL; size_t len; file = fopen(fname, "re"); @@ -806,7 +806,7 @@ size_t get_entity_name(char *buffer, size_t bufsz) size_t get_entity_version(char *buffer, size_t bufsz) { - _cleanup_file_ FILE *file; + _cleanup_file_ FILE *file = NULL; size_t num_bytes = 0; /* /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]) int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]) { - _cleanup_fd_ int f; + _cleanup_fd_ int f = -1; ssize_t n; f = open("/dev/urandom", O_RDONLY);