]> Savannah Git Hosting - gnulib.git/commitdiff
fts: add comment
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 11 Apr 2018 23:27:03 +0000 (16:27 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 11 Apr 2018 23:27:25 +0000 (16:27 -0700)
* lib/fts.c (fts_build): Explain why ==, not >.
See remark by Bernhard Voelker in:
https://lists.gnu.org/r/bug-gnulib/2018-04/msg00041.html

ChangeLog
lib/fts.c

index 3702f75c187d7d1b6ad0158dbccddccbf4b7197c..f5752a2179938ff093dfaa2907b29704d4683419 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2018-04-11  Paul Eggert  <eggert@cs.ucla.edu>
 
+       fts: add comment
+       * lib/fts.c (fts_build): Explain why ==, not >.
+       See remark by Bernhard Voelker in:
+       https://lists.gnu.org/r/bug-gnulib/2018-04/msg00041.html
+
        fts: fix bug in find across filesystems
        This fixes a bug I introduced last summer.
        Problem reported by Kamil Dudka in:
index a26c6824a07313c5990edd0fce5378e49ff653c6..d543510595d2800f0a97838e79fadee469091c88 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1597,7 +1597,11 @@ mem1:                           saved_errno = errno;
                 /* If there are many entries, no sorting function has been
                    specified, and this file system is of a type that may be
                    slow with a large number of entries, arrange to sort the
-                   directory entries on increasing inode numbers.  */
+                   directory entries on increasing inode numbers.
+
+                   The NITEMS comparison uses ==, not >, because the test
+                   needs to be tried at most once once, and NITEMS will exceed
+                   the threshold after it is incremented below.  */
                 if (nitems == _FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD
                     && !sp->fts_compar)
                   sort_by_inode = dirent_inode_sort_may_be_useful (cur, dir_fd);