From f4fccf8efdd09d5e38f49f6ae1962797ce3e8e9c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 28 Dec 2023 12:25:16 -0800 Subject: [PATCH] include_next: pacify clang -Winclude-next-absolute-path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Without this change, Ubuntu clang version 16.0.6 (15) issues warnings like this: “In file included from xalloc-die.c:25: ./error.h:28:3: warning: #include_next in file found relative to primary source file or found by absolute path; will search from start of include path [-Winclude-next-absolute-path]”. And sure enough, each file includes itself rather than the next include file and it’s only the subsidiary include that gets around to including the next include file. * lib/argmatch.c, lib/chdir-long.c, lib/clean-temp-simple.c: * lib/clean-temp.c, lib/closein.c, lib/closeout.c, lib/copy-acl.c: * lib/copy-file.c, lib/creat.c, lib/csharpcomp.c: * lib/csharpexec.c, lib/error.c, lib/exclude.c, lib/execute.c: * lib/faccessat.c, lib/fopen.c, lib/freopen.c, lib/getopt.c: * lib/getopt1.c, lib/git-merge-changelog.c, lib/javacomp.c: * lib/javaexec.c, lib/javaversion.c, lib/mkdir-p.c, lib/open.c: * lib/openat-die.c, lib/openat.c, lib/os2-spawn.c: * lib/pagealign_alloc.c, lib/pipe-filter-gi.c: * lib/pipe-filter-ii.c, lib/same.c, lib/set-acl.c: * lib/sigpipe-die.c, lib/spawn-pipe.c, lib/sys_socket.c, lib/truncate.c: * lib/unistd.c, lib/verror.c, lib/wait-process.c, lib/wctype-h.c: * lib/xalloc-die.c, lib/xfreopen.c, lib/xmemcoll.c, lib/xprintf.c: * lib/xsetenv.c, lib/xstdopen.c, lib/xstrtol-error.c: Use ‘#include ’ instead of ‘#include "foo.h"’ if foo.h possibly uses #include_next. (However, don’t do this on OSF/1 which has its own problems.) --- ChangeLog | 27 +++++++++++++++++++++++++++ lib/argmatch.c | 2 +- lib/chdir-long.c | 2 +- lib/clean-temp-simple.c | 2 +- lib/clean-temp.c | 2 +- lib/closein.c | 2 +- lib/closeout.c | 2 +- lib/copy-acl.c | 2 +- lib/copy-file.c | 2 +- lib/creat.c | 6 +++++- lib/csharpcomp.c | 2 +- lib/csharpexec.c | 2 +- lib/error.c | 2 +- lib/exclude.c | 2 +- lib/execute.c | 2 +- lib/faccessat.c | 6 +++++- lib/fopen.c | 6 +++++- lib/freopen.c | 6 +++++- lib/getopt.c | 2 +- lib/getopt1.c | 2 +- lib/git-merge-changelog.c | 2 +- lib/javacomp.c | 2 +- lib/javaexec.c | 2 +- lib/javaversion.c | 2 +- lib/mkdir-p.c | 2 +- lib/open.c | 6 +++++- lib/openat-die.c | 2 +- lib/openat.c | 6 +++++- lib/os2-spawn.c | 2 +- lib/pagealign_alloc.c | 2 +- lib/pipe-filter-gi.c | 2 +- lib/pipe-filter-ii.c | 2 +- lib/same.c | 2 +- lib/set-acl.c | 2 +- lib/sigpipe-die.c | 2 +- lib/spawn-pipe.c | 2 +- lib/sys_socket.c | 2 +- lib/truncate.c | 6 +++++- lib/unistd.c | 2 +- lib/verror.c | 2 +- lib/wait-process.c | 2 +- lib/wctype-h.c | 2 +- lib/xalloc-die.c | 2 +- lib/xfreopen.c | 2 +- lib/xmemcoll.c | 2 +- lib/xprintf.c | 2 +- lib/xsetenv.c | 2 +- lib/xstdopen.c | 2 +- lib/xstrtol-error.c | 2 +- 49 files changed, 103 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 746a1ea70f..d07835db5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,32 @@ 2023-12-28 Paul Eggert + include_next: pacify clang -Winclude-next-absolute-path + Without this change, Ubuntu clang version 16.0.6 (15) issues + warnings like this: “In file included from xalloc-die.c:25: + ./error.h:28:3: warning: #include_next in file found relative to + primary source file or found by absolute path; will search from + start of include path [-Winclude-next-absolute-path]”. + And sure enough, each file includes itself rather than the + next include file and it’s only the subsidiary include that + gets around to including the next include file. + * lib/argmatch.c, lib/chdir-long.c, lib/clean-temp-simple.c: + * lib/clean-temp.c, lib/closein.c, lib/closeout.c, lib/copy-acl.c: + * lib/copy-file.c, lib/creat.c, lib/csharpcomp.c: + * lib/csharpexec.c, lib/error.c, lib/exclude.c, lib/execute.c: + * lib/faccessat.c, lib/fopen.c, lib/freopen.c, lib/getopt.c: + * lib/getopt1.c, lib/git-merge-changelog.c, lib/javacomp.c: + * lib/javaexec.c, lib/javaversion.c, lib/mkdir-p.c, lib/open.c: + * lib/openat-die.c, lib/openat.c, lib/os2-spawn.c: + * lib/pagealign_alloc.c, lib/pipe-filter-gi.c: + * lib/pipe-filter-ii.c, lib/same.c, lib/set-acl.c: + * lib/sigpipe-die.c, lib/spawn-pipe.c, lib/sys_socket.c, lib/truncate.c: + * lib/unistd.c, lib/verror.c, lib/wait-process.c, lib/wctype-h.c: + * lib/xalloc-die.c, lib/xfreopen.c, lib/xmemcoll.c, lib/xprintf.c: + * lib/xsetenv.c, lib/xstdopen.c, lib/xstrtol-error.c: + Use ‘#include ’ instead of ‘#include "foo.h"’ if foo.h + possibly uses #include_next. (However, don’t do this on OSF/1 + which has its own problems.) + stat-time: fix macOS bug with negative file times macOS has a bug similar (but not identical) to Solaris when file timestamps are negative: tv_nsec might go negative. diff --git a/lib/argmatch.c b/lib/argmatch.c index 9cddb37d69..ad2b269055 100644 --- a/lib/argmatch.c +++ b/lib/argmatch.c @@ -30,7 +30,7 @@ #define _(msgid) gettext (msgid) -#include "error.h" +#include #include "quotearg.h" #if USE_UNLOCKED_IO diff --git a/lib/chdir-long.c b/lib/chdir-long.c index 8a25538b3f..de5aaee74f 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -209,7 +209,7 @@ chdir_long (char *dir) #if TEST_CHDIR # include "closeout.h" -# include "error.h" +# include int main (int argc, char *argv[]) diff --git a/lib/clean-temp-simple.c b/lib/clean-temp-simple.c index 66eeb1ea69..9e9beb829d 100644 --- a/lib/clean-temp-simple.c +++ b/lib/clean-temp-simple.c @@ -28,7 +28,7 @@ #include #include -#include "error.h" +#include #include "fatal-signal.h" #include "asyncsafe-spin.h" #include "glthread/lock.h" diff --git a/lib/clean-temp.c b/lib/clean-temp.c index de16292b36..ec7fb4b319 100644 --- a/lib/clean-temp.c +++ b/lib/clean-temp.c @@ -36,7 +36,7 @@ #include "clean-temp-simple.h" #include "clean-temp-private.h" -#include "error.h" +#include #include "fatal-signal.h" #include "asyncsafe-spin.h" #include "pathmax.h" diff --git a/lib/closein.c b/lib/closein.c index d26de8d078..930169a1d6 100644 --- a/lib/closein.c +++ b/lib/closein.c @@ -28,7 +28,7 @@ #include "close-stream.h" #include "closeout.h" -#include "error.h" +#include #include "exitfail.h" #include "freadahead.h" #include "quotearg.h" diff --git a/lib/closeout.c b/lib/closeout.c index d9e8211303..813869a3ac 100644 --- a/lib/closeout.c +++ b/lib/closeout.c @@ -28,7 +28,7 @@ #define _(msgid) gettext (msgid) #include "close-stream.h" -#include "error.h" +#include #include "exitfail.h" #include "quotearg.h" diff --git a/lib/copy-acl.c b/lib/copy-acl.c index 3606a5017d..d7beececb6 100644 --- a/lib/copy-acl.c +++ b/lib/copy-acl.c @@ -24,7 +24,7 @@ #include #include "quote.h" -#include "error.h" +#include #include "gettext.h" #define _(msgid) gettext (msgid) diff --git a/lib/copy-file.c b/lib/copy-file.c index 78da3996bb..4132f69dff 100644 --- a/lib/copy-file.c +++ b/lib/copy-file.c @@ -28,7 +28,7 @@ #include #include -#include "error.h" +#include #include "ignore-value.h" #include "safe-read.h" #include "full-write.h" diff --git a/lib/creat.c b/lib/creat.c index dad7b2da45..49b7a453a4 100644 --- a/lib/creat.c +++ b/lib/creat.c @@ -36,9 +36,13 @@ orig_creat (const char *filename, mode_t mode) } /* Specification. */ +#ifdef __osf__ /* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "fcntl.h" +# include "fcntl.h" +#else +# include +#endif #include #include diff --git a/lib/csharpcomp.c b/lib/csharpcomp.c index 03b7da1f7b..89f7a7c10d 100644 --- a/lib/csharpcomp.c +++ b/lib/csharpcomp.c @@ -32,7 +32,7 @@ #include "sh-quote.h" #include "safe-read.h" #include "xmalloca.h" -#include "error.h" +#include #include "gettext.h" #define _(str) gettext (str) diff --git a/lib/csharpexec.c b/lib/csharpexec.c index 2e30198c29..bf85ab849e 100644 --- a/lib/csharpexec.c +++ b/lib/csharpexec.c @@ -27,7 +27,7 @@ #include "execute.h" #include "sh-quote.h" #include "xmalloca.h" -#include "error.h" +#include #include "gettext.h" /* Handling of MONO_PATH is just like Java CLASSPATH. */ diff --git a/lib/error.c b/lib/error.c index 9e26391e98..72f248f157 100644 --- a/lib/error.c +++ b/lib/error.c @@ -22,7 +22,7 @@ # define _GL_NO_INLINE_ERROR #endif -#include "error.h" +#include #include #include diff --git a/lib/exclude.c b/lib/exclude.c index a3479db8a6..43456a3fd5 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -34,7 +34,7 @@ #include "exclude.h" #include "filename.h" -#include "fnmatch.h" +#include #include "hash.h" #if GNULIB_MCEL_PREFER # include "mcel.h" diff --git a/lib/execute.c b/lib/execute.c index b2164f1688..33d98a4175 100644 --- a/lib/execute.c +++ b/lib/execute.c @@ -31,7 +31,7 @@ #include #include "canonicalize.h" -#include "error.h" +#include #include "fatal-signal.h" #include "filename.h" #include "findprog.h" diff --git a/lib/faccessat.c b/lib/faccessat.c index ac8977cfd6..ee83806844 100644 --- a/lib/faccessat.c +++ b/lib/faccessat.c @@ -40,10 +40,14 @@ orig_faccessat (int fd, char const *name, int mode, int flag) } #endif +#ifdef __osf__ /* Write "unistd.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "unistd.h" +# include "unistd.h" +#else +# include +#endif #ifndef HAVE_ACCESS /* Mingw lacks access, but it also lacks real vs. effective ids, so diff --git a/lib/fopen.c b/lib/fopen.c index e1e4cdbd23..9cb6176fb0 100644 --- a/lib/fopen.c +++ b/lib/fopen.c @@ -33,9 +33,13 @@ orig_fopen (const char *filename, const char *mode) } /* Specification. */ +#ifdef __osf__ /* Write "stdio.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "stdio.h" +# include "stdio.h" +#else +# include +#endif #include #include diff --git a/lib/freopen.c b/lib/freopen.c index 646aa7c817..52332b74d6 100644 --- a/lib/freopen.c +++ b/lib/freopen.c @@ -35,9 +35,13 @@ orig_freopen (const char *filename, const char *mode, FILE *stream) } /* Specification. */ +#ifdef __osf__ /* Write "stdio.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "stdio.h" +# include "stdio.h" +#else +# include +#endif #include #include diff --git a/lib/getopt.c b/lib/getopt.c index a2a291d697..43dd5dad61 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -21,7 +21,7 @@ # include #endif -#include "getopt.h" +#include #include #include diff --git a/lib/getopt1.c b/lib/getopt1.c index 49323aa8ed..587daa2a6f 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -21,7 +21,7 @@ # include #endif -#include "getopt.h" +#include #include "getopt_int.h" int diff --git a/lib/git-merge-changelog.c b/lib/git-merge-changelog.c index 2ef745ec9d..c701d29942 100644 --- a/lib/git-merge-changelog.c +++ b/lib/git-merge-changelog.c @@ -164,7 +164,7 @@ #include #include -#include "error.h" +#include #include "idx.h" #include "read-file.h" #include "gl_xlist.h" diff --git a/lib/javacomp.c b/lib/javacomp.c index b4bf298d29..e55b18e2e8 100644 --- a/lib/javacomp.c +++ b/lib/javacomp.c @@ -44,7 +44,7 @@ #include "concat-filename.h" #include "fwriteerror.h" #include "clean-temp.h" -#include "error.h" +#include #include "xvasprintf.h" #include "verify.h" #include "c-strstr.h" diff --git a/lib/javaexec.c b/lib/javaexec.c index 6f4af37485..20d0068fe9 100644 --- a/lib/javaexec.c +++ b/lib/javaexec.c @@ -32,7 +32,7 @@ #include "concat-filename.h" #include "xalloc.h" #include "xmalloca.h" -#include "error.h" +#include #include "gettext.h" #define _(str) gettext (str) diff --git a/lib/javaversion.c b/lib/javaversion.c index aef1be3077..9c1225e7c7 100644 --- a/lib/javaversion.c +++ b/lib/javaversion.c @@ -34,7 +34,7 @@ #include "javaexec.h" #include "spawn-pipe.h" #include "wait-process.h" -#include "error.h" +#include #include "gettext.h" #define _(str) gettext (str) diff --git a/lib/mkdir-p.c b/lib/mkdir-p.c index 67e9050ad6..2cb0bc9bc1 100644 --- a/lib/mkdir-p.c +++ b/lib/mkdir-p.c @@ -31,7 +31,7 @@ #include "dirchownmod.h" #include "dirname.h" -#include "error.h" +#include #include "quote.h" #include "mkancesdirs.h" #include "savewd.h" diff --git a/lib/open.c b/lib/open.c index 7ec8fdc35d..d9af5a2a35 100644 --- a/lib/open.c +++ b/lib/open.c @@ -38,9 +38,13 @@ orig_open (const char *filename, int flags, mode_t mode) } /* Specification. */ +#ifdef __osf__ /* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "fcntl.h" +# include "fcntl.h" +#else +# include +#endif #include "cloexec.h" diff --git a/lib/openat-die.c b/lib/openat-die.c index df3dbc9b66..84bc543706 100644 --- a/lib/openat-die.c +++ b/lib/openat-die.c @@ -22,7 +22,7 @@ #include #ifndef GNULIB_LIBPOSIX -# include "error.h" +# include #endif #include "exitfail.h" diff --git a/lib/openat.c b/lib/openat.c index f28b10e138..160a02e5d5 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -35,9 +35,13 @@ orig_openat (int fd, char const *filename, int flags, mode_t mode) } #endif +#ifdef __osf__ /* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "fcntl.h" +# include "fcntl.h" +#else +# include +#endif #include "openat.h" diff --git a/lib/os2-spawn.c b/lib/os2-spawn.c index c47f33afc3..305226288c 100644 --- a/lib/os2-spawn.c +++ b/lib/os2-spawn.c @@ -29,7 +29,7 @@ #include #include "cloexec.h" -#include "error.h" +#include #include "gettext.h" #define _(str) gettext (str) diff --git a/lib/pagealign_alloc.c b/lib/pagealign_alloc.c index fa74c09fd4..73ebd9d74a 100644 --- a/lib/pagealign_alloc.c +++ b/lib/pagealign_alloc.c @@ -31,7 +31,7 @@ # include #endif -#include "error.h" +#include #include "xalloc.h" #include "gettext.h" diff --git a/lib/pipe-filter-gi.c b/lib/pipe-filter-gi.c index 5b04bf7c7d..94b562286a 100644 --- a/lib/pipe-filter-gi.c +++ b/lib/pipe-filter-gi.c @@ -33,7 +33,7 @@ # include #endif -#include "error.h" +#include #include "spawn-pipe.h" #include "wait-process.h" #include "xalloc.h" diff --git a/lib/pipe-filter-ii.c b/lib/pipe-filter-ii.c index 1730e8175b..abc76c284c 100644 --- a/lib/pipe-filter-ii.c +++ b/lib/pipe-filter-ii.c @@ -153,7 +153,7 @@ WaitForMultipleObjects (DWORD nCount, const HANDLE *pHandles, BOOL bWaitAll, # include #endif -#include "error.h" +#include #include "spawn-pipe.h" #include "wait-process.h" #include "gettext.h" diff --git a/lib/same.c b/lib/same.c index 82a5cc3cff..c6426087f9 100644 --- a/lib/same.c +++ b/lib/same.c @@ -37,7 +37,7 @@ #include "same.h" #include "dirname.h" -#include "error.h" +#include #include "same-inode.h" #ifndef MIN diff --git a/lib/set-acl.c b/lib/set-acl.c index fac5665df2..19bc4aaf31 100644 --- a/lib/set-acl.c +++ b/lib/set-acl.c @@ -24,7 +24,7 @@ #include #include "quote.h" -#include "error.h" +#include #include "gettext.h" #define _(msgid) gettext (msgid) diff --git a/lib/sigpipe-die.c b/lib/sigpipe-die.c index 3202eac4cd..b2d7ab71f3 100644 --- a/lib/sigpipe-die.c +++ b/lib/sigpipe-die.c @@ -24,7 +24,7 @@ #include #include -#include "error.h" +#include #include "exitfail.h" #include "gettext.h" diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c index d2d21e6e8e..42d713817e 100644 --- a/lib/spawn-pipe.c +++ b/lib/spawn-pipe.c @@ -33,7 +33,7 @@ #include #include "canonicalize.h" -#include "error.h" +#include #include "fatal-signal.h" #include "filename.h" #include "findprog.h" diff --git a/lib/sys_socket.c b/lib/sys_socket.c index b7388ceccf..a4e845957f 100644 --- a/lib/sys_socket.c +++ b/lib/sys_socket.c @@ -18,5 +18,5 @@ #include #define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE -#include "sys/socket.h" +#include typedef int dummy; diff --git a/lib/truncate.c b/lib/truncate.c index 0541e346d3..a04bff3fd5 100644 --- a/lib/truncate.c +++ b/lib/truncate.c @@ -37,10 +37,14 @@ orig_truncate (const char *filename, off_t length) } #endif +#ifdef __osf__ /* Write "unistd.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "unistd.h" +# include "unistd.h" +#else +# include +#endif int truncate (const char *filename, off_t length) diff --git a/lib/unistd.c b/lib/unistd.c index be7a825503..98bdb4e265 100644 --- a/lib/unistd.c +++ b/lib/unistd.c @@ -18,5 +18,5 @@ #include #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE -#include "unistd.h" +#include typedef int dummy; diff --git a/lib/verror.c b/lib/verror.c index 46bb230443..acaa6e0a40 100644 --- a/lib/verror.c +++ b/lib/verror.c @@ -25,7 +25,7 @@ #include #include -#include "error.h" +#include #include "xvasprintf.h" #if ENABLE_NLS diff --git a/lib/wait-process.c b/lib/wait-process.c index 3e95b4efb5..012c52ae6c 100644 --- a/lib/wait-process.c +++ b/lib/wait-process.c @@ -29,7 +29,7 @@ #include #include -#include "error.h" +#include #include "fatal-signal.h" #include "xalloc.h" #include "gettext.h" diff --git a/lib/wctype-h.c b/lib/wctype-h.c index 7d3e14a6b5..c8f1eb4905 100644 --- a/lib/wctype-h.c +++ b/lib/wctype-h.c @@ -20,4 +20,4 @@ #include #define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE -#include "wctype.h" +#include diff --git a/lib/xalloc-die.c b/lib/xalloc-die.c index 7605eee151..d4461c793d 100644 --- a/lib/xalloc-die.c +++ b/lib/xalloc-die.c @@ -22,7 +22,7 @@ #include -#include "error.h" +#include #include "exitfail.h" #include "gettext.h" diff --git a/lib/xfreopen.c b/lib/xfreopen.c index e776ff70c1..5620d214b6 100644 --- a/lib/xfreopen.c +++ b/lib/xfreopen.c @@ -18,7 +18,7 @@ #include "xfreopen.h" #include -#include "error.h" +#include #include "exitfail.h" #include "quote.h" diff --git a/lib/xmemcoll.c b/lib/xmemcoll.c index 5a15d2b221..02bf66b60f 100644 --- a/lib/xmemcoll.c +++ b/lib/xmemcoll.c @@ -25,7 +25,7 @@ #include "gettext.h" #define _(msgid) gettext (msgid) -#include "error.h" +#include #include "exitfail.h" #include "memcoll.h" #include "quotearg.h" diff --git a/lib/xprintf.c b/lib/xprintf.c index fbdd96cce4..ef4a619960 100644 --- a/lib/xprintf.c +++ b/lib/xprintf.c @@ -20,7 +20,7 @@ #include -#include "error.h" +#include #include "exitfail.h" #include "gettext.h" diff --git a/lib/xsetenv.c b/lib/xsetenv.c index 2763997df6..b01f2945e8 100644 --- a/lib/xsetenv.c +++ b/lib/xsetenv.c @@ -21,7 +21,7 @@ #include -#include "error.h" +#include #include "gettext.h" #define _(str) gettext (str) diff --git a/lib/xstdopen.c b/lib/xstdopen.c index 76d4781528..0cf4053ac1 100644 --- a/lib/xstdopen.c +++ b/lib/xstdopen.c @@ -20,7 +20,7 @@ #include "xstdopen.h" #include "stdopen.h" -#include "error.h" +#include #include "exitfail.h" #include "gettext.h" diff --git a/lib/xstrtol-error.c b/lib/xstrtol-error.c index 7749e02137..5100542236 100644 --- a/lib/xstrtol-error.c +++ b/lib/xstrtol-error.c @@ -21,7 +21,7 @@ #include -#include "error.h" +#include #include "exitfail.h" #include "gettext.h" -- 2.39.5