Przeglądaj źródła

num_files: Variable declarations at top of block

Aaron Marcher 7 lat temu
rodzic
commit
0a287616b2
1 zmienionych plików z 2 dodań i 1 usunięć
  1. 2 1
      components/num_files.c

+ 2 - 1
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 */