* lib/uninorm.in.h (uninorm_filter_free): Move declaration up.
(uninorm_filter_create): Declare that deallocation must happen through
'uninorm_filter_free'.
* lib/unistr.in.h: Include <stdlib.h>.
(u8_strdup, u16_strdup, u32_strdup): Declare that deallocation must
happen through 'free'.
* lib/pipe-filter.h (pipe_filter_gi_close): Move declaration up.
(pipe_filter_gi_create): Declare that deallocation must happen through
'pipe_filter_gi_close'.
* lib/bitset.h (bitset_free): Move declaration up.
(bitset_alloc, bitset_create): Declare that deallocation must happen
through 'bitset_free'.
(bitset_obstack_free): Move declaration up.
(bitset_obstack_alloc): Declare that deallocation must happen through
'bitset_obstack_free'.
* lib/argv-iter.h (argv_iter_free): Move declaration up.
(argv_iter_init_argv, argv_iter_init_stream): Declare that deallocation
must happen through 'argv_iter_free'.
* lib/argp-fmtstream.h (__argp_fmtstream_free, argp_fmtstream_free):
Move declarations up.
(__argp_make_fmtstream): Declare that deallocation must happen through
'__argp_fmtstream_free'.
(argp_make_fmtstream): Declare that deallocation must happen through
'argp_fmtstream_free'.
* 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.