From 5c629d9ef4b2f834996850c4cc50fda7bd58646e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 20 Feb 2003 15:03:22 +0000 Subject: (process_file): Set info->skip before any possible return. Report correct usage for directories, not 0. (process_file): Return for `file_type == FTW_DPRE' _before_ recording the dev/ino of a directory. --- src/du.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/du.c') diff --git a/src/du.c b/src/du.c index 95aa4d98c..dac67e5f9 100644 --- a/src/du.c +++ b/src/du.c @@ -329,6 +329,9 @@ process_file (const char *file, const struct stat *sb, int file_type, directory at the specified level. */ static uintmax_t *sum_subdir; + /* Always define info->skip before returning. */ + info->skip = excluded_filename (exclude, file + info->base); + switch (file_type) { case FTW_NS: @@ -360,9 +363,14 @@ process_file (const char *file, const struct stat *sb, int file_type, break; } + /* If this is the first (pre-order) encounter with a directory, + return right away. */ + if (file_type == FTW_DPRE) + return 0; + /* If the file is being excluded or if it has already been counted via a hard link, then don't let it contribute to the sums. */ - if ((info->skip = excluded_filename (exclude, file + info->base)) + if (info->skip || (!opt_count_all && 1 < sb->st_nlink && hash_ins (sb->st_ino, sb->st_dev))) @@ -377,11 +385,6 @@ process_file (const char *file, const struct stat *sb, int file_type, s = size = ST_NBLOCKS (*sb); } - /* If this is the first (pre-order) encounter with a directory, - return right away. */ - if (file_type == FTW_DPRE) - return 0; - if (first_call) { n_alloc = info->level + 10; -- cgit v1.2.3-54-g00ecf