浏览代码

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;
 	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 */