]> git.tuebingen.mpg.de Git - adu.git/commitdiff
Get rid of global variables num_dirs, num_files, and num_bytes.
authorAndre Noll <maan@systemlinux.org>
Sun, 1 Jun 2008 18:29:16 +0000 (20:29 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 1 Jun 2008 18:29:16 +0000 (20:29 +0200)
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.

adu.c
adu.h
create.c
select.c

diff --git a/adu.c b/adu.c
index 6eb958456ea292d33cf0bb4eba7b6c050a426866..3eec0b4d67c20509c4de586b5d4bf16d17fb362c 100644 (file)
--- 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 a6a3892e6c33c5aaf52762d15debdb70b96790ac..67607fdb7946151ed2085dc4ccb0fe324dee9128 100644 (file)
--- 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 */
index 1ce2e544cec93a85095c1a451083f4d6aaa211bd..638ba19d28dc5fe3258ea71eabb48514fe9bbb56 100644 (file)
--- 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)
index efe2c3c55a1ea18fb2629243ddf5b5c61aed6dca..094ab72cbf15f21ab77b05cae9d48c5e030a918b 100644 (file)
--- a/select.c
+++ b/select.c
 #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