changeset 7786:f79f76e0b6f7

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.
author Jim Meyering <jim@meyering.net>
date Mon, 08 Jan 2007 10:32:58 +0000
parents 3246679850d5
children df203603907e
files ChangeLog lib/fts.c
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -740,17 +740,10 @@
 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;