Xinqi Bao's Git

Update LICENSE for Tobias
[slstatus.git] / components / num_files.c
index 1a918ac..9179037 100644 (file)
@@ -1,6 +1,6 @@
 /* See LICENSE file for copyright and license details. */
-#include <errno.h>
 #include <dirent.h>
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -11,13 +11,14 @@ num_files(const char *dir)
 {
        struct dirent *dp;
        DIR *fd;
-       int num = 0;
+       int num;
 
        if (!(fd = opendir(dir))) {
-               fprintf(stderr, "opendir '%s': %s\n", dir, strerror(errno));
+               warn("opendir '%s':", dir);
                return NULL;
        }
 
+       num = 0;
        while ((dp = readdir(fd))) {
                if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
                        continue; /* skip self and parent */