fts: avoid used-uninitialized error due to recent change
authorJim Meyering <meyering@redhat.com>
Wed, 18 Feb 2009 07:37:24 +0000 (08:37 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 18 Feb 2009 14:54:29 +0000 (15:54 +0100)
* lib/fts.c (fts_read): Guard uses of the new member,
parent->fts_n_dirs_remaining, since it's not relevant for
the parent of a directory specified on the command-line.

ChangeLog
lib/fts.c

index 4146057..8cbd03b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-02-18  Jim Meyering  <meyering@redhat.com>
+
+       fts: avoid used-uninitialized error due to recent change
+       * lib/fts.c (fts_read): Guard uses of the new member,
+       parent->fts_n_dirs_remaining, since it's not relevant for
+       the parent of a directory specified on the command-line.
+
 2009-02-17  James Youngman  <jay@gnu.org>
             Bruno Haible  <bruno@clisp.org>
 
index f00db41..0cbb9fb 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -965,7 +965,10 @@ check_for_dir:
                    if (p->fts_statp->st_size == FTS_STAT_REQUIRED)
                      {
                        FTSENT *parent = p->fts_parent;
-                       if (parent->fts_n_dirs_remaining == 0
+                       if (FTS_ROOTLEVEL < p->fts_level
+                           /* ->fts_n_dirs_remaining is not valid
+                              for command-line-specified names.  */
+                           && parent->fts_n_dirs_remaining == 0
                            && ISSET(FTS_NOSTAT)
                            && ISSET(FTS_PHYSICAL)
                            && link_count_optimize_ok (parent))
@@ -975,11 +978,10 @@ check_for_dir:
                        else
                          {
                            p->fts_info = fts_stat(sp, p, false);
-                           if (S_ISDIR(p->fts_statp->st_mode))
-                             {
-                               if (parent->fts_n_dirs_remaining)
+                           if (S_ISDIR(p->fts_statp->st_mode)
+                               && p->fts_level != FTS_ROOTLEVEL
+                               && parent->fts_n_dirs_remaining)
                                  parent->fts_n_dirs_remaining--;
-                             }
                          }
                      }
                    else