bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] fts: avoid used-uninitialized error due to recent change


From: Jim Meyering
Subject: [PATCH] fts: avoid used-uninitialized error due to recent change
Date: Wed, 18 Feb 2009 08:55:38 +0100

In my pre-release testing of coreutils valgrind spotted a new problem.
Here's the fix I'll probably push soon.

>From 35cacf46fb3848941709955041c6902c7f6c20ca Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 18 Feb 2009 08:37:24 +0100
Subject: [PATCH] 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.
---
 lib/fts.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/fts.c b/lib/fts.c
index f00db41..0cbb9fb 100644
--- 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
--
1.6.2.rc1.175.g96b8a




reply via email to

[Prev in Thread] Current Thread [Next in Thread]