From: Andre Noll Date: Sun, 1 Jun 2008 18:29:16 +0000 (+0200) Subject: Get rid of global variables num_dirs, num_files, and num_bytes. X-Git-Tag: v0.0.2~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=commitdiff_plain;h=1e723f61001e9f4448a465886b0b4ebcdadb388e Get rid of global variables num_dirs, num_files, and num_bytes. These were defined in adu.c but not used there at all. In fact, create.c only used num_dirs in scan_dir() as a counter for the directory currently being processed while the other two were not really used at all. Make num_dirs local to scan_dir(), rename it to current_dir_num and remove the other two. The only "real" users of these variables are all in select.c, so move them there and make them static. --- diff --git a/adu.c b/adu.c index 6eb9584..3eec0b4 100644 --- a/adu.c +++ b/adu.c @@ -18,13 +18,6 @@ static int signum; /** Command line and config file options. */ struct gengetopt_args_info conf; -/** Global dir count. */ -uint64_t num_dirs = 0; -/** Global files count. */ -uint64_t num_files = 0; -/** Global bytes count. */ -uint64_t num_bytes = 0; - /** The number of different uids found so far. */ uint32_t num_uids = 0; diff --git a/adu.h b/adu.h index a6a3892..67607fd 100644 --- a/adu.h +++ b/adu.h @@ -176,9 +176,6 @@ enum search_uid_flags { extern uint32_t num_uids; extern struct osl_table *dir_table; -extern uint64_t num_dirs; -extern uint64_t num_files; -extern uint64_t num_bytes; extern struct gengetopt_args_info conf; /* adu.c */ diff --git a/create.c b/create.c index 1ce2e54..638ba19 100644 --- a/create.c +++ b/create.c @@ -117,10 +117,13 @@ static int scan_dir(char *dirname, uint64_t *parent_dir_num) struct dirent *entry; int ret, cwd_fd, ret2; uint64_t dir_size = 0, dir_files = 0; - uint64_t this_dir_num = ++num_dirs; + /* dir count. */ + static uint64_t current_dir_num; + + uint64_t this_dir_num = ++current_dir_num; check_signals(); - DEBUG_LOG("----------------- %llu: %s\n", (long long unsigned)num_dirs, dirname); + DEBUG_LOG("----------------- %llu: %s\n", (long long unsigned)current_dir_num, dirname); ret = adu_opendir(dirname, &dir, &cwd_fd); if (ret < 0) { if (ret != -ERRNO_TO_ERROR(EACCES)) @@ -158,9 +161,7 @@ static int scan_dir(char *dirname, uint64_t *parent_dir_num) /* regular file */ size = s.st_size; dir_size += size; - num_bytes += size; dir_files++; - num_files++; uid = s.st_uid; ret = search_uid(uid, CREATE_USER_TABLE | OPEN_USER_TABLE, &ui); if (ret < 0) diff --git a/select.c b/select.c index efe2c3c..094ab72 100644 --- a/select.c +++ b/select.c @@ -15,6 +15,13 @@ #include "error.h" #include "portable_io.h" +/** Global dir count. */ +static uint64_t num_dirs; +/** Global files count. */ +static uint64_t num_files; +/** Global bytes count. */ +static uint64_t num_bytes; + /** The decimal representation of an uint64_t never exceeds that size. */ #define FORMATED_VALUE_SIZE 25