summaryrefslogtreecommitdiff
path: root/components/num_files.c
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2018-05-07 12:17:13 +0200
committerAaron Marcher <me@drkhsh.at>2018-05-07 12:17:13 +0200
commit0a287616b2e3122a1b149e28d63560819bcdf7c9 (patch)
treed24116be9faab08bc4c895ed462d3f4686ff91ff /components/num_files.c
parentdcffaeaf570e6dde5745080e533b5404ebc0e610 (diff)
num_files: Variable declarations at top of block
Diffstat (limited to 'components/num_files.c')
-rw-r--r--components/num_files.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/components/num_files.c b/components/num_files.c
index ab43694..327a64d 100644
--- a/components/num_files.c
+++ b/components/num_files.c
@@ -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));
return NULL;
}
+ num = 0;
while ((dp = readdir(fd))) {
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
continue; /* skip self and parent */