* lib/areadlink.h: Include <stdlib.h> instead of <stddef.h>.
(areadlink, areadlink_with_size, areadlinkat, areadlinkat_with_size):
Declare that deallocation must happen through 'free'.
* lib/stdio.in.h (fdopen, fopen, tmpfile): Declare that deallocation
must happen through 'fclose'.
(popen): Declare that deallocation must happen through 'pclose'.
* lib/stdio-safer.h (fopen_safer, tmpfile_safer): Declare that
deallocation must happen through 'fclose'.
(popen_safer): Declare that deallocation must happen through 'pclose'.
(freopen_safer): Declare that arguments must be non-NULL.
Paul Eggert [Fri, 6 Aug 2021 22:08:27 +0000 (15:08 -0700)]
glob: merge from glibc
* lib/glob-libc.h, lib/glob.c: Merge changes from glibc 2.34.
The result should be copyable directly into glibc.
* modules/glob-h (glob-libc.gl.h): Also omit __THROWNL.
Paul Eggert [Mon, 2 Aug 2021 23:49:01 +0000 (16:49 -0700)]
manywarnings: enable some malloc warnings
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Stop adding
-Wno-analyzer-double-free, -Wno-analyzer-null-dereference, and
-Wno-analyzer-use-after-free, as these false alarms don’t seem
to be as much of an issue now that we’ve pacified a couple
of individual modules and GCC has some bug fixes.
Paul Eggert [Mon, 2 Aug 2021 18:36:30 +0000 (11:36 -0700)]
dfa: omit unneeded malloc+free
Problem indirectly found by Coverity.
* lib/dfa.c (enlistnew): New function, with most of the body of
the old ‘enlist’. It assumes its arg NEW has been malloced and
can be freed eventually.
(enlist, addlists, dfamust): Use it.
(dfamust): Omit an unnecessary malloc+free.
Paul Eggert [Mon, 2 Aug 2021 16:30:50 +0000 (09:30 -0700)]
year2038: port to unusual time_t platforms
* m4/year2038.m4 (gl_YEAR2038_TEST_INCLUDES): Check that time_t
can go to 2**32 - 1, not to 2**63 - 1, as the former is enough to
be year 2038 safe. Unsigned 32-bit time_t (AmigaOS) and signed
40-bit time_t (Unisys ClearPath) have occurred in the wild, and
even if Gnulib code is rarely or never ported to them there’s no
need to exclude them merely because of year 2038 issues.
(gl_YEAR2038_BODY): Adjust messages to match. Use 2**32 - 1,
not 2**32, as the test timestamp, to allow unsigned 32-bit time_t.
Paul Eggert [Mon, 2 Aug 2021 05:27:49 +0000 (22:27 -0700)]
xalloc: no attribute (malloc (free)) on inline
The GCC manual says you can’t use __attribute__ ((__malloc__
(free, 1))) on inline functions. Problem discovered when
compiling diffutils 3.8 on RHEL 8.4 using a GCC 11.2.0 that I
built myself. Perhaps the problem was not discovered earlier
because the attribute works with ‘free’ (which is what I was
seeing before on Fedora 34) but not with ‘rpl_free’ (seen on RHEL
8.4). Anyway, the GCC manual says it shouldn’t work at all, so
don’t use it.
* lib/xalloc.h (xnmalloc, xcharalloc): No longer inline.
* lib/xmalloc.c (xcharalloc, xnmalloc): Move function bodies here.
* m4/gnulib-common.m4 (_GL_ATTRIBUTE_DEALLOC)
(_GL_ATTRIBUTE_DEALLOC_FREE): Document that these cannot be
used on inline functions, as per the GCC 11.2.1 manual.
Paul Eggert [Mon, 2 Aug 2021 00:57:43 +0000 (17:57 -0700)]
sigsegv-tests: make more things static
* tests/test-sigsegv-catch-segv1.c:
* tests/test-sigsegv-catch-stackoverflow1.c:
* tests/test-sigsegv-catch-stackoverflow2.c:
Declare some functions and variables static, to pacify GCC when
warning about external functions missing declarations.
Paul Eggert [Fri, 30 Jul 2021 19:56:24 +0000 (12:56 -0700)]
gnulib-common: update for gcc -Wmismatched-dealloc
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros
_GL_ATTRIBUTE_DEALLOC and _GL_ATTRIBUTE_DEALLOC_FREE. These can
be useful with gcc -Wmismatched-dealloc.
Paul Eggert [Fri, 30 Jul 2021 19:56:24 +0000 (12:56 -0700)]
gnulib-common: update for C2x 2020-12-11 draft
Use blessed-by-draft-standard way to test for [[__deprecated__]]
etc.; this is supported by GCC 11 and the fallback code should
work fine with GCC 10 and earlier, clang, etc.
* NEWS, doc/attribute.texi:
Mention that DEPRECATED etc. must now come first.
* lib/fflush.c, lib/unistr.in.h:
Do not include unused-parameter.h. All uses of _GL_UNUSED_PARAMETER
(after parameters) replaced by _GL_ATTRIBUTE_MAYBE_UNUSED (before
parameters). Although perhaps we need a shorter name for
_GL_ATTRIBUTE_MAYBE_UNUSED, that should probably be in
gnulib-common.m4, due to the ubiquity of this issue.
And perhaps the snippet/unused-parameter module should be marked
obsolete since it's no longer compatible with its old use.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macro
_GL_HAS_C_ATTRIBUTE, and use it instead of __STDC_VERSION__ in
deciding whether to use C2x attributes like [[__deprecated__]].
(_GL_ATTRIBUTE_MAYBE_UNUSED): Fall back on _GL_ATTRIBUTE_UNUSED.
(_GL_ATTRIBUTE_UNUSED): New macro, for labels where C2x
[[maybe_unused]] do not work.
(_GL_UNUSED, _GL_UNUSED_LABEL): Use it.
* modules/fflush, modules/unistr/base (Depends-on):
Remove snippet/unused-parameter.
* modules/fflush (selinux/selinux.h, selinux/context.h)
(selinux/label.h): Do not use $(UNUSED_PARAMETER).
Remove useless chmod a-x.
Paul Eggert [Fri, 30 Jul 2021 19:56:24 +0000 (12:56 -0700)]
limits-h: add BOOL_MAX, BOOL_WIDTH
* doc/posix-headers/limits.texi (limits.h): Document them.
* lib/limits.in.h: Also define CHAR_WIDTH etc. if C2x.
(BOOL_MAX, BOOL_WIDTH): New macros, from C2x.
* m4/limits-h.m4 (gl_LIMITS_H): Also check BOOL_WIDTH.
Simon Josefsson [Wed, 28 Jul 2021 08:37:57 +0000 (10:37 +0200)]
maintainer-makefile: Respect cfg.mk setting announcement_Cc_, reverting most of the previous patch.
* top/maint.mk (announcement_mail_Cc_stable): Rename back to
announcement_Cc_stable.
(announcement_Cc_alpha): Rename back to
announcement_mail_Cc_alpha.
(announcement_Cc_): Renamed from announcement_mail_Cc_.
(announcement_mail_headers_stable)
(announcement_mail_headers_alpha): Use announcement_Cc_ again.
Simon Josefsson [Wed, 28 Jul 2021 08:23:37 +0000 (10:23 +0200)]
maintainer-makefile: Fix announcement mail CC's.
* top/maint.mk (announcement_Cc_stable): Rename to
announcement_mail_Cc_stable.
(announcement_Cc_alpha): Rename to announcement_mail_Cc_alpha.
(announcement_mail_headers_stable)
(announcement_mail_headers_alpha): Use announcement_mail_Cc_
instead of announcement_Cc_.
Paul Eggert [Sun, 18 Jul 2021 19:08:56 +0000 (14:08 -0500)]
explicit_bzero-tests: pacify GCC better
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2021-07/msg00039.html
* tests/test-explicit_bzero.c: Ignore -Wmaybe-uninitialized.
(stackbuf): Remove this static pointer, reverting recent change.
(do_secret_stuff, test_stack): Revert these related changes too.
Paul Eggert [Sun, 18 Jul 2021 04:52:45 +0000 (23:52 -0500)]
explicit_bzero-tests: pacify GCC
Redo to pacify -Wmaybe-uninitialized with
GCC 11.1.1 20210531 (Red Hat 11.1.1-3) x86-64.
* tests/test-explicit_bzero.c (stackbuf): New static pointer.
(do_secret_stuff): Use it.
(test_stack): Set it to a local buffer.
Paul Eggert [Sat, 17 Jul 2021 22:55:18 +0000 (17:55 -0500)]
posixtm: pacify latest GCC
Also, modernize while I’m at it.
* lib/posixtm.c: Include c-ctype.h, idx.h, intprops.h, verify.h
instead of stdlib.h.
(ISDIGIT): Remove. All uses replaced by c_isdigit.
(year, posix_time_parse): Prefer idx_t to size_t. Use assume
instead of abort.
(posixtime): Do not parse twice; once is enough. That way, we
needn’t worry about a bogus warning about strcpy overrunning a
buffer from GCC 11.1.1 20210531 (Red Hat 11.1.1-3) x86-64
when coreutils is configured with --enable-gcc-warnings.
* modules/posixtm (Depends-on): Add c-ctype, intprops, verify.
Remove stpcpy.
Paul Eggert [Thu, 15 Jul 2021 04:55:30 +0000 (23:55 -0500)]
regex: modernize to newer regex bugset
Problem reported by Hiroo Hayashi in:
https://lists.gnu.org/r/bug-gnulib/2021-07/msg00024.html
* m4/regex.m4 (gl_REGEX): Allow newer glibc behavior for ()0|\1,
behavior where the regex compiles but does not match.
Test for glibc bug 11053.
* tests/test-regex.c (bug_regex11, main): Add casts needed
for printf portability.
(main): Allow newer glibc behavior for ()0|\1.
Paul Eggert [Thu, 8 Jul 2021 17:00:30 +0000 (10:00 -0700)]
select: port better to MinGW
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/bug-gnulib/2021-07/msg00017.html
* lib/select.c (rpl_select) [_WIN32 && !__CYGWIN__]:
Pass a SOCKET, not a HANDLE, to FD_ISSET.
Paul Eggert [Tue, 6 Jul 2021 22:21:44 +0000 (15:21 -0700)]
year2038: Add --disable-year2038 option
Also, document this stuff better. Suggested by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2021-07/msg00011.html
* doc/year2038.texi: Document --disable-year2038.
* m4/year2038.m4 (gl_YEAR2038_BODY): Support ‘./configure
--disable-year2038’ to disable 64-bit time_t when that is not the
default. Arg is now either empty or nonempty (not a shell
command) and is evaluated at m4 expansion time instead of at
runtime; all callers changed.
Paul Eggert [Fri, 2 Jul 2021 02:29:57 +0000 (19:29 -0700)]
year2038: support glibc 2.34 _TIME_BITS=64
In glibc 2.34 on Linux kernels where time_t is traditionally 32-bit,
defining _FILE_OFFSET_BITS=64 and _TIME_BITS=64 makes time_t 64-bit.
Apps must define both macros. Gnulib applications that use either
the largefile or the year2038 modules will want this behavior;
largefile because it deals with the off_t and ino_t components of
struct stat already, and so should also deal with time_t.
* NEWS, doc/largefile.texi, doc/posix-headers/time.texi:
Mention this.
* m4/largefile.m4: Override two macros even in Autoconf 2.70 and later.
(_AC_SYS_LARGEFILE_MACRO_VALUE): #undef $1 before #defining it, in
case some other Gnulib macro has #defined it.
(AC_SYS_LARGEFILE): Use AS_IF and AS_CASE to propagate AC_REQUIREs.
Invoke gl_YEAR2038_BODY if we need to set _FILE_OFFSET_BITS=64.
* m4/year2038.m4 (gl_YEAR2038_TEST_INCLUDES): New macro.
(gl_YEAR2038_BODY): New macro, with gl_YEAR2038’s old body; this
macro is designed to be used directly instead of being
AC_REQUIREd. It takes an argument specifying whether 64-bit is
required. Set _TIME_BITS=64 if this makes a difference in time_t
width when setting _FILE_OFFSET_BITS=64. Do not warn about
32-bit time_t more than once.
* modules/largefile (Files): Add year2038.m4.
(Depends-on): Require gl_YEAR2038_EARLY.
Paul Eggert [Thu, 1 Jul 2021 18:26:13 +0000 (11:26 -0700)]
relocatable-prog-wrapper: add m4 files
Add .m4 files needed for standalone relocatable-prog-wrapper, so
that ‘./gnulib-tool --test relocatable-prog-wrapper’ does not fail
with diagnostics like ‘configure.ac:63: error: possibly undefined
macro: gl_FUNC_MALLOC_POSIX’.
* modules/relocatable-prog-wrapper (Files): Add m4/free.m4,
m4/malloc.m4, m4/mempcpy.m4, m4/rawmemchr.m4, m4/realloc.m4.
Bruno Haible [Tue, 29 Jun 2021 00:17:30 +0000 (02:17 +0200)]
strerror-override: Fix possible compilation error.
Reported by Thomas Klausner <wiz@netbsd.org>.
* lib/strerror-override.h (GNULIB_defined_strerror_override_macro): New
macro.
* lib/strerror-override.c (strerror_override): Don't define if
GNULIB_defined_strerror_override_macro is set.
Egor Ignatov [Tue, 22 Jun 2021 19:35:15 +0000 (12:35 -0700)]
regex: fix undefined behavior
Problem reported by Paul Eggert in:
https://lists.gnu.org/r/bug-gnulib/2021-06/msg00115.html
* lib/regexec.c (proceed_next_node):
Don’t insert already-inserted node.
Bruno Haible [Tue, 15 Jun 2021 16:37:18 +0000 (18:37 +0200)]
pipe-filter-ii tests: Fix long-standing failure on native Windows.
* tests/test-pipe-filter-ii2-main.c: Include binary-io.h.
(main): Avoid NL to CRLF conversion on standard output.
* tests/test-pipe-filter-ii2-child.c: Include <unistd.h>, binary-io.h.
(main): Avoid NL to CRLF conversion on standard output.