]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/configs: initialize FD to -1
authorKarel Zak <kzak@redhat.com>
Thu, 2 Oct 2025 09:55:55 +0000 (11:55 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 2 Oct 2025 09:55:55 +0000 (11:55 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/configs.c

index a5d714f23e8077620c058e04cc4bc60a1ca4925c..d40743198d83e16050fedb16bb93a5d95f3e400d 100644 (file)
@@ -107,7 +107,7 @@ static int read_dir(struct list_head *file_list,
        char *dirname = NULL;
        char *filename = NULL;
        struct stat st;
-       int dd = 0, nfiles = 0, i;
+       int dd = -1, nfiles = 0, i;
        int counter = 0;
        struct dirent **namelist = NULL;
        struct file_element *entry = NULL;
@@ -175,7 +175,7 @@ finish:
                free(namelist[i]);
        free(namelist);
        free(dirname);
-       if (dd > 0)
+       if (dd >= 0)
                close(dd);
        return counter;
 }