Преглед на файлове

num_files: Variable declarations at top of block

Aaron Marcher преди 7 години
родител
ревизия
0a287616b2
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  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;
 	struct dirent *dp;
 	DIR *fd;
 	DIR *fd;
-	int num = 0;
+	int num;
 
 
 	if (!(fd = opendir(dir))) {
 	if (!(fd = opendir(dir))) {
 		fprintf(stderr, "opendir '%s': %s\n", dir, strerror(errno));
 		fprintf(stderr, "opendir '%s': %s\n", dir, strerror(errno));
 		return NULL;
 		return NULL;
 	}
 	}
 
 
+	num = 0;
 	while ((dp = readdir(fd))) {
 	while ((dp = readdir(fd))) {
 		if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
 		if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
 			continue; /* skip self and parent */
 			continue; /* skip self and parent */