]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(process_file): Set info->skip before any possible return.
authorJim Meyering <jim@meyering.net>
Thu, 20 Feb 2003 15:03:22 +0000 (15:03 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 20 Feb 2003 15:03:22 +0000 (15:03 +0000)
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

index 95aa4d98cee91ae526388c0d4ca15abe7b046515..dac67e5f95e23ea09b84445223080834f2c7cfab 100644 (file)
--- 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;