diff lib/fts.c @ 15530:ddc76c261e25

maint: fts: move decl of `dp' down into while loop; split a long line * lib/fts.c (fts_build): No semantic change.
author Jim Meyering <meyering@redhat.com>
date Wed, 17 Aug 2011 09:24:06 +0200
parents 894e5e6ae541
children 65fb6cc5f301
line wrap: on
line diff
--- a/lib/fts.c	Wed Aug 17 09:20:41 2011 +0200
+++ b/lib/fts.c	Wed Aug 17 09:24:06 2011 +0200
@@ -1229,7 +1229,6 @@
 internal_function
 fts_build (register FTS *sp, int type)
 {
-        register struct dirent *dp;
         register FTSENT *p, *head;
         register size_t nitems;
         FTSENT *tail;
@@ -1352,9 +1351,14 @@
 
         /* Read the directory, attaching each entry to the `link' pointer. */
         doadjust = false;
-        for (head = tail = NULL, nitems = 0; cur->fts_dirp && (dp = readdir(cur->fts_dirp));) {
+        head = NULL;
+        tail = NULL;
+        nitems = 0;
+        while (cur->fts_dirp) {
                 bool is_dir;
-
+                struct dirent *dp = readdir(cur->fts_dirp);
+                if (dp == NULL)
+                        break;
                 if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
                         continue;