From 729cf45871bb16065dde7ef0e87823a7ba57b8f3 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 8 Jan 2007 10:32:58 +0000 Subject: [PATCH] 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. --- ChangeLog | 7 +++++++ lib/fts.c | 15 ++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88e40752d..bb9da15ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2007-01-08 Jim Meyering + 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. diff --git a/lib/fts.c b/lib/fts.c index afb296d1b..9482833a0 100644 --- 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; -- 2.11.0