summaryrefslogtreecommitdiff
path: root/lib/fts.c
Commit message (Collapse)AuthorAgeFilesLines
* Support FALLTHROUGH macro better in glibc+clang.Paul Eggert2023-03-271-1/+1
| | | | | | | * lib/fnmatch.c (FALLTHROUGH): Use __attribute__ ((__fallthrough__)) also in clang >= 10. * lib/fts.c (FALLTHROUGH): Likewise. * lib/regex_internal.h (FALLTHROUGH): Likewise.
* fts: fail gracefully when out of memoryChuanGang Jiang2023-02-271-1/+5
| | | | | * lib/fts.c (fts_read): Set errno==ENOMEM and return NULL when setup_dir() fails, rather than hitting an assertion later.
* fts: pacify GCC 12 -Wstrict-aliasingPaul Eggert2023-02-041-2/+2
| | | | * lib/fts.c (ADJUST): Avoid -Wstrict-aliasing waring.
* fts: pacify GCC 13 -Wuse-after-freePaul Eggert2023-02-041-5/+10
| | | | | | | | | | | Problem reported by Peter Frazier in: https://lists.gnu.org/r/bug-gnulib/2023-02/msg00000.html * lib/fts.c: Include stdint.h. (fts_build): Do not access freed pointer directly; instead, save its bit-pattern into a uintptr_t, and use that to compare. (ADJUST): Likewise, but more trickily since this hack puns pointer types and relies on undefined behavior. * modules/fts (Depends-on): Add stdint.
* maint: run 'make update-copyright'Simon Josefsson2023-01-011-1/+1
|
* fts: make debug version compilable againPaul Eggert2022-12-091-22/+36
| | | | | | | | | | | | | | | | | | This fixes things in what I hope is a better way than the fd-only approach proposed by Kamil Dudka here: https://lists.gnu.org/archive/html/bug-gnulib/2018-03/msg00079.html https://lists.gnu.org/archive/html/bug-gnulib/2018-03/msg00080.html * lib/fts.c (GNULIB_FTS_DEBUG): Rename from FTS_DEBUG, to avoid collision with coreutils symbol. Do not include <stdint.h> (not needed, since we include <stdint.h>) or "getcwdat.h" (no longer exists). (fd_ring_check, fd_ring_print): Add forward decls. (struct devino): New type. (PRINT_DEVINO): New macro. (getdevino): New static function. (fd_ring_print): Do nothing if not debugging. (fd_ring_print, fd_ring_check): Use getdevino instead of getcwdat. The output isn’t as good, but at least it compiles and runs.
* fts: fix race + mishandling of fstatat failurePaul Eggert2022-12-061-8/+24
| | | | | | | | | | | I hope this fixes a Luke Dashjr coreutils bug report about ext4 ramdisks; see “9.1: du Aborted (corrupt filesystem)” <https://debbugs.gnu.org/59821>. * lib/fts.c (fts_build): Fix two bugs. First, fts_stat was being called without checking its return value, causing a later abort. Second, there was a race between opening a directory and statting it, fixed by using fstat on the file descriptor rather than fstatat on the directory name.
* fts: omit goto break_without_closedirPaul Eggert2022-12-061-6/+2
| | | | * lib/fts.c (fts_build): Refactor to omit goto.
* fts: clarify ISSETPaul Eggert2022-12-061-1/+1
| | | | * lib/fts.c (ISSET): Refactor to clarify boolean usage.
* fts: fix errno handling if dirfd failsPaul Eggert2022-09-251-1/+2
| | | | | | * lib/fts.c (fts_build): Use proper errno if dirfd failed. Although I don’t know of any platform where dirfd can fail here, we might as well get it right.
* stdalign: prefer to not include <stdalign.h>Paul Eggert2022-09-131-1/+0
| | | | | | | * lib/alignalloc.c, lib/argp-parse.c, lib/fts.c, lib/md4.c, lib/md5.c: * lib/rawmemchr.c, lib/sha1.c, lib/sha256.c, lib/sha512.c, lib/sm3.c: * lib/sys_socket.in.h: In C23, <stdalign.h> is a no-op, so don’t include it.
* Rely on new stdbool behaviorPaul Eggert2022-09-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prefer the C23 style to the C99 style, since the stdbool module now supports C23. * lib/acl-internal.h, lib/acl.h, lib/argmatch.c, lib/argmatch.h: * lib/argp-help.c, lib/argv-iter.h, lib/asyncsafe-spin.c: * lib/backup-internal.h, lib/backupfile.c, lib/base32.h: * lib/base64.h, lib/basename-lgpl.c, lib/bitset/base.h: * lib/c-ctype.h, lib/c-strcasestr.c, lib/canonicalize-lgpl.c: * lib/canonicalize.c, lib/chdir-long.c, lib/chown.c: * lib/classpath.h, lib/clean-temp-private.h: * lib/clean-temp-simple.c, lib/clean-temp-simple.h: * lib/clean-temp.c, lib/clean-temp.h, lib/cloexec.h: * lib/close-stream.c, lib/closein.c, lib/closeout.c, lib/closeout.h: * lib/csharpcomp.h, lib/csharpexec.h, lib/cycle-check.c: * lib/cycle-check.h, lib/des.h, lib/dfa.h, lib/diffseq.h: * lib/dirname.h, lib/exclude.c, lib/exclude.h, lib/execute.c: * lib/execute.h, lib/execvpe.c, lib/fatal-signal.c, lib/fchdir.c: * lib/file-set.h, lib/filevercmp.c, lib/findprog-in.c: * lib/findprog.c, lib/findprog.h, lib/fma.c, lib/fnmatch.c: * lib/fopen.c, lib/freadable.h, lib/freading.h, lib/freopen-safer.c: * lib/fstrcmp.c, lib/fsusage.h, lib/fts.c, lib/fwritable.h: * lib/fwriteerror.c, lib/fwriting.h, lib/gen-uni-tables.c: * lib/getaddrinfo.c, lib/getcwd.c, lib/getloadavg.c: * lib/getndelim2.c, lib/getpass.c, lib/getrandom.c: * lib/git-merge-changelog.c, lib/gl_list.h, lib/gl_map.h: * lib/gl_omap.h, lib/gl_oset.h, lib/gl_set.h, lib/glob.c: * lib/glthread/cond.h, lib/hamt.h, lib/hard-locale.h: * lib/hash-triple.h, lib/hash.h, lib/human.h, lib/i-ring.h: * lib/isapipe.c, lib/javacomp.h, lib/javaexec.h, lib/javaversion.c: * lib/lchown.c, lib/localeinfo.h, lib/localename.c: * lib/long-options.h, lib/malloc/dynarray.h, lib/mbchar.h: * lib/mbfile.h, lib/mbiter.h, lib/mbmemcasecoll.h, lib/mbscasestr.c: * lib/mbsstr.c, lib/mbuiter.h, lib/mkdir-p.h, lib/modechange.h: * lib/mountlist.h, lib/nanosleep.c, lib/nonblocking.h: * lib/nstrftime.c, lib/openat.c, lib/openat.h, lib/os2-spawn.c: * lib/parse-datetime.h, lib/pipe-filter-aux.c, lib/pipe-filter-gi.c: * lib/pipe-filter-ii.c, lib/pipe-filter.h, lib/posixtm.h: * lib/priv-set.c, lib/progreloc.c, lib/propername.c: * lib/pthread-spin.c, lib/quotearg.c, lib/readtokens.c: * lib/readtokens0.h, lib/readutmp.c, lib/regex-quote.h: * lib/regex_internal.h, lib/relocwrapper.c, lib/rename.c: * lib/renameatu.c, lib/rpmatch.c, lib/same.c, lib/same.h: * lib/save-cwd.c, lib/savewd.c, lib/savewd.h, lib/spawn-pipe.h: * lib/spawni.c, lib/stack.h, lib/stat.c, lib/stdckdint.in.h: * lib/strcasestr.c, lib/strfmon_l.c, lib/striconveh.c: * lib/striconveha.h, lib/string-buffer.h, lib/strptime.c: * lib/strstr.c, lib/strtod.c, lib/supersede.h, lib/system-quote.c: * lib/tempname.c, lib/term-style-control.c: * lib/term-style-control.h, lib/textstyle.in.h, lib/time_rz.c: * lib/tmpdir.c, lib/tmpdir.h, lib/tmpfile.c, lib/unicase.in.h: * lib/unicase/caseprop.h, lib/unicase/invariant.h: * lib/unicase/u16-casemap.c, lib/unicase/u16-ct-totitle.c: * lib/unicase/u16-is-invariant.c, lib/unicase/u32-casemap.c: * lib/unicase/u32-ct-totitle.c, lib/unicase/u32-is-invariant.c: * lib/unicase/u8-casemap.c, lib/unicase/u8-ct-totitle.c: * lib/unicase/u8-is-invariant.c, lib/unictype.in.h: * lib/unigbrk.in.h, lib/unigbrk/u16-grapheme-breaks.c: * lib/unigbrk/u32-grapheme-breaks.c: * lib/unigbrk/u8-grapheme-breaks.c: * lib/unigbrk/uc-grapheme-breaks.c, lib/uniname/uniname.c: * lib/unistr.in.h, lib/unlinkdir.h, lib/userspec.h, lib/utime.c: * lib/utimecmp.c, lib/utimens.c, lib/wait-process.h: * lib/windows-cond.c, lib/windows-spawn.c, lib/windows-spawn.h: * lib/windows-timedrwlock.c, lib/write-any-file.h, lib/xbinary-io.c: * lib/xstrtod.h, lib/yesno.h: * tests/nap.h, tests/qemu.h, tests/test-areadlink-with-size.c: * tests/test-areadlink.c, tests/test-areadlinkat-with-size.c: * tests/test-areadlinkat.c, tests/test-base32.c: * tests/test-base64.c, tests/test-ceil2.c, tests/test-ceilf2.c: * tests/test-chown.c, tests/test-dirname.c, tests/test-dup-safer.c: * tests/test-dup3.c, tests/test-exclude.c: * tests/test-execute-child.c, tests/test-execute-main.c: * tests/test-execute-script.c, tests/test-explicit_bzero.c: * tests/test-fchownat.c, tests/test-fcntl-safer.c: * tests/test-fcntl.c, tests/test-fdutimensat.c: * tests/test-filenamecat.c, tests/test-floor2.c: * tests/test-floorf2.c, tests/test-fstatat.c, tests/test-fstrcmp.c: * tests/test-futimens.c, tests/test-getlogin.h, tests/test-getopt.h: * tests/test-hard-locale.c, tests/test-hash.c: * tests/test-idpriv-drop.c, tests/test-idpriv-droptemp.c: * tests/test-immutable.c, tests/test-intprops.c: * tests/test-lchown.c, tests/test-link.c, tests/test-linkat.c: * tests/test-lstat.c, tests/test-mbmemcasecmp.c: * tests/test-mbmemcasecoll.c, tests/test-mkdir.c: * tests/test-mkdirat.c, tests/test-mkfifo.c, tests/test-mkfifoat.c: * tests/test-mknod.c, tests/test-nonblocking-pipe-child.c: * tests/test-nonblocking-pipe-main.c: * tests/test-nonblocking-socket-child.c: * tests/test-nonblocking-socket-main.c, tests/test-open.c: * tests/test-openat.c, tests/test-pipe.c, tests/test-pipe2.c: * tests/test-poll.c, tests/test-posix_spawn-chdir.c: * tests/test-posix_spawn-dup2-stdin.c: * tests/test-posix_spawn-dup2-stdout.c: * tests/test-posix_spawn-fchdir.c, tests/test-posix_spawn-open1.c: * tests/test-posix_spawn-open2.c, tests/test-quotearg-simple.c: * tests/test-quotearg.c, tests/test-readlink.c: * tests/test-readlinkat.c, tests/test-readtokens.c: * tests/test-rename.c, tests/test-renameat.c: * tests/test-renameatu.c, tests/test-rmdir.c, tests/test-round2.c: * tests/test-select.h, tests/test-spawn-pipe-child.c: * tests/test-spawn-pipe-main.c, tests/test-spawn-pipe-script.c: * tests/test-stack.c, tests/test-stat.c, tests/test-supersede.c: * tests/test-symlink.c, tests/test-symlinkat.c: * tests/test-system-quote-main.c: * tests/test-term-style-control-hello.c: * tests/test-term-style-control-yes.c, tests/test-timespec.c: * tests/test-trunc2.c, tests/test-truncf2.c, tests/test-unlink.c: * tests/test-unlinkat.c, tests/test-userspec.c, tests/test-utime.c: * tests/test-utimens.c, tests/test-utimensat.c: * tests/unictype/test-categ_byname.c: * tests/unigbrk/test-uc-is-grapheme-break.c: Don’t include stdbool.h. * modules/acl, modules/xgetcwd: Don’t depend on stdbool, as these modules don’t use bool. * modules/argp, modules/bitset, modules/diffseq, modules/file-has-acl: * modules/gen-uni-tables, modules/getrandom: * modules/hash-triple-simple, modules/posix_spawn-internal: * modules/strcasestr, modules/supersede, modules/system-quote: * modules/uniconv/base, modules/uniname/uniname, modules/utime: * modules/windows-timedrwlock: Depend on stdbool, as these modules use bool.
* fts: Fix compilation error with MSVC 14.Bruno Haible2022-09-041-0/+3
| | | | * lib/fts.c (S_IFBLK): Add fallback definition.
* fts: revert change to use AT_NO_AUTOMOUNTPaul Eggert2022-03-101-2/+2
| | | | | | * NEWS: Don’t mention AT_NO_AUTOMOUNT. * lib/fts.c (fts_stat): Don’t use AT_NO_AUTOMOUNT, as it has no effect with fstatat.
* fts: be consistent about AT_NO_AUTOMOUNTPaul Eggert2022-03-091-17/+17
| | | | | | | * lib/fts.c (fts_stat): Use fstatat with AT_NO_AUTOMOUNT consistently, instead of sometimes using stat (which implies AT_NO_AUTOMOUNT) and sometimes using fstatat without AT_NO_AUTOMOUNT. Remove a goto while we’re at it.
* license: fix GPLv3 texts to use a comma instead of semicolon.Bernhard Voelker2022-01-051-1/+1
| | | | | | | | | See: https://www.gnu.org/licenses/gpl-3.0.html#howto Run: $ git grep -l 'Foundation; either version 3' \ | xargs sed -i '/Foundation; either version 3/ s/n; e/n, e/' * All files using GPLv3: Adjust via the above command.
* maint: run 'make update-copyright'Paul Eggert2022-01-011-1/+1
|
* gnulib-common.m4: Use C2x [[maybe_unused]] when possible.Bruno Haible2021-08-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/gnulib-common.m4 (gl_COMMON_BODY): Define _GL_UNUSED as an alias of _GL_ATTRIBUTE_MAYBE_UNUSED, not of _GL_ATTRIBUTE_UNUSED. * lib/binary-io.h (__gl_setmode): Put _GL_UNUSED before, not after, the declaration. * lib/c-stack.c (null_action, segv_handler, overflow_handler, c_stack_action): Likewise. * lib/chown.c (chown): Likewise. * lib/clean-temp-simple.c (cleanup_action): Likewise. * lib/fts.c (dirent_inode_sort_may_be_useful, leaf_optimization, fts_set): Likewise. * lib/getgroups.c (getgroups): Likewise. * lib/getopt.c (_getopt_initialize): Likewise. * lib/getugroups.c (getugroups): Likewise. * lib/localename.c (gl_locale_name_thread_unsafe, gl_locale_name_thread, gl_locale_name_posix, gl_locale_name_environ): Likewise. * lib/mkdir.c (rpl_mkdir): Likewise. * lib/mkfifo.c (mkfifo): Likewise. * lib/mkfifoat.c (mkfifoat): Likewise. * lib/mknod.c (mknod): Likewise. * lib/mknodat.c (mknodat): Likewise. * lib/mountlist.c (me_remote): Likewise. * lib/openpty.c (openpty): Likewise. * lib/parse-datetime.y (yyerror): Likewise. * lib/passfd.c (sendfd, recvfd): Likewise. * lib/pthread-cond.c (pthread_condattr_destroy, pthread_cond_init, pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal, pthread_cond_broadcast, pthread_cond_destroy): Likewise. * lib/pthread-mutex.c (pthread_mutexattr_destroy, pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_timedlock, pthread_mutex_unlock, pthread_mutex_destroy): Likewise. * lib/pthread-rwlock.c (pthread_rwlockattr_destroy, pthread_rwlock_init, pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock): Likewise. * lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy): Likewise. * lib/pthread-thread.c (pthread_attr_destroy): Likewise. * lib/readlink.c (readlink): Likewise. * lib/rename.c (rpl_rename): Likewise. * lib/set-permissions.c (set_permissions): Likewise. * lib/sockets.c (gl_sockets_startup): Likewise. * lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime, stat_time_normalize): Likewise. * lib/strptime.c (__strptime_internal): Likewise. * lib/strtod.c (LDEXP): Likewise. * lib/symlink.c (symlink): Likewise. * lib/symlinkat.c (symlinkat): Likewise. * lib/tempname.c (try_dir, try_nocreate): Likewise. * lib/textstyle.in.h (styled_ostream_begin_use_class, styled_ostream_end_use_class, styled_ostream_get_hyperlink_ref, styled_ostream_get_hyperlink_id, styled_ostream_set_hyperlink, styled_ostream_flush_to_current_style, fd_ostream_create, term_ostream_get_color, term_ostream_set_color, term_ostream_get_bgcolor, term_ostream_set_bgcolor, term_ostream_get_weight, term_ostream_set_weight, term_ostream_get_posture, term_ostream_set_posture, term_ostream_get_underline, term_ostream_set_underline, term_ostream_get_hyperlink_ref, term_ostream_get_hyperlink_id, term_ostream_set_hyperlink, term_ostream_create, term_styled_ostream_create, html_styled_ostream_create, handle_color_option, handle_style_option, style_file_prepare, styled_ostream_create, libtextstyle_set_failure_exit_code): Likewise. * lib/unicodeio.c (exit_failure_callback, fallback_failure_callback): Likewise. * lib/wait-process.c (cleanup_slaves_action): Likewise. * tests/signature.h (SIGNATURE_CHECK2): Likewise. * tests/test-areadlink.c (do_areadlink): Likewise. * tests/test-areadlinkat.c (do_areadlinkat): Likewise. * tests/test-ceilf-ieee.c (main): Likewise. * tests/test-ceilf1.c (main): Likewise. * tests/test-dirent.c (dir): Likewise. * tests/test-fchownat.c (main): Likewise. * tests/test-fdopendir.c (main): Likewise. * tests/test-filenamecat.c (main): Likewise. * tests/test-floor1.c (main): Likewise. * tests/test-floorf-ieee.c (main): Likewise. * tests/test-floorf1.c (main): Likewise. * tests/test-fseeko.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-ftello.c (main): Likewise. * tests/test-getdomainname.c (main): Likewise. * tests/test-getgroups.c (main): Likewise. * tests/test-gethostname.c (main): Likewise. * tests/test-math-c++.cc (OVERLOADED_CHECK): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-openat.c (main): Likewise. * tests/test-parse-datetime.c (main): Likewise. * tests/test-quotearg-simple.c (main): Likewise. * tests/test-quotearg.c (main): Likewise. * tests/test-sethostname2.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-version-etc.c (main): Likewise. * tests/test-xalloc-die.c (main): Likewise. * tests/test-xfprintf-posix.c (main): Likewise. * tests/test-xprintf-posix.c (main): Likewise. * tests/test-xvasprintf.c (main): Likewise.
* fnmatch, regex, fts: FALLTHROUGH consistencyPaul Eggert2021-01-191-2/+2
| | | | | | | | | | | | | | Be more consistent about how FALLTHROUGH is defined. For Gnulib, use attribute.h. For glibc, use __GNUC__ >= 7. Problem for glibc reported by Vaseeharan Vinayagamoorthy in: https://sourceware.org/pipermail/libc-alpha/2021-January/121778.html * lib/fnmatch.c (FALLTHROUGH) [_LIBC]: * lib/regex_internal.h (FALLTHROUGH) [_LIBC]: Don’t worry about Clang, as it’s not needed and provokes GCC. * lib/fts.c (FALLTHROUGH) [!_LIBC]: * lib/regex_internal.h (FALLTHROUGH) [!_LIBC]: Rely on attribute.h for FALLTHROUGH * modules/regex: Depend on attribute module.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* Silence warnings from clang 10 with -Wimplicit-fallthrough.Bruno Haible2020-08-091-3/+3
| | | | | | | | | | * lib/dfa.c (FALLTHROUGH): Use __attribute__ __fallthrough__ also on clang >= 10. * lib/fnmatch.c (FALLTHROUGH): Likewise. * lib/fts.c (FALLTHROUGH): Likewise. * tests/macros.h (FALLTHROUGH): Likewise. * lib/regex_internal.h (FALLTHROUGH): Likewise. * config/srclist.txt: Mark it as needing sync with glibc.
* Optimize three-valued comparison between integers.Bruno Haible2020-07-241-2/+1
| | | | | | | | | | | | | | | | | | | (a > b ? 1 : a < b ? -1 : 0) is the same as (a > b) - (a < b). * m4/gnulib-common.m4 (gl_COMMON): Define _GL_CMP. * lib/c-strcasecmp.c (c_strcasecmp): Use _GL_CMP. * lib/c-strncasecmp.c (c_strncasecmp): Likewise. * lib/dfa.c (compare): Likewise. * lib/fts.c (fts_compare_ino): Likewise. * lib/mbmemcasecmp.c (mbmemcasecmp): Likewise. * lib/mbscasecmp.c (mbscasecmp): Likewise. * lib/mbsncasecmp.c (mbsncasecmp): Likewise. * lib/memcasecmp.c (memcasecmp): Likewise. * lib/memcmp2.c (memcmp2): Likewise. * lib/savedir.c (direntry_cmp_inode): Likewise. * lib/strcasecmp.c (strcasecmp): Likewise. * lib/strncasecmp.c (strncasecmp): Likewise. * lib/unistr/u-cmp2.h (FUNC): Likewise.
* fts: Make more robust in multithreaded applications.Bruno Haible2020-05-281-1/+1
| | | | | * lib/fts.c (fts_open): Pass an O_CLOEXEC flag to open(). * modules/fts (Depends-on): Add 'open'.
* attribute: new modulePaul Eggert2020-05-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies use of GCC and C2X attributes like ‘deprecated’. * MODULES.html.sh: Add attribute. * doc/attribute.texi, lib/attribute.h, modules/attribute: New files. * doc/gnulib.texi (Particular Modules): Add Attributes. * lib/backupfile.c, lib/fnmatch.c, lib/freopen-safer.c: * lib/mbrtoc32.c, lib/mbrtowc.c, lib/nstrftime.c, lib/quotearg.c: * lib/savewd.c, lib/unistr/u8-uctomb-aux.c, lib/unistr/u8-uctomb.c: * lib/vasnprintf.c: Include attribute.h, and let it define FALLTHROUGH. * lib/bitset/base.h, lib/c-stack.c (__attribute__): Remove macro. * lib/bitset/base.h (ATTRIBUTE_UNUSED): Define in terms of _GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2X. * lib/dfa.c (FALLTHROUGH): Define consistently with gl_COMMON_BODY. This is a copy since Gawk doesn’t use Gnulib. * lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Remove definition that is incompatible with gl_COMMON_BODY’s. All uses changed. * lib/fts.c: Include attribte.h, for FALLTHROUGH. Keep the existing FALLTHROUGH definition since Glibc might use it, and it does no harm to Gnulib’s FALLTHROUGH. * lib/fts_.h, lib/inttostr.h: (__GNUC_PREREQ): Remove; no longer needed. (__attribute_warn_unused_result__): Remove. All uses replaced by _GL_ATTRIBUTE_NODISCARD. * lib/gl_list.h, lib/gl_map.h, lib/gl_omap.h, lib/gl_oset.h: * lib/gl_set.h: Prefer _GL_ATTRIBUTE_NODISCARD to an ifdeffed __attribute__ ((__warn_unused_result__)), for forward compatibility to C2X. * lib/hash.h (_GL_ATTRIBUTE_WUR): Remove. All uses replaced by _GL_ATTRIBUTE_NODISCARD. (_GL_ATTRIBUTE_DEPRECATED): Remove, since gl_COMMON_BODY defines it. * lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Remove. All uses replaced by gl_COMMON_BODY’s implementation, which has a slightly different signature. * lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK): Remove. All uses replaced by _GL_ATTRIBUTE_NODISCARD. * lib/unused-parameter.h (_GL_UNUSED_PARAMETER): Define in terms of _GL_ATTRIBUTE_MAYBE_UNUSED. No doubt all uses should be replaced, at some point. * m4/gnulib-common.m4 (_GL_GNUC_PREREQ): New macro. (_Noreturn): Use it. (_GL_HAS_ATTRIBUTE, _GL_ATTRIBUTE_ALLOC_SIZE) (_GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_ARTIFICIAL) (_GL_ATTRIBUTE_COLD) (_GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR) (_GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE) (_GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT) (_GL_ATTRIBUTE_LEAF, _GL_ATTRIBUTE_MAY_ALIAS) (_GL_ATTRIBUTE_MAYBE_UNUSED) (_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE) (_GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_NONSTRING) (_GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE) (_GL_ATTRIBUTE_SENTINEL): New macros. * modules/backup-rename, modules/backupfile, modules/c-vasnprintf: * modules/fnmatch, modules/freopen-safer, modules/fts: * modules/mbrtoc32, modules/mbrtowc, modules/nstrftime: * modules/quotearg, modules/savewd: * modules/unistdio/u16-u16-vasnprintf: * modules/unistdio/u16-vasnprintf: * modules/unistdio/u32-u32-vasnprintf: * modules/unistdio/u32-vasnprintf: * modules/unistdio/u8-u8-vasnprintf: * modules/unistdio/u8-vasnprintf: * modules/unistdio/ulc-vasnprintf: * modules/unistr/u8-uctomb, modules/vasnprintf: (Depends-on:): Add attribute module.
* Tune fts for FTS_LOGICAL+FTS_NOSTATPaul Eggert2020-04-251-3/+4
| | | | | | | | | From a suggestion by Askar Safin in: https://lists.gnu.org/r/bug-gnulib/2020-04/msg00074.html * lib/fts.c (fts_build): If file types are known, optimize FTS_LOGICAL+FTS_NOSTAT for non-symlinks and non-directories the same way that we already optimize FTS_PHYSICAL+FTS_NOSTAT for non-directories.
* fts: remove NOSTAT_LEAF_OPTIMIZATIONPaul Eggert2020-04-151-48/+8
| | | | | | | | | | | | | | | | It caused ‘find’ and ‘du’ to dump core, and it was useful only for obsolescent Linux filesystems anyway. Problem reported in: https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html Quite possibly there is still a serious underlying fts bug with tight-loop-check and mutating file systems, but if so this patch should cause the bug to be triggered less often. * lib/fts.c (enum leaf_optimization): Remove NOSTAT_LEAF_OPTIMIZATION, as it’s problematic. (S_MAGIC_REISERFS, S_MAGIC_XFS): Remove; no longer needed. (leaf_optimization): Remove special cases for ReiserFS and XFS. (fts_read): Remove NOSTAT_LEAF_OPTIMIZATION code. * lib/fts_.h (struct _ftsent.fts_n_dirs_remaining): Remove. All uses removed.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* fts: tune via callocPaul Eggert2019-12-171-2/+2
| | | | * lib/fts.c (fts_open): Prefer calloc to malloc + memset.
* fts: minor simplificationPaul Eggert2019-03-171-1/+0
| | | | * lib/fts.c (fts_safe_changedir): Remove redundant assignment.
* fts: Optimize on Android.Bruno Haible2019-01-271-1/+1
| | | | * lib/fts.c: Treat Android like Linux.
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* backupfile: new dir_fd argsPaul Eggert2018-10-231-25/+1
| | | | | | | | | | | | | | | | | | | | | | New module opendirat with code taken from fts. Use this module to let backupfile use a directory file descriptor. * NEWS: Document the incompatible change. * lib/backup-find.c (find_backup_file_name): * lib/backup-rename.c (backup_file_rename): New arg DIR_FD. * lib/backupfile.c: Include stdint.h, for SIZE_MAX. (SIZE_MAX): Remove. Include opendirat.h rather than dirent--.h. (check_extension): New args DIR_FD and BASE_MAX. All callers changed. (numbered_backup): New args DIR_FD and PNEW_FD. All callers changed. (backupfile_internal): New arg DIR_FD. All callers changed. * lib/fts.c: Include opendirat.h. (opendirat): Move to opendirat.c. * lib/opendirat.c, lib/opendirat.h, modules/opendirat: New files. * modules/backupfile (Depends-on): Remove dirfd, opendir. Add opendirat. * modules/fts (Depends-on): Remove fdopendir, openat-safer. Add opendirat.
* fts: remove FTS_NOATIMEBernhard Voelker2018-10-081-7/+4
| | | | | | | | | | | | | This reverts commit da4d6974013c822af1498941e32db774b2031765. We cannot guarantee that O_NOATIME works: e.g. openat fails with EPERM if the effective user ID of the caller does not match the owner of the file and the caller is not privileged. Downstream findutils has never picked up FTS_NOATIME. Discussed at <https://lists.gnu.org/r/bug-gnulib/2018-09/msg00122.html>. * lib/fts_.h (FTS_NOATIME): Remove bit flag. (FTS_OPTIONMASK): Adjust. * lib/fts.c (diropen, fts_open, fts_build): Likewise. (fd_ring_check): Likewise.
* fts: avoid a memory leak edge casePádraig Brady2018-05-201-0/+1
| | | | | | | | * lib/fts.c (fts_open): Set an appropriate fts_level so that an immediate fts_close() will free the allocation. * tests/test-fts.c (fts_dealloc): Add a test case which will trigger under valgrind or address sanitizer. Fixes https://bugs.gnu.org/31439
* fts: add commentPaul Eggert2018-04-111-1/+5
| | | | | | * 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 filesystemsPaul Eggert2018-04-111-24/+31
| | | | | | | | | | | This fixes a bug I introduced last summer. Problem reported by Kamil Dudka in: https://lists.gnu.org/r/bug-gnulib/2018-04/msg00033.html * lib/fts.c (filesystem_type, dirent_inode_sort_may_be_useful) (leaf_optimization): New arg for file descriptor. All callers changed. (fts_build): Check for whether inodes should be sorted before closing the directory.
* fts: treat CIFS like NFSPaul Eggert2018-04-051-1/+7
| | | | | | | | Problem reported by Kamil Dudka in: https://lists.gnu.org/r/bug-gnulib/2018-04/msg00015.html * lib/fts.c (S_MAGIC_CIFS): New macro. (dirent_inode_sort_may_be_useful, leaf_optimization): Treat CIFS like NFS.
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: Replace many more http URLs by https URLs. Update stale URLs.Bruno Haible2017-09-141-2/+2
| | | | | * users.txt: Remove mention of 'newts'. * lib/localename.c: Update comment about LANG_SOTHO.
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* * lib/fts.c: Fix XFS comments.Paul Eggert2017-09-081-3/+3
|
* fts: fix cloexec racesPaul Eggert2017-08-121-19/+8
| | | | | | | | | | | * lib/fts.c [!_LIBC]: Do not include dirent--.h, unistd--.h, cloexec.h. (opendirat, diropen): Use O_CLOEXEC instead of set_cloexec_flag. (fts_build): Use F_DUPD_CLOEXEC rinstad of set_cloexec_flag. (fd_ring_check): Set cloexec flag on new file descriptors. (fts_build, fd_ring_check): While we’re at it, make sure the resulting file descriptor is not 0, 1, or 2, since that is easy. * modules/fts (Depends-on): Remove cloexec, dirent-safer, dup, fcntl-safer, unistd-safer. Add fcntl.
* fts: port recent changes to CentOS 6Paul Eggert2017-08-101-2/+8
| | | | | | | | | Problem reported by Tom G. Christensen in: http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00064.html * lib/fts.c (fsword): New type. (struct dev_type, filesystem_type): Use it. * m4/fts.m4 (gl_FUNC_FTS_CORE): Check for __fsword_t. Also, check for f_type only if fstatfs and sys/vfs.h work.
* Don't interpret EOVERFLOW to mean nonexistencePaul Eggert2017-07-301-3/+1
| | | | | | | | | | | | | * lib/fts.c (fts_stat): If lstat fails, report its errno, which may be EOVERFLOW; this is likely more useful than reporting the stat errno. * lib/glob.c (link_stat): Rename from link_exists2_p and return -1/0 instead of 0/1. Caller changed. * lib/glob.c (link_exists_p): * lib/renameat2.c (rename_noreplace, renameat2): * lib/tempname.c (try_nocreate): If errno == EOVERFLOW then the directory entry exists, so do not act as if it does not exist.
* fts: simplify fts_buildPaul Eggert2017-07-251-25/+15
| | | | | * lib/fts.c (fts_build): Simplify, and be lazier about calling leaf_optimization.
* fts: three levels of leaf optimizationPaul Eggert2017-07-251-17/+37
| | | | | | | | | * lib/fts.c (enum leaf_optimization): New type with three values. (S_MAGIC_AFS): New macro. Sort them. (leaf_optimization): Rename from leaf_optimization_applies, and return enum leaf_optimization instead of bool. All uses changed. Add cases for unknown type and for AFS. (fts_build): Don’t rely on link counts if NO_LEAF_OPTIMIZATION.
* fts: cache dirent_inode_sort_may_be_useful tooPaul Eggert2017-07-251-106/+96
| | | | | | | | | | | * lib/fts.c (struct dev_type): New struct. (DEV_TYPE_HT_INITIAL_SIZE): New constant. (dev_type_hash, dev_type_compare, filesystem_type): New functions. (dirent_inode_sort_may_be_useful, leaf_optimization_applies): Now takes FTSENT const *, not int. All uses changed. Use filesystem_type to cache. (link_count_optimize_ok): Remove. Caller changed to use leaf_optimization_applies, which now uses shared cache.
* fts: introduce MIN_DIR_NLINKPaul Eggert2017-07-251-5/+14
| | | | | * lib/fts.c (MIN_DIR_NLINK): New constant. Use it instead of 2, whenever we are talking about link counts.
* fts: nlink_t signedness fixupsPaul Eggert2017-07-251-17/+9
| | | | | | | | | | * lib/fts.c (fts_open): Set rootparent n_dirs_remaining to -1 so that root need not be a special case later. (fts_read): Remove now-redundant test for fts_level. Do not assume that nlink_t is signed. (fts_build): Remove useless decrement of nlinks. (fts_stat): Avoid unlikely signed integer overflow later, if nlink_t is signed.
* fallthrough: update for GCC 7/8Jim Meyering2017-05-191-2/+10
| | | | | | | | | | | | | | | | * lib/quotearg.c (FALLTHROUGH): New macro. Use it whenever one switch case falls through into the next, replacing "/* Fall through */" comments. This exposed one instance of an unwarranted "fall through" comment: unwarranted because it preceded a "goto" label not a case statement. * lib/freopen-safer.c (freopen_safer): Likewise. * lib/fts.c (leaf_optimization_applies): Likewise. * lib/unistr/u8-uctomb-aux.c (u8_uctomb_aux): Likewise. * tests/test-getopt_long.h (getopt_long_loop): Likewise. * tests/test-tsearch.c (mangle_tree): Likewise. Also include tests/macros.h for the definition. * tests/test-argp.c (group1_parser): Likewise. * tests/test-getopt.h (getopt_loop): Likewise.