commit 984f45719e8ac9f4451c2d009fb34e28afdfbdb6
Author:     planet36 <[email protected]>
AuthorDate: Tue May 11 22:45:34 2021 -0400
Commit:     drkhsh <[email protected]>
CommitDate: Mon Dec 19 02:44:21 2022 +0100

    num_files: opendir() returns a directory stream
    
    opendir() returns a directory stream, not a file descriptor
    
    Co-authored-by: drkhsh <[email protected]>
    Signed-off-by: drkhsh <[email protected]>

diff --git a/components/num_files.c b/components/num_files.c
index e4b4281..df0acd1 100644
--- a/components/num_files.c
+++ b/components/num_files.c
@@ -10,23 +10,23 @@ const char *
 num_files(const char *path)
 {
        struct dirent *dp;
-       DIR *fd;
+       DIR *dir;
        int num;
 
-       if (!(fd = opendir(path))) {
+       if (!(dir = opendir(path))) {
                warn("opendir '%s':", path);
                return NULL;
        }
 
        num = 0;
-       while ((dp = readdir(fd))) {
+       while ((dp = readdir(dir))) {
                if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
                        continue; /* skip self and parent */
 
                num++;
        }
 
-       closedir(fd);
+       closedir(dir);
 
        return bprintf("%d", num);
 }

Reply via email to