Skip to content

Commit

Permalink
util: Explicitly initialize auto-cleanup variables
Browse files Browse the repository at this point in the history
gcc complains about potentially uninitialized variables.

Signed-off-by: Tomas Bzatek <[email protected]>
  • Loading branch information
tbzatek authored and igaw committed Jan 18, 2024
1 parent fe4f622 commit 267d2ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/nvme/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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" */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 267d2ab

Please sign in to comment.