Use a more robust test for a "can't happen" condition.
authorJim Meyering <jim@meyering.net>
Mon, 8 Jan 2007 10:32:58 +0000 (10:32 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 8 Jan 2007 10:32:58 +0000 (10:32 +0000)
* lib/fts.c (fts_read): Revert the change of 2006-11-22, since it
narrowed the st_size value.  Presuming the "can't happen" condition
is true, that narrowing could conceivably convert an invalid st_size
value into a valid one.  Instead, use a change based on Matthew
Woehlke's original patch.

ChangeLog
lib/fts.c

index 88e4075..bb9da15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-01-08  Jim Meyering  <jim@meyering.net>
 
+       Use a more robust test for a "can't happen" condition.
+       * lib/fts.c (fts_read): Revert the change of 2006-11-22, since it
+       narrowed the st_size value.  Presuming the "can't happen" condition
+       is true, that narrowing could conceivably convert an invalid st_size
+       value into a valid one.  Instead, use a change based on Matthew
+       Woehlke's original patch.
+
        Slight readability improvement: use an assert-like macro
        in place of literal "abort ()" uses.
        * lib/fts.c (fts_assert): Define.
index afb296d..9482833 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -740,17 +740,10 @@ name:             t = sp->fts_path + NAPPEND(p->fts_parent);
 check_for_dir:
                if (p->fts_info == FTS_NSOK)
                  {
-                   enum Fts_stat need_stat = p->fts_statp->st_size;
-                   switch (need_stat)
-                     {
-                     case FTS_STAT_REQUIRED:
-                       p->fts_info = fts_stat(sp, p, false);
-                       break;
-                     case FTS_NO_STAT_REQUIRED:
-                       break;
-                     default:
-                       fts_assert (0);
-                     }
+                   if (p->fts_statp->st_size == FTS_STAT_REQUIRED)
+                     p->fts_info = fts_stat(sp, p, false);
+                   else
+                     fts_assert (p->fts_statp->st_size == FTS_NO_STAT_REQUIRED);
                  }
 
                sp->fts_cur = p;