summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog161
-rw-r--r--build-aux/arg-nonnull.h26
-rw-r--r--lib/argv-iter.h20
-rw-r--r--lib/arpa_inet.in.h10
-rw-r--r--lib/canonicalize-lgpl.c4
-rw-r--r--lib/dirent.in.h14
-rw-r--r--lib/fcntl.in.h7
-rw-r--r--lib/fnmatch.in.h7
-rw-r--r--lib/getaddrinfo.c7
-rw-r--r--lib/getdelim.c4
-rw-r--r--lib/getopt.in.h8
-rw-r--r--lib/glob-libc.h14
-rw-r--r--lib/glob.c4
-rw-r--r--lib/glob.in.h4
-rw-r--r--lib/iconv.in.h7
-rw-r--r--lib/inttypes.in.h6
-rw-r--r--lib/locale.in.h4
-rw-r--r--lib/math.in.h6
-rw-r--r--lib/netdb.in.h12
-rw-r--r--lib/random_r.c7
-rw-r--r--lib/search.in.h16
-rw-r--r--lib/setenv.c5
-rw-r--r--lib/signal.in.h14
-rw-r--r--lib/spawn.in.h60
-rw-r--r--lib/stdio.in.h92
-rw-r--r--lib/stdlib.in.h54
-rw-r--r--lib/string.in.h81
-rw-r--r--lib/strings.in.h10
-rw-r--r--lib/strtod.c6
-rw-r--r--lib/sys_socket.in.h28
-rw-r--r--lib/sys_stat.in.h36
-rw-r--r--lib/sys_time.in.h7
-rw-r--r--lib/sys_times.in.h6
-rw-r--r--lib/sys_utsname.in.h4
-rw-r--r--lib/time.in.h25
-rw-r--r--lib/tsearch.c6
-rw-r--r--lib/unistd.in.h57
-rw-r--r--lib/unsetenv.c4
-rw-r--r--lib/wchar.in.h14
-rw-r--r--modules/arg-nonnull31
-rw-r--r--modules/argv-iter1
-rw-r--r--modules/arpa_inet4
-rw-r--r--modules/dirent4
-rw-r--r--modules/fcntl-h4
-rw-r--r--modules/fnmatch6
-rw-r--r--modules/getopt-posix4
-rw-r--r--modules/glob4
-rw-r--r--modules/iconv_open4
-rw-r--r--modules/inttypes4
-rw-r--r--modules/locale4
-rw-r--r--modules/math4
-rw-r--r--modules/netdb4
-rw-r--r--modules/search4
-rw-r--r--modules/signal4
-rw-r--r--modules/spawn4
-rw-r--r--modules/stdio4
-rw-r--r--modules/stdlib4
-rw-r--r--modules/string4
-rw-r--r--modules/strings4
-rw-r--r--modules/sys_socket4
-rw-r--r--modules/sys_stat4
-rw-r--r--modules/sys_time4
-rw-r--r--modules/sys_times4
-rw-r--r--modules/sys_utsname4
-rw-r--r--modules/time4
-rw-r--r--modules/unistd4
-rw-r--r--modules/wchar4
-rw-r--r--tests/test-canonicalize-lgpl.c8
-rw-r--r--tests/test-canonicalize.c8
-rw-r--r--tests/test-memmem.c8
70 files changed, 751 insertions, 268 deletions
diff --git a/ChangeLog b/ChangeLog
index db9205ae2b..0425b9e4dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,166 @@
2009-12-10 Bruno Haible <bruno@clisp.org>
+ Declare which arguments expect non-NULL values, for GCC and clang.
+ * build-aux/arg-nonnull.h: New file.
+ * modules/arg-nonnull: New file.
+ * lib/arpa_inet.in.h (_GL_ARG_NONNULL): New placeholder.
+ (inet_ntop, inet_pton): Use it.
+ * lib/dirent.in.h (_GL_ARG_NONNULL): New placeholder.
+ (closedir, dirfd, opendir, scandir, alphasort): Use it.
+ * lib/fcntl.in.h (_GL_ARG_NONNULL): New placeholder.
+ (open, openat): Use it.
+ * lib/fnmatch.in.h (_GL_ARG_NONNULL): New placeholder.
+ (fnmatch): Use it.
+ * lib/getopt.in.h (_GL_ARG_NONNULL): New placeholder.
+ (getopt, getopt_long, getopt_long_only): Use it.
+ * lib/glob.in.h (_GL_ARG_NONNULL): New placeholder.
+ * lib/glob-libc.h (glob, globfree, glob64, globfree64, glob_pattern_p):
+ Use it.
+ * lib/iconv.in.h (_GL_ARG_NONNULL): New placeholder.
+ (iconv_open): Use it.
+ * lib/inttypes.in.h (_GL_ARG_NONNULL): New placeholder.
+ (strtoimax, strtoumax): Use it.
+ * lib/locale.in.h (_GL_ARG_NONNULL): New placeholder.
+ (duplocale): Use it.
+ * lib/math.in.h (_GL_ARG_NONNULL): New placeholder.
+ (frexp, frexpl): Use it.
+ * lib/netdb.in.h (_GL_ARG_NONNULL): New placeholder.
+ (getaddrinfo, freeaddrinfo, getnameinfo): Use it.
+ * lib/search.in.h (_GL_ARG_NONNULL): New placeholder.
+ (tsearch, tfind, tdelete, twalk): Use it.
+ * lib/signal.in.h (_GL_ARG_NONNULL): New placeholder.
+ (sigismember, sigemptyset, sigaddset, sigdelset, sigfillset,
+ sigpending): Use it.
+ * lib/spawn.in.h (_GL_ARG_NONNULL): New placeholder.
+ (posix_spawn, posix_spawnp, posix_spawnattr_init,
+ posix_spawnattr_destroy, posix_spawnattr_getsigdefault,
+ posix_spawnattr_setsigdefault, posix_spawnattr_getsigmask,
+ posix_spawnattr_setsigmask, posix_spawnattr_getflags,
+ posix_spawnattr_setflags, posix_spawnattr_getpgroup,
+ posix_spawnattr_setpgroup, posix_spawnattr_getschedpolicy,
+ posix_spawnattr_setschedpolicy, posix_spawnattr_getschedparam,
+ posix_spawnattr_setschedparam, posix_spawn_file_actions_init,
+ posix_spawn_file_actions_destroy, posix_spawn_file_actions_addopen,
+ posix_spawn_file_actions_addclose, posix_spawn_file_actions_adddup2):
+ Use it.
+ * lib/stdio.in.h (_GL_ARG_NONNULL): New placeholder.
+ (dprintf, fclose, fopen, fprintf, fpurge, fputc, fputs, freopen,
+ rpl_fseek, fseeko, rpl_ftell, ftello, fwrite, getdelim, getline,
+ obstack_printf, obstack_vprintf, popen, printf, putc, puts, remove,
+ rename, renameat, snprintf, sprintf, asprintf, vasprintf, vdprintf,
+ vfprintf, vprintf, vsnprintf, vsprintf): Use it.
+ * lib/stdlib.in.h (_GL_ARG_NONNULL): New placeholder.
+ (atoll, canonicalize_file_name, getloadavg, getsubopt, mkdtemp,
+ mkostemp, mkostemps, mkstemp, mkstemps, putenv, srandom_r, initstate_r,
+ setstate_r, random_r, realpath, rpmatch, setenv, strtod, strtoll,
+ strtoull, unsetenv): Use it.
+ * lib/string.in.h (_GL_ARG_NONNULL): New placeholder.
+ (memchr, memmem, mempcpy, memrchr, rawmemchr, stpcpy, stpncpy,
+ strchrnul, strdup, strndup, strnlen, strpbrk, strsep, strstr,
+ strcasestr, strtok_r, mbslen, mbsnlen, mbschr, mbsrchr, mbsstr,
+ mbscasecmp, mbsncasecmp, mbspcasecmp, mbscasestr, mbscspn, mbspbrk,
+ mbsspn, mbssep, mbstok_r, strverscmp): Use it.
+ * lib/strings.in.h (_GL_ARG_NONNULL): New placeholder.
+ (strcasecmp, strncasecmp): Use it.
+ * lib/sys_socket.in.h (_GL_ARG_NONNULL): New placeholder.
+ (rpl_connect, rpl_bind, rpl_getpeername, rpl_getsockname,
+ rpl_getsockopt, rpl_recv, rpl_send, rpl_recvfrom, rpl_sendto,
+ rpl_setsockopt): Use it.
+ * lib/sys_stat.in.h (_GL_ARG_NONNULL): New placeholder.
+ (fchmodat, fstat, fstatat, lchmod, rpl_lstat, mkdir, mkdirat, mkfifo,
+ mkfifoat, mknod, mknodat, stat, utimensat): Use it.
+ * lib/sys_time.in.h (_GL_ARG_NONNULL): New placeholder.
+ (gettimeofday): Use it.
+ * lib/sys_times.in.h (_GL_ARG_NONNULL): New placeholder.
+ (times): Use it.
+ * lib/sys_utsname.in.h (_GL_ARG_NONNULL): New placeholder.
+ (uname): Use it.
+ * lib/time.in.h (_GL_ARG_NONNULL): New placeholder.
+ (nanosleep, mktime, localtime_r, gmtime_r, strptime, timegm): Use it.
+ * lib/unistd.in.h (_GL_ARG_NONNULL): New placeholder.
+ (chown, euidaccess, faccessat, _gl_register_fd, fchownat,
+ getdomainname, gethostname, getlogin_r, lchown, link, linkat, pipe2,
+ pread, readlink, readlinkat, rmdir, symlink, symlinkat, unlink,
+ unlinkat, write): Use it.
+ * lib/wchar.in.h (_GL_ARG_NONNULL): New placeholder.
+ (mbsrtowcs, mbsnrtowcs, wcsrtombs, wcsnrtombs): Use it.
+ * lib/argv-iter.h: Include arg-nonnull.h.
+ (_ATTRIBUTE_NONNULL_): Remove macro.
+ (argv_iter_init_argv, argv_iter_init_stream, argv_iter,
+ argv_iter_n_args, argv_iter_free): Use _GL_ARG_NONNULL.
+ * lib/canonicalize-lgpl.c (_GL_ARG_NONNULL): Define, to defeat gcc
+ optimization.
+ * lib/getaddrinfo.c (_GL_ARG_NONNULL): Likewise.
+ * lib/getdelim.c (_GL_ARG_NONNULL): Likewise.
+ * lib/glob.c (_GL_ARG_NONNULL): Likewise.
+ * lib/random_r.c (_GL_ARG_NONNULL): Likewise.
+ * lib/setenv.c (_GL_ARG_NONNULL): Likewise.
+ * lib/strtod.c (_GL_ARG_NONNULL): Likewise.
+ * lib/tsearch.c (_GL_ARG_NONNULL): Likewise.
+ * lib/unsetenv.c (_GL_ARG_NONNULL): Likewise.
+ * modules/arpa_inet (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into arpa/inet.h.
+ * modules/dirent (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into dirent.h.
+ * modules/fcntl-h (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into fcntl.h.
+ * modules/fnmatch (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into fnmatch.h.
+ * modules/getopt-posix (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into getopt.h.
+ * modules/glob (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into glob.h.
+ * modules/iconv_open (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into iconv.h.
+ * modules/inttypes (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into inttypes.h.
+ * modules/locale (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into locale.h.
+ * modules/math (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into math.h.
+ * modules/netdb (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into netdb.h.
+ * modules/search (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into search.h.
+ * modules/signal (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into signal.h.
+ * modules/spawn (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into spawn.h.
+ * modules/stdio (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into stdio.h.
+ * modules/stdlib (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into stdlib.h.
+ * modules/string (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into string.h.
+ * modules/strings (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into strings.h.
+ * modules/sys_socket (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into sys/socket.h.
+ * modules/sys_stat (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into sys/stat.h.
+ * modules/sys_time (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into sys/time.h.
+ * modules/sys_times (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into sys/times.h.
+ * modules/sys_utsname (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into sys/utsname.h.
+ * modules/time (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into time.h.
+ * modules/unistd (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into unistd.h.
+ * modules/wchar (Depends-on): Add arg-nonnull.
+ (Makefile.am): Insert arg-nonnull.h into wchar.h.
+ * modules/argv-iter (Depends-on): Add arg-nonnull.
+ * tests/test-canonicalize.c (null_ptr): New function.
+ (main): Use it.
+ * tests/test-canonicalize-lgpl.c (null_ptr): New function.
+ (main): Use it.
+ * tests/test-memmem.c (null_ptr): New function.
+ (main): Use it.
+ Reported by Jim Meyering.
+
+2009-12-10 Bruno Haible <bruno@clisp.org>
+
Use spaces for indentation, not tabs.
* lib/**/*.[hcy] except lib/reg*.[hc]: Untabify.
* m4/*.m4: Untabify.
diff --git a/build-aux/arg-nonnull.h b/build-aux/arg-nonnull.h
new file mode 100644
index 0000000000..feebbfe65b
--- /dev/null
+++ b/build-aux/arg-nonnull.h
@@ -0,0 +1,26 @@
+/* A C macro for declaring that specific arguments must not be NULL.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
+ that the values passed as arguments n, ..., m must be non-NULL pointers.
+ n = 1 stands for the first argument, n = 2 for the second argument etc. */
+#ifndef _GL_ARG_NONNULL
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
+# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
+# else
+# define _GL_ARG_NONNULL(params)
+# endif
+#endif
diff --git a/lib/argv-iter.h b/lib/argv-iter.h
index 537fb1ea29..60c1978c15 100644
--- a/lib/argv-iter.h
+++ b/lib/argv-iter.h
@@ -17,16 +17,12 @@
#include <stdio.h>
#include <stdbool.h>
+/* Definition of _GL_ARG_NONNULL. */
+#include "arg-nonnull.h"
+
struct argv_iterator;
enum argv_iter_err;
-#undef _ATTRIBUTE_NONNULL_
-#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
-# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m)))
-#else
-# define _ATTRIBUTE_NONNULL_(m)
-#endif
-
enum argv_iter_err
{
AI_ERR_OK = 1,
@@ -36,12 +32,12 @@ enum argv_iter_err
};
struct argv_iterator *argv_iter_init_argv (char **argv)
- _ATTRIBUTE_NONNULL_ (1);
+ _GL_ARG_NONNULL ((1));
struct argv_iterator *argv_iter_init_stream (FILE *fp)
- _ATTRIBUTE_NONNULL_ (1);
+ _GL_ARG_NONNULL ((1));
char *argv_iter (struct argv_iterator *, enum argv_iter_err *)
- _ATTRIBUTE_NONNULL_ (1) _ATTRIBUTE_NONNULL_ (2);
+ _GL_ARG_NONNULL ((1, 2));
size_t argv_iter_n_args (struct argv_iterator const *)
- _ATTRIBUTE_NONNULL_ (1);
+ _GL_ARG_NONNULL ((1));
void argv_iter_free (struct argv_iterator *)
- _ATTRIBUTE_NONNULL_ (1);
+ _GL_ARG_NONNULL ((1));
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index 26b60737ff..2965629201 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <arpa/inet.h>.
- Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,6 +38,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -60,7 +62,8 @@ extern "C" {
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
extern const char *inet_ntop (int af, const void *restrict src,
- char *restrict dst, socklen_t cnt);
+ char *restrict dst, socklen_t cnt)
+ _GL_ARG_NONNULL ((2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef inet_ntop
@@ -72,7 +75,8 @@ extern const char *inet_ntop (int af, const void *restrict src,
#if @GNULIB_INET_PTON@
# if !@HAVE_DECL_INET_PTON@
-extern int inet_pton (int af, const char *restrict src, void *restrict dst);
+extern int inet_pton (int af, const char *restrict src, void *restrict dst)
+ _GL_ARG_NONNULL ((2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef inet_pton
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index c71721eaa4..27c75bcee6 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -21,6 +21,10 @@
#if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the name == NULL test below. */
+#define _GL_ARG_NONNULL(params)
+
/* Specification. */
#include <stdlib.h>
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 62b7cfb9b0..8694b8596e 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -28,6 +28,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -37,14 +39,14 @@ extern "C" {
#if @REPLACE_CLOSEDIR@
# define closedir rpl_closedir
-extern int closedir (DIR *);
+extern int closedir (DIR *) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_DIRFD@
# if !@HAVE_DECL_DIRFD@ && !defined dirfd
/* Return the file descriptor associated with the given directory stream,
or -1 if none exists. */
-extern int dirfd (DIR const *dir);
+extern int dirfd (DIR const *dir) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef dirfd
@@ -77,7 +79,7 @@ extern DIR *fdopendir (int fd);
#if @REPLACE_OPENDIR@
# define opendir rpl_opendir
-extern DIR * opendir (const char *);
+extern DIR * opendir (const char *) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_SCANDIR@
@@ -88,7 +90,8 @@ extern DIR * opendir (const char *);
# if !@HAVE_SCANDIR@
extern int scandir (const char *dir, struct dirent ***namelist,
int (*filter) (const struct dirent *),
- int (*cmp) (const struct dirent **, const struct dirent **));
+ int (*cmp) (const struct dirent **, const struct dirent **))
+ _GL_ARG_NONNULL ((1, 2, 4));
# endif
#elif defined GNULIB_POSIXCHECK
# undef scandir
@@ -101,7 +104,8 @@ extern int scandir (const char *dir, struct dirent ***namelist,
#if @GNULIB_ALPHASORT@
/* Compare two 'struct dirent' entries alphabetically. */
# if !@HAVE_ALPHASORT@
-extern int alphasort (const struct dirent **, const struct dirent **);
+extern int alphasort (const struct dirent **, const struct dirent **)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef alphasort
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 0ae8213e47..75e1b5599c 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -46,6 +46,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Declare overridden functions. */
@@ -57,7 +59,7 @@ extern "C" {
# if @REPLACE_OPEN@
# undef open
# define open rpl_open
-extern int open (const char *filename, int flags, ...);
+extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -67,7 +69,8 @@ extern int open (const char *filename, int flags, ...);
# define openat rpl_openat
# endif
# if !@HAVE_OPENAT@ || @REPLACE_OPENAT@
-int openat (int fd, char const *file, int flags, /* mode_t mode */ ...);
+int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef openat
diff --git a/lib/fnmatch.in.h b/lib/fnmatch.in.h
index cab79797ee..65fca7dc65 100644
--- a/lib/fnmatch.in.h
+++ b/lib/fnmatch.in.h
@@ -1,5 +1,5 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
- 2005, 2007 Free Software Foundation, Inc.
+ 2005, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -20,6 +20,8 @@
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -56,7 +58,8 @@ extern "C" {
/* Match NAME against the file name pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch (const char *__pattern, const char *__name,
- int __flags);
+ int __flags)
+ _GL_ARG_NONNULL ((1, 2));
#ifdef __cplusplus
}
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index ee89fa29cb..539d184de5 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -1,6 +1,5 @@
/* Get address information (partial implementation).
- Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software
- Foundation, Inc.
+ Copyright (C) 1997, 2001-2002, 2004-2009 Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This program is free software; you can redistribute it and/or modify
@@ -19,6 +18,10 @@
#include <config.h>
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the sa == NULL test below. */
+#define _GL_ARG_NONNULL(params)
+
#include <netdb.h>
#if HAVE_NETINET_IN_H
diff --git a/lib/getdelim.c b/lib/getdelim.c
index cb8886d30c..4ae814b1ca 100644
--- a/lib/getdelim.c
+++ b/lib/getdelim.c
@@ -21,6 +21,10 @@
#include <config.h>
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
+#define _GL_ARG_NONNULL(params)
+
#include <stdio.h>
#include <limits.h>
diff --git a/lib/getopt.in.h b/lib/getopt.in.h
index ed9689cb13..7d74e36cc7 100644
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -121,6 +121,8 @@
# endif
#endif
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -222,17 +224,17 @@ struct option
the environment, then do not permute arguments. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((2, 3));
#ifndef __need_getopt
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((2, 3));
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((2, 3));
#endif
diff --git a/lib/glob-libc.h b/lib/glob-libc.h
index bf701f36c7..abe7468ac1 100644
--- a/lib/glob-libc.h
+++ b/lib/glob-libc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,95-98,2000,2001,2004-2007 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,95-98,2000,2001,2004-2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -173,10 +173,10 @@ typedef struct
#if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
extern int glob (const char *_Restrict_ __pattern, int __flags,
int (*__errfunc) (const char *, int),
- glob_t *_Restrict_ __pglob) __THROW;
+ glob_t *_Restrict_ __pglob) __THROW _GL_ARG_NONNULL ((1, 4));
/* Free storage allocated in PGLOB by a previous `glob' call. */
-extern void globfree (glob_t *__pglob) __THROW;
+extern void globfree (glob_t *__pglob) __THROW _GL_ARG_NONNULL ((1));
#else
extern int __REDIRECT_NTH (glob, (const char *_Restrict_ __pattern,
int __flags,
@@ -189,9 +189,10 @@ extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
extern int glob64 (const char *_Restrict_ __pattern, int __flags,
int (*__errfunc) (const char *, int),
- glob64_t *_Restrict_ __pglob) __THROW;
+ glob64_t *_Restrict_ __pglob)
+ __THROW _GL_ARG_NONNULL ((1, 4));
-extern void globfree64 (glob64_t *__pglob) __THROW;
+extern void globfree64 (glob64_t *__pglob) __THROW _GL_ARG_NONNULL ((1));
#endif
@@ -201,7 +202,8 @@ extern void globfree64 (glob64_t *__pglob) __THROW;
This function is not part of the interface specified by POSIX.2
but several programs want to use it. */
-extern int glob_pattern_p (const char *__pattern, int __quote) __THROW;
+extern int glob_pattern_p (const char *__pattern, int __quote)
+ __THROW _GL_ARG_NONNULL ((1));
#endif
__END_DECLS
diff --git a/lib/glob.c b/lib/glob.c
index f46159bd65..7f0c733255 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -19,6 +19,10 @@
# include <config.h>
#endif
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the pattern == NULL || pglob == NULL tests below. */
+#define _GL_ARG_NONNULL(params)
+
#include <glob.h>
#include <errno.h>
diff --git a/lib/glob.in.h b/lib/glob.in.h
index 09e106b764..bbc732f11d 100644
--- a/lib/glob.in.h
+++ b/lib/glob.in.h
@@ -1,6 +1,6 @@
/* glob.h -- Find a path matching a pattern.
- Copyright (C) 2005-2007 Free Software Foundation, Inc.
+ Copyright (C) 2005-2007, 2009 Free Software Foundation, Inc.
Written by Derek Price <derek@ximbiot.com> & Paul Eggert <eggert@CS.UCLA.EDU>
@@ -40,6 +40,8 @@
# define __THROW
#endif
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifndef __size_t
# define __size_t size_t
#endif
diff --git a/lib/iconv.in.h b/lib/iconv.in.h
index b0ee68e599..a5c509f088 100644
--- a/lib/iconv.in.h
+++ b/lib/iconv.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <iconv.h>.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,6 +28,8 @@
#ifndef _GL_ICONV_H
#define _GL_ICONV_H
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -37,7 +39,8 @@ extern "C" {
/* An iconv_open wrapper that supports the IANA standardized encoding names
("ISO-8859-1" etc.) as far as possible. */
# define iconv_open rpl_iconv_open
-extern iconv_t iconv_open (const char *tocode, const char *fromcode);
+extern iconv_t iconv_open (const char *tocode, const char *fromcode)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @REPLACE_ICONV_UTF@
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index 7022ebc354..cfb6fc7d57 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -47,6 +47,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* 7.8.1 Macros for format specifiers */
#if ! defined __cplusplus || defined __STDC_FORMAT_MACROS
@@ -1066,7 +1068,7 @@ extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
#if @GNULIB_STRTOIMAX@
# if !@HAVE_DECL_STRTOIMAX@
-extern intmax_t strtoimax (const char *, char **, int);
+extern intmax_t strtoimax (const char *, char **, int) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strtoimax
@@ -1078,7 +1080,7 @@ extern intmax_t strtoimax (const char *, char **, int);
#if @GNULIB_STRTOUMAX@
# if !@HAVE_DECL_STRTOUMAX@
-extern uintmax_t strtoumax (const char *, char **, int);
+extern uintmax_t strtoumax (const char *, char **, int) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strtoumax
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 08d05741da..478795ad17 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -34,6 +34,8 @@
# include <xlocale.h>
#endif
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
On systems that don't define it, use the same value as GNU libintl. */
#if !defined LC_MESSAGES
@@ -44,7 +46,7 @@
# if @REPLACE_DUPLOCALE@
# undef duplocale
# define duplocale rpl_duplocale
-extern locale_t duplocale (locale_t locale);
+extern locale_t duplocale (locale_t locale) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef duplocale
diff --git a/lib/math.in.h b/lib/math.in.h
index 05ce408598..614896e366 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -30,6 +30,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -74,7 +76,7 @@ _NaN ()
#if @GNULIB_FREXP@
# if @REPLACE_FREXP@
# define frexp rpl_frexp
-extern double frexp (double x, int *expptr);
+extern double frexp (double x, int *expptr) _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef frexp
@@ -211,7 +213,7 @@ extern long double floorl (long double x);
# define frexpl rpl_frexpl
#endif
#if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
-extern long double frexpl (long double x, int *expptr);
+extern long double frexpl (long double x, int *expptr) _GL_ARG_NONNULL ((2));
#endif
#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
# undef frexpl
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index ec50d13c32..77379d97ed 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -1,5 +1,5 @@
/* Provide a netdb.h header file for systems lacking it (read: MinGW).
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -39,6 +39,8 @@
/* Get netdb.h definitions such as struct hostent for MinGW. */
#include <sys/socket.h>
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Declarations for a platform that lacks <netdb.h>, or where it is
incomplete. */
@@ -141,14 +143,15 @@ struct addrinfo
extern int getaddrinfo (const char *restrict nodename,
const char *restrict servname,
const struct addrinfo *restrict hints,
- struct addrinfo **restrict res);
+ struct addrinfo **restrict res)
+ _GL_ARG_NONNULL ((4));
# endif
# if !@HAVE_DECL_FREEADDRINFO@
/* Free `addrinfo' structure AI including associated storage.
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
-extern void freeaddrinfo (struct addrinfo *ai);
+extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1));
# endif
# if !@HAVE_DECL_GAI_STRERROR@
@@ -165,7 +168,8 @@ extern const char *gai_strerror (int ecode);
extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
char *restrict node, socklen_t nodelen,
char *restrict service, socklen_t servicelen,
- int flags);
+ int flags)
+ _GL_ARG_NONNULL ((1));
# endif
/* Possible flags for getnameinfo. */
diff --git a/lib/random_r.c b/lib/random_r.c
index d9585044b9..6db13a6d58 100644
--- a/lib/random_r.c
+++ b/lib/random_r.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 2005, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2005, 2008-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -52,6 +52,11 @@
#include <config.h>
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the buf == NULL, arg_state == NULL, result == NULL tests
+ below. */
+#define _GL_ARG_NONNULL(params)
+
#include <errno.h>
#include <limits.h>
#include <stddef.h>
diff --git a/lib/search.in.h b/lib/search.in.h
index aa9e994b47..93d2e0286c 100644
--- a/lib/search.in.h
+++ b/lib/search.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <search.h>.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,6 +31,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -65,18 +67,21 @@ VISIT;
If one is found, it is returned. Otherwise, a new element equal to KEY
is inserted in the tree and is returned. */
extern void * tsearch (const void *key, void **vrootp,
- int (*compar) (const void *, const void *));
+ int (*compar) (const void *, const void *))
+ _GL_ARG_NONNULL ((1, 2, 3));
/* Searches an element in the tree *VROOTP that compares equal to KEY.
If one is found, it is returned. Otherwise, NULL is returned. */
extern void * tfind (const void *key, void *const *vrootp,
- int (*compar) (const void *, const void *));
+ int (*compar) (const void *, const void *))
+ _GL_ARG_NONNULL ((1, 2, 3));
/* Searches an element in the tree *VROOTP that compares equal to KEY.
If one is found, it is removed from the tree, and its parent node is
returned. Otherwise, NULL is returned. */
extern void * tdelete (const void *key, void **vrootp,
- int (*compar) (const void *, const void *));
+ int (*compar) (const void *, const void *))
+ _GL_ARG_NONNULL ((1, 2, 3));
/* Perform a depth-first, left-to-right traversal of the tree VROOT.
The ACTION function is called:
@@ -90,7 +95,8 @@ extern void * tdelete (const void *key, void **vrootp,
2. an indicator which visit of the node this is,
3. the level of the node in the tree (0 for the root). */
extern void twalk (const void *vroot,
- void (*action) (const void *, VISIT, int));
+ void (*action) (const void *, VISIT, int))
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
diff --git a/lib/setenv.c b/lib/setenv.c
index 5ad22c5c10..93a5ef94d8 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -17,6 +17,11 @@
#if !_LIBC
# include <config.h>
#endif
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the name == NULL test below. */
+#define _GL_ARG_NONNULL(params)
+
#include <alloca.h>
/* Specification. */
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 5c42fe9e26..3a957cd83e 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -37,6 +37,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Define pid_t, uid_t.
Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. */
#include <sys/types.h>
@@ -82,22 +84,22 @@ typedef unsigned int sigset_t;
# endif
/* Test whether a given signal is contained in a signal set. */
-extern int sigismember (const sigset_t *set, int sig);
+extern int sigismember (const sigset_t *set, int sig) _GL_ARG_NONNULL ((1));
/* Initialize a signal set to the empty set. */
-extern int sigemptyset (sigset_t *set);
+extern int sigemptyset (sigset_t *set) _GL_ARG_NONNULL ((1));
/* Add a signal to a signal set. */
-extern int sigaddset (sigset_t *set, int sig);
+extern int sigaddset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1));
/* Remove a signal from a signal set. */
-extern int sigdelset (sigset_t *set, int sig);
+extern int sigdelset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1));
/* Fill a signal set with all possible signals. */
-extern int sigfillset (sigset_t *set);
+extern int sigfillset (sigset_t *set) _GL_ARG_NONNULL ((1));
/* Return the set of those blocked signals that are pending. */
-extern int sigpending (sigset_t *set);
+extern int sigpending (sigset_t *set) _GL_ARG_NONNULL ((1));
/* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
Then, if SET is not NULL, affect the current set of blocked signals by
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
index f1155ceaf9..61c82aebb7 100644
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -1,5 +1,5 @@
/* Definitions for POSIX spawn interface.
- Copyright (C) 2000, 2003, 2004, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2003, 2004, 2008-2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -67,6 +67,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Data structure to contain attributes for thread creation. */
#if @REPLACE_POSIX_SPAWN@
@@ -147,7 +149,8 @@ extern int posix_spawn (pid_t *_Restrict_ __pid,
const posix_spawn_file_actions_t *_Restrict_ __file_actions,
const posix_spawnattr_t *_Restrict_ __attrp,
char *const argv[_Restrict_arr_],
- char *const envp[_Restrict_arr_]);
+ char *const envp[_Restrict_arr_])
+ _GL_ARG_NONNULL ((2, 5, 6));
# endif
#endif
@@ -163,7 +166,8 @@ extern int posix_spawn (pid_t *_Restrict_ __pid,
extern int posix_spawnp (pid_t *__pid, const char *__file,
const posix_spawn_file_actions_t *__file_actions,
const posix_spawnattr_t *__attrp,
- char *const argv[], char *const envp[]);
+ char *const argv[], char *const envp[])
+ _GL_ARG_NONNULL ((2, 5, 6));
# endif
#endif
@@ -174,7 +178,8 @@ extern int posix_spawnp (pid_t *__pid, const char *__file,
# define posix_spawnattr_init rpl_posix_spawnattr_init
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
-extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
+extern int posix_spawnattr_init (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -184,7 +189,8 @@ extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
# define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
-extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
+extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -197,7 +203,7 @@ extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t *_Restrict_ __attr,
sigset_t *_Restrict_ __sigdefault)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -209,7 +215,7 @@ extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t *_Restrict_ __
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *_Restrict_ __attr,
const sigset_t *_Restrict_ __sigdefault)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -220,7 +226,8 @@ extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *_Restrict_ __attr,
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *_Restrict_ __attr,
- sigset_t *_Restrict_ __sigmask) __THROW;
+ sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -232,7 +239,7 @@ extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *_Restrict_ __att
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_setsigmask (posix_spawnattr_t *_Restrict_ __attr,
const sigset_t *_Restrict_ __sigmask)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -243,7 +250,8 @@ extern int posix_spawnattr_setsigmask (posix_spawnattr_t *_Restrict_ __attr,
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_getflags (const posix_spawnattr_t *_Restrict_ __attr,
- short int *_Restrict_ __flags) __THROW;
+ short int *_Restrict_ __flags)
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -254,7 +262,8 @@ extern int posix_spawnattr_getflags (const posix_spawnattr_t *_Restrict_ __attr,
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_setflags (posix_spawnattr_t *__attr,
- short int __flags) __THROW;
+ short int __flags)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -266,7 +275,7 @@ extern int posix_spawnattr_setflags (posix_spawnattr_t *__attr,
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *_Restrict_ __attr,
pid_t *_Restrict_ __pgroup)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -277,7 +286,8 @@ extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *_Restrict_ __attr
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
- pid_t __pgroup) __THROW;
+ pid_t __pgroup)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -289,7 +299,7 @@ extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *_Restrict_ __attr,
int *_Restrict_ __schedpolicy)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -300,7 +310,8 @@ extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *_Restrict_ _
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
- int __schedpolicy) __THROW;
+ int __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -311,7 +322,8 @@ extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *_Restrict_ __attr,
- struct sched_param *_Restrict_ __schedparam) __THROW;
+ struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -322,7 +334,8 @@ extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *_Restrict_ __
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawnattr_setschedparam (posix_spawnattr_t *_Restrict_ __attr,
- const struct sched_param *_Restrict_ __schedparam) __THROW;
+ const struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -333,7 +346,8 @@ extern int posix_spawnattr_setschedparam (posix_spawnattr_t *_Restrict_ __attr,
# define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
-extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *__file_actions) __THROW;
+extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -343,7 +357,8 @@ extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *__file_act
# define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
-extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *__file_actions) __THROW;
+extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -358,7 +373,7 @@ extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *_Restri
int __fd,
const char *_Restrict_ __path,
int __oflag, mode_t __mode)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1, 3));
# endif
#endif
@@ -371,7 +386,7 @@ extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *_Restri
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *__file_actions,
int __fd)
- __THROW;
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -383,7 +398,8 @@ extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *__file
# endif
# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *__file_actions,
- int __fd, int __newfd) __THROW;
+ int __fd, int __newfd)
+ __THROW _GL_ARG_NONNULL ((1));
# endif
#endif
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 495e5cd8df..0bcf1542b9 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -63,6 +63,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -74,7 +76,7 @@ extern "C" {
# endif
# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
extern int dprintf (int fd, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef dprintf
@@ -88,7 +90,7 @@ extern int dprintf (int fd, const char *format, ...)
# if @REPLACE_FCLOSE@
# define fclose rpl_fclose
/* Close STREAM and its underlying file descriptor. */
-extern int fclose (FILE *stream);
+extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fclose
@@ -123,7 +125,8 @@ extern int fclose (FILE *stream);
# if @REPLACE_FOPEN@
# undef fopen
# define fopen rpl_fopen
-extern FILE * fopen (const char *filename, const char *mode);
+extern FILE * fopen (const char *filename, const char *mode)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fopen
@@ -137,12 +140,14 @@ extern FILE * fopen (const char *filename, const char *mode);
# if @REPLACE_FPRINTF@
# define fprintf rpl_fprintf
extern int fprintf (FILE *fp, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3)))
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define fprintf rpl_fprintf
extern int fprintf (FILE *fp, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3)))
+ _GL_ARG_NONNULL ((1, 2));
#elif defined GNULIB_POSIXCHECK
# undef fprintf
# define fprintf \
@@ -163,7 +168,7 @@ extern int fprintf (FILE *fp, const char *format, ...)
was before the write calls. When discarding pending input, the file
position is advanced to match the end of the previously read input.
Return 0 if successful. Upon error, return -1 and set errno. */
- extern int fpurge (FILE *gl_stream);
+ extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fpurge
@@ -176,20 +181,21 @@ extern int fprintf (FILE *fp, const char *format, ...)
#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fputc
# define fputc rpl_fputc
-extern int fputc (int c, FILE *stream);
+extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
#endif
#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fputs
# define fputs rpl_fputs
-extern int fputs (const char *string, FILE *stream);
+extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_FREOPEN@
# if @REPLACE_FREOPEN@
# undef freopen
# define freopen rpl_freopen
-extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
+extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
+ _GL_ARG_NONNULL ((2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef freopen
@@ -200,7 +206,7 @@ extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
#endif
#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
-extern int rpl_fseek (FILE *fp, long offset, int whence);
+extern int rpl_fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
# undef fseek
# if defined GNULIB_POSIXCHECK
# define fseek(f,o,w) \
@@ -226,7 +232,7 @@ extern int rpl_fseek (FILE *fp, long offset, int whence);
/* Provide fseek, fseeko functions that are aware of a preceding
fflush(), and which detect pipes. */
# define fseeko rpl_fseeko
-extern int fseeko (FILE *fp, off_t offset, int whence);
+extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
# if !@GNULIB_FSEEK@
# undef fseek
# define fseek(f,o,w) \
@@ -245,7 +251,7 @@ extern int fseeko (FILE *fp, off_t offset, int whence);
#endif
#if @GNULIB_FTELL@ && @REPLACE_FTELL@
-extern long rpl_ftell (FILE *fp);
+extern long rpl_ftell (FILE *fp) _GL_ARG_NONNULL ((1));
# undef ftell
# if GNULIB_POSIXCHECK
# define ftell(f) \
@@ -269,7 +275,7 @@ extern long rpl_ftell (FILE *fp);
#if @GNULIB_FTELLO@
# if @REPLACE_FTELLO@
# define ftello rpl_ftello
-extern off_t ftello (FILE *fp);
+extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
# if !@GNULIB_FTELL@
# undef ftell
# define ftell(f) \
@@ -290,7 +296,8 @@ extern off_t ftello (FILE *fp);
#if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fwrite
# define fwrite rpl_fwrite
-extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
+extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
+ _GL_ARG_NONNULL ((1, 4));
#endif
#if @GNULIB_GETDELIM@
@@ -302,7 +309,8 @@ extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
Return the number of bytes read and stored at *LINEPTR (not including the
NUL terminator), or -1 on error or EOF. */
extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
- FILE *stream);
+ FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 4));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getdelim
@@ -324,7 +332,8 @@ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
bytes of space. It is realloc'd as necessary.
Return the number of bytes read and stored at *LINEPTR (not including the
NUL terminator), or -1 on error or EOF. */
-extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
+extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getline
@@ -347,10 +356,10 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
memory allocation error, call obstack_alloc_failed_handler. Upon
other error, return -1. */
extern int obstack_printf (struct obstack *obs, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
extern int obstack_vprintf (struct obstack *obs, const char *format,
va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -374,7 +383,8 @@ extern void perror (const char *string);
# if @REPLACE_POPEN@
# undef popen
# define popen rpl_popen
-extern FILE *popen (const char *cmd, const char *mode);
+extern FILE *popen (const char *cmd, const char *mode)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef popen
@@ -389,13 +399,13 @@ extern FILE *popen (const char *cmd, const char *mode);
/* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__
extern int printf (const char *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
# endif
#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
/* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__
extern int printf (const char *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK
# undef printf
# define printf \
@@ -415,7 +425,7 @@ extern int printf (const char *format, ...)
#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef putc
# define putc rpl_fputc
-extern int putc (int c, FILE *stream);
+extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
#endif
#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
@@ -427,14 +437,14 @@ extern int putchar (int c);
#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef puts
# define puts rpl_puts
-extern int puts (const char *string);
+extern int puts (const char *string) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_REMOVE@
# if @REPLACE_REMOVE@
# undef remove
# define remove rpl_remove
-extern int remove (const char *name);
+extern int remove (const char *name) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef remove
@@ -448,7 +458,8 @@ extern int remove (const char *name);
# if @REPLACE_RENAME@
# undef rename
# define rename rpl_rename
-extern int rename (const char *old_filename, const char *new_filename);
+extern int rename (const char *old_filename, const char *new_filename)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef rename
@@ -464,7 +475,8 @@ extern int rename (const char *old_filename, const char *new_filename);
# define renameat rpl_renameat
# endif
# if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
-extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
+extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
+ _GL_ARG_NONNULL ((2, 4));
# endif
#elif defined GNULIB_POSIXCHECK
# undef renameat
@@ -480,7 +492,8 @@ extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
# endif
# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
extern int snprintf (char *str, size_t size, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 3, 4)));
+ __attribute__ ((__format__ (__printf__, 3, 4)))
+ _GL_ARG_NONNULL ((3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef snprintf
@@ -494,7 +507,8 @@ extern int snprintf (char *str, size_t size, const char *format, ...)
# if @REPLACE_SPRINTF@
# define sprintf rpl_sprintf
extern int sprintf (char *str, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3)))
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef sprintf
@@ -516,9 +530,9 @@ extern int sprintf (char *str, const char *format, ...)
*RESULT and return the number of resulting bytes, excluding the trailing
NUL. Upon memory allocation error, or some other error, return -1. */
extern int asprintf (char **result, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
extern int vasprintf (char **result, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -528,7 +542,7 @@ extern int sprintf (char *str, const char *format, ...)
# endif
# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
extern int vdprintf (int fd, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef vdprintf
@@ -542,12 +556,14 @@ extern int vdprintf (int fd, const char *format, va_list args)
# if @REPLACE_VFPRINTF@
# define vfprintf rpl_vfprintf
extern int vfprintf (FILE *fp, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0)))
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define vfprintf rpl_vfprintf
extern int vfprintf (FILE *fp, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0)))
+ _GL_ARG_NONNULL ((1, 2));
#elif defined GNULIB_POSIXCHECK
# undef vfprintf
# define vfprintf(s,f,a) \
@@ -561,12 +577,12 @@ extern int vfprintf (FILE *fp, const char *format, va_list args)
# if @REPLACE_VPRINTF@
# define vprintf rpl_vprintf
extern int vprintf (const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 1, 0)));
+ __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
# endif
#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define vprintf rpl_vprintf
extern int vprintf (const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 1, 0)));
+ __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK
# undef vprintf
# define vprintf(f,a) \
@@ -582,7 +598,8 @@ extern int vprintf (const char *format, va_list args)
# endif
# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 3, 0)));
+ __attribute__ ((__format__ (__printf__, 3, 0)))
+ _GL_ARG_NONNULL ((3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef vsnprintf
@@ -596,7 +613,8 @@ extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
# if @REPLACE_VSPRINTF@
# define vsprintf rpl_vsprintf
extern int vsprintf (char *str, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0)))
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef vsprintf
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 53d48fccc5..af9c35ea87 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -68,6 +68,8 @@ struct random_data
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
#ifndef EXIT_SUCCESS
@@ -91,7 +93,7 @@ extern "C" {
# if !@HAVE_ATOLL@
/* Parse a signed decimal integer.
Returns the value of the integer. Errors are not detected. */
-extern long long atoll (const char *string);
+extern long long atoll (const char *string) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef atoll
@@ -120,7 +122,7 @@ extern void * calloc (size_t nmemb, size_t size);
# define canonicalize_file_name rpl_canonicalize_file_name
# endif
# if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@
-extern char *canonicalize_file_name (const char *name);
+extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef canonicalize_file_name
@@ -136,7 +138,7 @@ extern char *canonicalize_file_name (const char *name);
The three numbers are the load average of the last 1 minute, the last 5
minutes, and the last 15 minutes, respectively.
LOADAVG is an array of NELEM numbers. */
-extern int getloadavg (double loadavg[], int nelem);
+extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getloadavg
@@ -159,7 +161,8 @@ extern int getloadavg (double loadavg[], int nelem);
For more details see the POSIX:2001 specification.
http://www.opengroup.org/susv3xsh/getsubopt.html */
# if !@HAVE_GETSUBOPT@
-extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
+extern int getsubopt (char **optionp, char *const *tokens, char **valuep)
+ _GL_ARG_NONNULL ((1, 2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getsubopt
@@ -190,7 +193,7 @@ extern void * malloc (size_t size);
they are replaced with a string that makes the directory name unique.
Returns TEMPLATE, or a null pointer if it cannot get a unique name.
The directory is created mode 700. */
-extern char * mkdtemp (char * /*template*/);
+extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkdtemp
@@ -214,7 +217,7 @@ extern char * mkdtemp (char * /*template*/);
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
-extern int mkostemp (char * /*template*/, int /*flags*/);
+extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkostemp
@@ -239,7 +242,8 @@ extern int mkostemp (char * /*template*/, int /*flags*/);
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
-extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
+extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkostemps
@@ -261,7 +265,7 @@ extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
# define mkstemp rpl_mkstemp
-extern int mkstemp (char * /*template*/);
+extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
# else
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
# include <unistd.h>
@@ -286,7 +290,8 @@ extern int mkstemp (char * /*template*/);
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
-extern int mkstemps (char * /*template*/, int /*suffixlen*/);
+extern int mkstemps (char * /*template*/, int /*suffixlen*/)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkstemps
@@ -300,7 +305,7 @@ extern int mkstemps (char * /*template*/, int /*suffixlen*/);
# if @REPLACE_PUTENV@
# undef putenv
# define putenv rpl_putenv
-extern int putenv (char *string);
+extern int putenv (char *string) _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -311,11 +316,15 @@ extern int putenv (char *string);
# define RAND_MAX 2147483647
# endif
-int srandom_r (unsigned int seed, struct random_data *rand_state);
+int srandom_r (unsigned int seed, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2));
int initstate_r (unsigned int seed, char *buf, size_t buf_size,
- struct random_data *rand_state);
-int setstate_r (char *arg_state, struct random_data *rand_state);
-int random_r (struct random_data *buf, int32_t *result);
+ struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2, 4));
+int setstate_r (char *arg_state, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((1, 2));
+int random_r (struct random_data *buf, int32_t *result)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef random_r
@@ -359,7 +368,7 @@ extern void * realloc (void *ptr, size_t size);
# define realpath rpl_realpath
# endif
# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
-extern char *realpath (const char *name, char *resolved);
+extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef realpath
@@ -373,7 +382,7 @@ extern char *realpath (const char *name, char *resolved);
# if !@HAVE_RPMATCH@
/* Test a user response to a question.
Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
-extern int rpmatch (const char *response);
+extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef rpmatch
@@ -391,7 +400,8 @@ extern int rpmatch (const char *response);
# if !@HAVE_SETENV@ || @REPLACE_SETENV@
/* Set NAME to VALUE in the environment.
If REPLACE is nonzero, overwrite an existing value. */
-extern int setenv (const char *name, const char *value, int replace);
+extern int setenv (const char *name, const char *value, int replace)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef setenv
@@ -407,7 +417,7 @@ extern int setenv (const char *name, const char *value, int replace);
# endif
# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
/* Parse a double from STRING, updating ENDP if appropriate. */
-extern double strtod (const char *str, char **endp);
+extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strtod
@@ -427,7 +437,8 @@ extern double strtod (const char *str, char **endp);
stored in *ENDPTR.
Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
to ERANGE. */
-extern long long strtoll (const char *string, char **endptr, int base);
+extern long long strtoll (const char *string, char **endptr, int base)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strtoll
@@ -447,7 +458,8 @@ extern long long strtoll (const char *string, char **endptr, int base);
stored in *ENDPTR.
Upon overflow, the return value is ULLONG_MAX, and errno is set to
ERANGE. */
-extern unsigned long long strtoull (const char *string, char **endptr, int base);
+extern unsigned long long strtoull (const char *string, char **endptr, int base)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strtoull
@@ -464,7 +476,7 @@ extern unsigned long long strtoull (const char *string, char **endptr, int base)
# endif
# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
/* Remove the variable NAME from the environment. */
-extern int unsetenv (const char *name);
+extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef unsetenv
diff --git a/lib/string.in.h b/lib/string.in.h
index 05669db164..cf117f6eb7 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -45,6 +45,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -56,7 +58,7 @@ extern "C" {
# if @REPLACE_MEMCHR@
# define memchr rpl_memchr
extern void *memchr (void const *__s, int __c, size_t __n)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memchr
@@ -74,7 +76,7 @@ extern void *memchr (void const *__s, int __c, size_t __n)
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
extern void *memmem (void const *__haystack, size_t __haystack_len,
void const *__needle, size_t __needle_len)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memmem
@@ -90,7 +92,8 @@ extern void *memmem (void const *__haystack, size_t __haystack_len,
#if @GNULIB_MEMPCPY@
# if ! @HAVE_MEMPCPY@
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
- size_t __n);
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mempcpy
@@ -104,7 +107,7 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src,
#if @GNULIB_MEMRCHR@
# if ! @HAVE_DECL_MEMRCHR@
extern void *memrchr (void const *, int, size_t)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memrchr
@@ -120,7 +123,7 @@ extern void *memrchr (void const *, int, size_t)
#if @GNULIB_RAWMEMCHR@
# if ! @HAVE_RAWMEMCHR@
extern void *rawmemchr (void const *__s, int __c_in)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef rawmemchr
@@ -133,7 +136,8 @@ extern void *rawmemchr (void const *__s, int __c_in)
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
#if @GNULIB_STPCPY@
# if ! @HAVE_STPCPY@
-extern char *stpcpy (char *restrict __dst, char const *restrict __src);
+extern char *stpcpy (char *restrict __dst, char const *restrict __src)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef stpcpy
@@ -149,7 +153,8 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src);
# if ! @HAVE_STPNCPY@
# define stpncpy gnu_stpncpy
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
- size_t __n);
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef stpncpy
@@ -174,7 +179,7 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
#if @GNULIB_STRCHRNUL@
# if ! @HAVE_STRCHRNUL@
extern char *strchrnul (char const *__s, int __c_in)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strchrnul
@@ -191,7 +196,7 @@ extern char *strchrnul (char const *__s, int __c_in)
# define strdup rpl_strdup
# endif
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
-extern char *strdup (char const *__s);
+extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strdup
@@ -208,7 +213,7 @@ extern char *strdup (char const *__s);
# define strndup rpl_strndup
# endif
# if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
-extern char *strndup (char const *__string, size_t __n);
+extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strndup
@@ -224,7 +229,7 @@ extern char *strndup (char const *__string, size_t __n);
#if @GNULIB_STRNLEN@
# if ! @HAVE_DECL_STRNLEN@
extern size_t strnlen (char const *__string, size_t __maxlen)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strnlen
@@ -251,7 +256,7 @@ extern size_t strnlen (char const *__string, size_t __maxlen)
#if @GNULIB_STRPBRK@
# if ! @HAVE_STRPBRK@
extern char *strpbrk (char const *__s, char const *__accept)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif
# if defined GNULIB_POSIXCHECK
/* strpbrk() assumes the second argument is a list of single-byte characters.
@@ -313,7 +318,8 @@ extern char *strpbrk (char const *__s, char const *__accept)
See also strtok_r(). */
#if @GNULIB_STRSEP@
# if ! @HAVE_STRSEP@
-extern char *strsep (char **restrict __stringp, char const *restrict __delim);
+extern char *strsep (char **restrict __stringp, char const *restrict __delim)
+ _GL_ARG_NONNULL ((1, 2));
# endif
# if defined GNULIB_POSIXCHECK
# undef strsep
@@ -334,8 +340,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
#if @GNULIB_STRSTR@
# if @REPLACE_STRSTR@
# define strstr rpl_strstr
-char *strstr (const char *haystack, const char *needle)
- __attribute__ ((__pure__));
+extern char *strstr (const char *haystack, const char *needle)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
/* strstr() does not work with multibyte strings if the locale encoding is
@@ -360,7 +366,7 @@ char *strstr (const char *haystack, const char *needle)
# endif
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
extern char *strcasestr (const char *haystack, const char *needle)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
/* strcasestr() does not work with multibyte strings:
@@ -407,7 +413,8 @@ extern char *strcasestr (const char *haystack, const char *needle)
# endif
# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
extern char *strtok_r (char *restrict s, char const *restrict delim,
- char **restrict save_ptr);
+ char **restrict save_ptr)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# if defined GNULIB_POSIXCHECK
# undef strtok_r
@@ -432,13 +439,13 @@ extern char *strtok_r (char *restrict s, char const *restrict delim,
#if @GNULIB_MBSLEN@
/* Return the number of multibyte characters in the character string STRING.
This considers multibyte characters, unlike strlen, which counts bytes. */
-extern size_t mbslen (const char *string);
+extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_MBSNLEN@
/* Return the number of multibyte characters in the character string starting
at STRING and ending at STRING + LEN. */
-extern size_t mbsnlen (const char *string, size_t len);
+extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_MBSCHR@
@@ -447,7 +454,7 @@ extern size_t mbsnlen (const char *string, size_t len);
Unlike strchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */
# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
-extern char * mbschr (const char *string, int c);
+extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_MBSRCHR@
@@ -456,7 +463,7 @@ extern char * mbschr (const char *string, int c);
Unlike strrchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */
# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
-extern char * mbsrchr (const char *string, int c);
+extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_MBSSTR@
@@ -464,7 +471,8 @@ extern char * mbsrchr (const char *string, int c);
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
Unlike strstr(), this function works correctly in multibyte locales with
encodings different from UTF-8. */
-extern char * mbsstr (const char *haystack, const char *needle);
+extern char * mbsstr (const char *haystack, const char *needle)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSCASECMP@
@@ -474,7 +482,8 @@ extern char * mbsstr (const char *haystack, const char *needle);
Note: This function may, in multibyte locales, return 0 for strings of
different lengths!
Unlike strcasecmp(), this function works correctly in multibyte locales. */
-extern int mbscasecmp (const char *s1, const char *s2);
+extern int mbscasecmp (const char *s1, const char *s2)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSNCASECMP@
@@ -487,7 +496,8 @@ extern int mbscasecmp (const char *s1, const char *s2);
of different lengths!
Unlike strncasecmp(), this function works correctly in multibyte locales.
But beware that N is not a byte count but a character count! */
-extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
+extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSPCASECMP@
@@ -500,7 +510,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
smaller length than PREFIX!
Unlike strncasecmp(), this function works correctly in multibyte
locales. */
-extern char * mbspcasecmp (const char *string, const char *prefix);
+extern char * mbspcasecmp (const char *string, const char *prefix)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSCASESTR@
@@ -509,7 +520,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix);
Note: This function may, in multibyte locales, return success even if
strlen (haystack) < strlen (needle) !
Unlike strcasestr(), this function works correctly in multibyte locales. */
-extern char * mbscasestr (const char *haystack, const char *needle);
+extern char * mbscasestr (const char *haystack, const char *needle)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSCSPN@
@@ -518,7 +530,8 @@ extern char * mbscasestr (const char *haystack, const char *needle);
beginning of the string to this occurrence, or to the end of the string
if none exists.
Unlike strcspn(), this function works correctly in multibyte locales. */
-extern size_t mbscspn (const char *string, const char *accept);
+extern size_t mbscspn (const char *string, const char *accept)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSPBRK@
@@ -527,7 +540,8 @@ extern size_t mbscspn (const char *string, const char *accept);
exists.
Unlike strpbrk(), this function works correctly in multibyte locales. */
# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
-extern char * mbspbrk (const char *string, const char *accept);
+extern char * mbspbrk (const char *string, const char *accept)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSSPN@
@@ -536,7 +550,8 @@ extern char * mbspbrk (const char *string, const char *accept);
beginning of the string to this occurrence, or to the end of the string
if none exists.
Unlike strspn(), this function works correctly in multibyte locales. */
-extern size_t mbsspn (const char *string, const char *reject);
+extern size_t mbsspn (const char *string, const char *reject)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSSEP@
@@ -554,7 +569,8 @@ extern size_t mbsspn (const char *string, const char *reject);
Caveat: The identity of the delimiting character is lost.
See also mbstok_r(). */
-extern char * mbssep (char **stringp, const char *delim);
+extern char * mbssep (char **stringp, const char *delim)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if @GNULIB_MBSTOK_R@
@@ -574,7 +590,8 @@ extern char * mbssep (char **stringp, const char *delim);
Caveat: The identity of the delimiting character is lost.
See also mbssep(). */
-extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
+extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
+ _GL_ARG_NONNULL ((2, 3));
#endif
/* Map any int, typically from errno, into an error message. */
@@ -609,7 +626,7 @@ extern char *strsignal (int __sig);
#if @GNULIB_STRVERSCMP@
# if !@HAVE_STRVERSCMP@
-extern int strverscmp (const char *, const char *);
+extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strverscmp
diff --git a/lib/strings.in.h b/lib/strings.in.h
index 0c87af2108..205bb364fc 100644
--- a/lib/strings.in.h
+++ b/lib/strings.in.h
@@ -1,6 +1,6 @@
/* A substitute <strings.h>.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,6 +31,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -42,7 +44,8 @@ extern "C" {
than S2.
Note: This function does not work in multibyte locales. */
#if ! @HAVE_STRCASECMP@
-extern int strcasecmp (char const *s1, char const *s2);
+extern int strcasecmp (char const *s1, char const *s2)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if defined GNULIB_POSIXCHECK
/* strcasecmp() does not work with multibyte strings:
@@ -64,7 +67,8 @@ extern int strcasecmp (char const *s1, char const *s2);
lexicographically less than, equal to or greater than S2.
Note: This function cannot work correctly in multibyte locales. */
#if ! @HAVE_DECL_STRNCASECMP@
-extern int strncasecmp (char const *s1, char const *s2, size_t n);
+extern int strncasecmp (char const *s1, char const *s2, size_t n)
+ _GL_ARG_NONNULL ((1, 2));
#endif
#if defined GNULIB_POSIXCHECK
/* strncasecmp() does not work with multibyte strings:
diff --git a/lib/strtod.c b/lib/strtod.c
index 853ca1cb20..b43a9039ae 100644
--- a/lib/strtod.c
+++ b/lib/strtod.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1997, 1999, 2003, 2006, 2008 Free
+/* Copyright (C) 1991-1992, 1997, 1999, 2003, 2006, 2008-2009 Free
Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -16,6 +16,10 @@
#include <config.h>
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the nptr == NULL test below. */
+#define _GL_ARG_NONNULL(params)
+
#include <stdlib.h>
#include <ctype.h>
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index c94ce172fe..82ea2e90d0 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -43,6 +43,8 @@
#ifndef _GL_SYS_SOCKET_H
#define _GL_SYS_SOCKET_H
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#if !@HAVE_SA_FAMILY_T@
typedef unsigned short sa_family_t;
#endif
@@ -195,7 +197,7 @@ extern int rpl_socket (int, int, int protocol);
# if @HAVE_WINSOCK2_H@
# undef connect
# define connect rpl_connect
-extern int rpl_connect (int, struct sockaddr *, int);
+extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef connect
@@ -229,7 +231,7 @@ extern int rpl_accept (int, struct sockaddr *, int *);
# if @HAVE_WINSOCK2_H@
# undef bind
# define bind rpl_bind
-extern int rpl_bind (int, struct sockaddr *, int);
+extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef bind
@@ -246,7 +248,8 @@ extern int rpl_bind (int, struct sockaddr *, int);
# if @HAVE_WINSOCK2_H@
# undef getpeername
# define getpeername rpl_getpeername
-extern int rpl_getpeername (int, struct sockaddr *, int *);
+extern int rpl_getpeername (int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getpeername
@@ -263,7 +266,8 @@ extern int rpl_getpeername (int, struct sockaddr *, int *);
# if @HAVE_WINSOCK2_H@
# undef getsockname
# define getsockname rpl_getsockname
-extern int rpl_getsockname (int, struct sockaddr *, int *);
+extern int rpl_getsockname (int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getsockname
@@ -280,7 +284,8 @@ extern int rpl_getsockname (int, struct sockaddr *, int *);
# if @HAVE_WINSOCK2_H@
# undef getsockopt
# define getsockopt rpl_getsockopt
-extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
+extern int rpl_getsockopt (int, int, int, void *, socklen_t *)
+ _GL_ARG_NONNULL ((4, 5));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getsockopt
@@ -314,7 +319,7 @@ extern int rpl_listen (int, int);
# if @HAVE_WINSOCK2_H@
# undef recv
# define recv rpl_recv
-extern int rpl_recv (int, void *, int, int);
+extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef recv
@@ -331,7 +336,7 @@ extern int rpl_recv (int, void *, int, int);
# if @HAVE_WINSOCK2_H@
# undef send
# define send rpl_send
-extern int rpl_send (int, const void *, int, int);
+extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef send
@@ -348,7 +353,8 @@ extern int rpl_send (int, const void *, int, int);
# if @HAVE_WINSOCK2_H@
# undef recvfrom
# define recvfrom rpl_recvfrom
-extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
+extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef recvfrom
@@ -365,7 +371,8 @@ extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
# if @HAVE_WINSOCK2_H@
# undef sendto
# define sendto rpl_sendto
-extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
+extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int)
+ _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef sendto
@@ -382,7 +389,8 @@ extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
# if @HAVE_WINSOCK2_H@
# undef setsockopt
# define setsockopt rpl_setsockopt
-extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
+extern int rpl_setsockopt (int, int, int, const void *, socklen_t)
+ _GL_ARG_NONNULL ((4));
# endif
# elif @HAVE_WINSOCK2_H@
# undef setsockopt
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 48d7fc1bbf..054630d395 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -49,6 +49,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). */
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
@@ -295,7 +297,8 @@ extern "C" {
#if @GNULIB_FCHMODAT@
# if !@HAVE_FCHMODAT@
-extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
+extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fchmodat
@@ -308,7 +311,7 @@ extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
#if @REPLACE_FSTAT@
# define fstat rpl_fstat
-extern int fstat (int fd, struct stat *buf);
+extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
#endif
@@ -318,7 +321,8 @@ extern int fstat (int fd, struct stat *buf);
# define fstatat rpl_fstatat
# endif
# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
-extern int fstatat (int fd, char const *name, struct stat *st, int flags);
+extern int fstatat (int fd, char const *name, struct stat *st, int flags)
+ _GL_ARG_NONNULL ((2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fstatat
@@ -360,7 +364,7 @@ extern int futimens (int fd, struct timespec const times[2]);
# define lchmod chmod
# endif
# if 0 /* assume already declared */
-extern int lchmod (const char *filename, mode_t mode);
+extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef lchmod
@@ -379,7 +383,8 @@ extern int lchmod (const char *filename, mode_t mode);
# elif @REPLACE_LSTAT@
# undef lstat
# define lstat rpl_lstat
-extern int rpl_lstat (const char *name, struct stat *buf);
+extern int rpl_lstat (const char *name, struct stat *buf)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef lstat
@@ -393,7 +398,7 @@ extern int rpl_lstat (const char *name, struct stat *buf);
#if @REPLACE_MKDIR@
# undef mkdir
# define mkdir rpl_mkdir
-extern int mkdir (char const *name, mode_t mode);
+extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
#else
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Additionally, it declares _mkdir (and depending on compile flags, an
@@ -413,7 +418,8 @@ rpl_mkdir (char const *name, mode_t mode)
#if @GNULIB_MKDIRAT@
# if !@HAVE_MKDIRAT@
-extern int mkdirat (int fd, char const *file, mode_t mode);
+extern int mkdirat (int fd, char const *file, mode_t mode)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkdirat
@@ -430,7 +436,7 @@ extern int mkdirat (int fd, char const *file, mode_t mode);
# define mkfifo rpl_mkfifo
# endif
# if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
-int mkfifo (char const *file, mode_t mode);
+extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkfifo
@@ -443,7 +449,8 @@ int mkfifo (char const *file, mode_t mode);
#if @GNULIB_MKFIFOAT@
# if !@HAVE_MKFIFOAT@
-int mkfifoat (int fd, char const *file, mode_t mode);
+extern int mkfifoat (int fd, char const *file, mode_t mode)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkfifoat
@@ -460,7 +467,8 @@ int mkfifoat (int fd, char const *file, mode_t mode);
# define mknod rpl_mknod
# endif
# if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
-int mknod (char const *file, mode_t mode, dev_t dev);
+extern int mknod (char const *file, mode_t mode, dev_t dev)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mknod
@@ -473,7 +481,8 @@ int mknod (char const *file, mode_t mode, dev_t dev);
#if @GNULIB_MKNODAT@
# if !@HAVE_MKNODAT@
-int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
+extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mknodat
@@ -499,7 +508,7 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
# else /* !_LARGE_FILES */
# define stat(name, st) rpl_stat (name, st)
# endif /* !_LARGE_FILES */
-extern int stat (const char *name, struct stat *buf);
+extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef stat
@@ -517,7 +526,8 @@ extern int stat (const char *name, struct stat *buf);
# endif
# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
extern int utimensat (int fd, char const *name,
- struct timespec const times[2], int flag);
+ struct timespec const times[2], int flag)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef utimensat
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index d9fb361b87..d5cb7ce3b7 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -1,6 +1,6 @@
/* Provide a more complete sys/time.h.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -39,6 +39,8 @@
# include <time.h>
# endif
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -54,7 +56,8 @@ struct timeval
# if @REPLACE_GETTIMEOFDAY@
# undef gettimeofday
# define gettimeofday rpl_gettimeofday
-int gettimeofday (struct timeval *restrict, void *restrict);
+extern int gettimeofday (struct timeval *restrict, void *restrict)
+ _GL_ARG_NONNULL ((1));
# endif
#ifdef __cplusplus
diff --git a/lib/sys_times.in.h b/lib/sys_times.in.h
index 381d7de565..2af1e58a3a 100644
--- a/lib/sys_times.in.h
+++ b/lib/sys_times.in.h
@@ -1,5 +1,5 @@
/* Provide a sys/times.h header file.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,6 +28,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
# ifdef __cplusplus
extern "C" {
# endif
@@ -43,7 +45,7 @@ extern "C" {
};
# if @GNULIB_TIMES@
- extern clock_t times (struct tms *buffer);
+ extern clock_t times (struct tms *buffer) _GL_ARG_NONNULL ((1));
# elif defined GNULIB_POSIXCHECK
# undef times
# define times(s) \
diff --git a/lib/sys_utsname.in.h b/lib/sys_utsname.in.h
index f8bc0f7eef..2a263485ce 100644
--- a/lib/sys_utsname.in.h
+++ b/lib/sys_utsname.in.h
@@ -20,6 +20,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
@@ -65,7 +67,7 @@ struct utsname
#if @GNULIB_UNAME@
# if !@HAVE_UNAME@
-extern int uname (struct utsname *buf);
+extern int uname (struct utsname *buf) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef uname
diff --git a/lib/time.in.h b/lib/time.in.h
index 4f44bb08a3..84ccfb9965 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -40,6 +40,8 @@
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
# ifdef __cplusplus
extern "C" {
# endif
@@ -66,13 +68,14 @@ struct timespec
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
# if @REPLACE_NANOSLEEP@
# define nanosleep rpl_nanosleep
-int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
+extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
+ _GL_ARG_NONNULL ((1));
# endif
/* Return the 'time_t' representation of TP and normalize TP. */
# if @REPLACE_MKTIME@
# define mktime rpl_mktime
-extern time_t mktime (struct tm *__tp);
+extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
@@ -83,10 +86,12 @@ extern time_t mktime (struct tm *__tp);
# define localtime_r rpl_localtime_r
# undef gmtime_r
# define gmtime_r rpl_gmtime_r
-struct tm *localtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
-struct tm *gmtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
+extern struct tm *localtime_r (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2));
+extern struct tm *gmtime_r (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2));
# endif
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
@@ -95,15 +100,17 @@ struct tm *gmtime_r (time_t const *restrict __timer,
# if @REPLACE_STRPTIME@
# undef strptime
# define strptime rpl_strptime
-char *strptime (char const *restrict __buf, char const *restrict __format,
- struct tm *restrict __tm);
+extern char *strptime (char const *restrict __buf,
+ char const *restrict __format,
+ struct tm *restrict __tm)
+ _GL_ARG_NONNULL ((1, 2, 3));
# endif
/* Convert TM to a time_t value, assuming UTC. */
# if @REPLACE_TIMEGM@
# undef timegm
# define timegm rpl_timegm
-time_t timegm (struct tm *__tm);
+extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
# endif
/* Encourage applications to avoid unsafe functions that can overrun
diff --git a/lib/tsearch.c b/lib/tsearch.c
index a2e053aa53..44b0d329f0 100644
--- a/lib/tsearch.c
+++ b/lib/tsearch.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1997, 2000, 2006-2007 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1997, 2000, 2006-2007, 2009 Free Software Foundation, Inc.
Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997.
NOTE: The canonical source of this file is maintained with the GNU C
@@ -86,6 +86,10 @@
#include <config.h>
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the rootp == NULL tests below. */
+#define _GL_ARG_NONNULL(params)
+
/* Specification. */
#ifdef IN_LIBINTL
# include "tsearch.h"
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index bc2410e9fc..0cf9a87aa7 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -96,6 +96,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* OS/2 EMX lacks these macros. */
#ifndef STDIN_FILENO
@@ -135,7 +137,8 @@ extern "C" {
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/chown.html>. */
-extern int chown (const char *file, uid_t uid, gid_t gid);
+extern int chown (const char *file, uid_t uid, gid_t gid)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef chown
@@ -239,7 +242,7 @@ extern char **environ;
# if !@HAVE_EUIDACCESS@
/* Like access(), except that it uses the effective user id and group id of
the current process. */
-extern int euidaccess (const char *filename, int mode);
+extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef euidaccess
@@ -252,7 +255,8 @@ extern int euidaccess (const char *filename, int mode);
#if @GNULIB_FACCESSAT@
# if !@HAVE_FACCESSAT@
-int faccessat (int fd, char const *file, int mode, int flag);
+extern int faccessat (int fd, char const *file, int mode, int flag)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef faccessat
@@ -273,7 +277,8 @@ int faccessat (int fd, char const *file, int mode, int flag);
extern int fchdir (int /*fd*/);
/* Gnulib internal hooks needed to maintain the fchdir metadata. */
-extern int _gl_register_fd (int fd, const char *filename);
+extern int _gl_register_fd (int fd, const char *filename)
+ _GL_ARG_NONNULL ((2));
extern void _gl_unregister_fd (int fd);
extern int _gl_register_dup (int oldfd, int newfd);
extern const char *_gl_directory_name (int fd);
@@ -294,7 +299,8 @@ extern const char *_gl_directory_name (int fd);
# define fchownat rpl_fchownat
# endif
# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
-extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
+extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fchownat
@@ -378,7 +384,7 @@ extern char * getcwd (char *buf, size_t size);
If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
Return 0 if successful, otherwise set errno and return -1. */
# if !@HAVE_GETDOMAINNAME@
-extern int getdomainname(char *name, size_t len);
+extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getdomainname
@@ -439,7 +445,7 @@ int getgroups (int n, gid_t *groups);
# define gethostname rpl_gethostname
# endif
# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
-extern int gethostname(char *name, size_t len);
+extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
# endif
#elif @UNISTD_H_HAVE_WINSOCK2_H@
# undef gethostname
@@ -464,7 +470,7 @@ extern int gethostname(char *name, size_t len);
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
*/
# if !@HAVE_DECL_GETLOGIN_R@
-extern int getlogin_r (char *name, size_t size);
+extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getlogin_r
@@ -574,7 +580,8 @@ extern void endusershell (void);
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/lchown.html>. */
-extern int lchown (char const *file, uid_t owner, gid_t group);
+extern int lchown (char const *file, uid_t owner, gid_t group)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef lchown
@@ -594,7 +601,8 @@ extern int lchown (char const *file, uid_t owner, gid_t group);
See POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/link.html>. */
# if !@HAVE_LINK@ || @REPLACE_LINK@
-extern int link (const char *path1, const char *path2);
+extern int link (const char *path1, const char *path2)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef link
@@ -614,7 +622,8 @@ extern int link (const char *path1, const char *path2);
Return 0 if successful, otherwise -1 and errno set. */
# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
- int flag);
+ int flag)
+ _GL_ARG_NONNULL ((2, 4));
# endif
#elif defined GNULIB_POSIXCHECK
# undef linkat
@@ -654,7 +663,7 @@ extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
# if @HAVE_PIPE2@
# define pipe2 rpl_pipe2
# endif
-extern int pipe2 (int fd[2], int flags);
+extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK
# undef pipe2
# define pipe2(f,o) \
@@ -673,7 +682,8 @@ extern int pipe2 (int fd[2], int flags);
set errno and return -1. 0 indicates EOF. See the POSIX:2001
specification <http://www.opengroup.org/susv3xsh/pread.html>. */
# if !@HAVE_PREAD@ || @REPLACE_PREAD@
- extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset);
+ extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef pread
@@ -694,7 +704,8 @@ extern int pipe2 (int fd[2], int flags);
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/readlink.html>. */
# if !@HAVE_READLINK@ || @REPLACE_READLINK@
-extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
+extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef readlink
@@ -707,7 +718,8 @@ extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
#if @GNULIB_READLINKAT@
# if !@HAVE_READLINKAT@
-ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
+extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
+ _GL_ARG_NONNULL ((2, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef readlinkat
@@ -722,7 +734,7 @@ ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
# if @REPLACE_RMDIR@
# define rmdir rpl_rmdir
/* Remove the directory DIR. */
-extern int rmdir (char const *name);
+extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef rmdir
@@ -760,7 +772,8 @@ extern unsigned int sleep (unsigned int n);
# define symlink rpl_symlink
# endif
# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
-int symlink (char const *contents, char const *file);
+extern int symlink (char const *contents, char const *file)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef symlink
@@ -773,7 +786,8 @@ int symlink (char const *contents, char const *file);
#if @GNULIB_SYMLINKAT@
# if !@HAVE_SYMLINKAT@
-int symlinkat (char const *contents, int fd, char const *file);
+extern int symlinkat (char const *contents, int fd, char const *file)
+ _GL_ARG_NONNULL ((1, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef symlinkat
@@ -788,7 +802,7 @@ int symlinkat (char const *contents, int fd, char const *file);
# if @REPLACE_UNLINK@
# undef unlink
# define unlink rpl_unlink
-extern int unlink (char const *file);
+extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef unlink
@@ -805,7 +819,7 @@ extern int unlink (char const *file);
# define unlinkat rpl_unlinkat
# endif
# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
-extern int unlinkat (int fd, char const *file, int flag);
+extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef unlinkat
@@ -843,7 +857,8 @@ extern int usleep (useconds_t n);
<http://www.opengroup.org/susv3xsh/write.html>. */
# undef write
# define write rpl_write
-extern ssize_t write (int fd, const void *buf, size_t count);
+extern ssize_t write (int fd, const void *buf, size_t count)
+ _GL_ARG_NONNULL ((2));
#endif
diff --git a/lib/unsetenv.c b/lib/unsetenv.c
index a2c181acc8..89ce64b6a6 100644
--- a/lib/unsetenv.c
+++ b/lib/unsetenv.c
@@ -16,6 +16,10 @@
#include <config.h>
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the name == NULL test below. */
+#define _GL_ARG_NONNULL(params)
+
/* Specification. */
#include <stdlib.h>
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index ddf8b75352..d7e798b4c2 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -74,6 +74,8 @@
/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -197,7 +199,8 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
# define mbsrtowcs rpl_mbsrtowcs
# endif
# if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
-extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps);
+extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mbsrtowcs
@@ -215,7 +218,8 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t
# define mbsnrtowcs rpl_mbsnrtowcs
# endif
# if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
-extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps);
+extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mbsnrtowcs
@@ -251,7 +255,8 @@ extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
# define wcsrtombs rpl_wcsrtombs
# endif
# if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
-extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps);
+extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef wcsrtombs
@@ -269,7 +274,8 @@ extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t
# define wcsnrtombs rpl_wcsnrtombs
# endif
# if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@
-extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps);
+extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef wcsnrtombs
diff --git a/modules/arg-nonnull b/modules/arg-nonnull
new file mode 100644
index 0000000000..ed224bf7dc
--- /dev/null
+++ b/modules/arg-nonnull
@@ -0,0 +1,31 @@
+Description:
+A C macro for declaring that specific arguments must not be NULL.
+
+Files:
+build-aux/arg-nonnull.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ sed -n -e '/GL_ARG_NONNULL/,$$p' \
+ < $(top_srcdir)/build-aux/arg-nonnull.h \
+ > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+Include:
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
diff --git a/modules/argv-iter b/modules/argv-iter
index e9fc633915..3844b8a807 100644
--- a/modules/argv-iter
+++ b/modules/argv-iter
@@ -6,6 +6,7 @@ lib/argv-iter.c
lib/argv-iter.h
Depends-on:
+arg-nonnull
getdelim
stdbool
diff --git a/modules/arpa_inet b/modules/arpa_inet
index 7eb9cc0567..e76c7e47fa 100644
--- a/modules/arpa_inet
+++ b/modules/arpa_inet
@@ -8,6 +8,7 @@ m4/arpa_inet_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
sys_socket
configure.ac:
@@ -19,7 +20,7 @@ BUILT_SOURCES += $(ARPA_INET_H)
# We need the following in order to create <arpa/inet.h> when the system
# doesn't have one.
-arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H)
+arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) arpa
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -32,6 +33,7 @@ arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H)
-e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
-e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/arpa_inet.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/dirent b/modules/dirent
index 110ec4520a..aed61e4ccd 100644
--- a/modules/dirent
+++ b/modules/dirent
@@ -9,6 +9,7 @@ m4/unistd_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
configure.ac:
gl_DIRENT_H
@@ -18,7 +19,7 @@ BUILT_SOURCES += $(DIRENT_H)
# We need the following in order to create <dirent.h> when the system
# doesn't have one that works with the given compiler.
-dirent.h: dirent.in.h $(LINK_WARNING_H)
+dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -36,6 +37,7 @@ dirent.h: dirent.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
-e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/dirent.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/fcntl-h b/modules/fcntl-h
index eb5cce11dd..6eaec522b3 100644
--- a/modules/fcntl-h
+++ b/modules/fcntl-h
@@ -8,6 +8,7 @@ m4/fcntl_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
unistd
extensions
@@ -19,7 +20,7 @@ BUILT_SOURCES += $(FCNTL_H)
# We need the following in order to create <fcntl.h> when the system
# doesn't have one that works with the given compiler.
-fcntl.h: fcntl.in.h $(LINK_WARNING_H)
+fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -31,6 +32,7 @@ fcntl.h: fcntl.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
-e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/fcntl.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/fnmatch b/modules/fnmatch
index 78344cae8b..6849b4d5e3 100644
--- a/modules/fnmatch
+++ b/modules/fnmatch
@@ -9,6 +9,7 @@ m4/mbstate_t.m4
m4/fnmatch.m4
Depends-on:
+arg-nonnull
extensions
alloca
stdbool
@@ -27,10 +28,11 @@ BUILT_SOURCES += $(FNMATCH_H)
# We need the following in order to create <fnmatch.h> when the system
# doesn't have one that supports the required API.
-fnmatch.h: fnmatch.in.h
+fnmatch.h: fnmatch.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/fnmatch.in.h; \
+ sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ < $(srcdir)/fnmatch.in.h; \
} > $@-t && \
mv -f $@-t $@
MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
diff --git a/modules/getopt-posix b/modules/getopt-posix
index 0a6ee88b0c..63bc6c4e25 100644
--- a/modules/getopt-posix
+++ b/modules/getopt-posix
@@ -13,6 +13,7 @@ gettext-h
unistd
extensions
include_next
+arg-nonnull
configure.ac:
gl_FUNC_GETOPT_POSIX
@@ -22,7 +23,7 @@ BUILT_SOURCES += $(GETOPT_H)
# We need the following in order to create <getopt.h> when the system
# doesn't have one that works with the given compiler.
-getopt.h: getopt.in.h $(LINK_WARNING_H)
+getopt.h: getopt.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
@@ -30,6 +31,7 @@ getopt.h: getopt.in.h $(LINK_WARNING_H)
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/getopt.in.h; \
} > $@-t && \
mv -f $@-t $@
diff --git a/modules/glob b/modules/glob
index c5fd73f470..204ba4886d 100644
--- a/modules/glob
+++ b/modules/glob
@@ -10,6 +10,7 @@ m4/glob.m4
Depends-on:
alloca
+arg-nonnull
d-type
dirfd
extensions
@@ -31,10 +32,11 @@ BUILT_SOURCES += $(GLOB_H)
# We need the following in order to create <glob.h> when the system
# doesn't have one that works with the given compiler.
-glob.h: glob.in.h
+glob.h: glob.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/glob.in.h; \
} > $@-t && \
mv -f $@-t $@
diff --git a/modules/iconv_open b/modules/iconv_open
index c85e660216..ab92f0c8b1 100644
--- a/modules/iconv_open
+++ b/modules/iconv_open
@@ -15,6 +15,7 @@ m4/iconv_open.m4
Depends-on:
gperf
include_next
+arg-nonnull
iconv
c-ctype
c-strcase
@@ -28,7 +29,7 @@ BUILT_SOURCES += $(ICONV_H)
# We need the following in order to create <iconv.h> when the system
# doesn't have one that works with the given compiler.
-iconv.h: iconv.in.h
+iconv.h: iconv.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -38,6 +39,7 @@ iconv.h: iconv.in.h
-e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
-e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
-e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/iconv.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/inttypes b/modules/inttypes
index 8c341f46d0..7a49b77e63 100644
--- a/modules/inttypes
+++ b/modules/inttypes
@@ -9,6 +9,7 @@ m4/inttypes.m4
Depends-on:
include_next
link-warning
+arg-nonnull
multiarch
stdint
@@ -20,7 +21,7 @@ BUILT_SOURCES += $(INTTYPES_H)
# We need the following in order to create <inttypes.h> when the system
# doesn't have one that works with the given compiler.
-inttypes.h: inttypes.in.h $(LINK_WARNING_H)
+inttypes.h: inttypes.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
@@ -45,6 +46,7 @@ inttypes.h: inttypes.in.h $(LINK_WARNING_H)
-e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
-e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/inttypes.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/locale b/modules/locale
index 8b4b3b6562..60d608192a 100644
--- a/modules/locale
+++ b/modules/locale
@@ -7,6 +7,7 @@ m4/locale_h.m4
Depends-on:
include_next
+arg-nonnull
extensions
stddef
@@ -18,7 +19,7 @@ BUILT_SOURCES += $(LOCALE_H)
# We need the following in order to create <locale.h> when the system
# doesn't have one that provides all definitions.
-locale.h: locale.in.h
+locale.h: locale.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -27,6 +28,7 @@ locale.h: locale.in.h
-e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \
-e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
-e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/locale.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/math b/modules/math
index 37a544e546..0e2bc0b27a 100644
--- a/modules/math
+++ b/modules/math
@@ -8,6 +8,7 @@ m4/math_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
configure.ac:
gl_MATH_H
@@ -17,7 +18,7 @@ BUILT_SOURCES += math.h
# We need the following in order to create <math.h> when the system
# doesn't have one that works with the given compiler.
-math.h: math.in.h $(LINK_WARNING_H)
+math.h: math.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
@@ -79,6 +80,7 @@ math.h: math.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
-e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/math.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/netdb b/modules/netdb
index 5672867276..5d9c3758e6 100644
--- a/modules/netdb
+++ b/modules/netdb
@@ -7,6 +7,7 @@ m4/netdb_h.m4
Depends-on:
include_next
+arg-nonnull
sys_socket
configure.ac:
@@ -17,7 +18,7 @@ BUILT_SOURCES += $(NETDB_H)
# We need the following in order to create <netdb.h> when the system
# doesn't have one that works with the given compiler.
-netdb.h: netdb.in.h
+netdb.h: netdb.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -30,6 +31,7 @@ netdb.h: netdb.in.h
-e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
-e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
-e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/netdb.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/search b/modules/search
index f7a58ebf65..9984c29113 100644
--- a/modules/search
+++ b/modules/search
@@ -8,6 +8,7 @@ m4/search_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
configure.ac:
gl_SEARCH_H
@@ -17,7 +18,7 @@ BUILT_SOURCES += search.h
# We need the following in order to create <search.h> when the system
# doesn't have one that works with the given compiler.
-search.h: search.in.h $(LINK_WARNING_H)
+search.h: search.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''HAVE_SEARCH_H''@|$(HAVE_SEARCH_H)|g' \
@@ -28,6 +29,7 @@ search.h: search.in.h $(LINK_WARNING_H)
-e 's|@''HAVE_TSEARCH''@|$(HAVE_TSEARCH)|g' \
-e 's|@''REPLACE_TSEARCH''@|$(REPLACE_TSEARCH)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/search.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/signal b/modules/signal
index 42b543e332..2c1917fa8f 100644
--- a/modules/signal
+++ b/modules/signal
@@ -8,6 +8,7 @@ m4/signal_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
configure.ac:
gl_SIGNAL_H
@@ -17,7 +18,7 @@ BUILT_SOURCES += signal.h
# We need the following in order to create <signal.h> when the system
# doesn't have a complete one.
-signal.h: signal.in.h $(LINK_WARNING_H)
+signal.h: signal.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -33,6 +34,7 @@ signal.h: signal.in.h $(LINK_WARNING_H)
-e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \
-e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/signal.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/spawn b/modules/spawn
index 0fe7f83662..616cc454f8 100644
--- a/modules/spawn
+++ b/modules/spawn
@@ -8,6 +8,7 @@ m4/spawn_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
sched
configure.ac:
@@ -18,7 +19,7 @@ BUILT_SOURCES += $(SPAWN_H)
# We need the following in order to create a replacement for <spawn.h> when
# the system doesn't have one.
-spawn.h: spawn.in.h $(LINK_WARNING_H)
+spawn.h: spawn.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_SPAWN_H''@|$(HAVE_SPAWN_H)|g' \
@@ -49,6 +50,7 @@ spawn.h: spawn.in.h $(LINK_WARNING_H)
-e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \
-e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/spawn.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/stdio b/modules/stdio
index 06e7865ca5..eca35813c7 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -9,6 +9,7 @@ m4/stdio_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
raise
stddef
@@ -20,7 +21,7 @@ BUILT_SOURCES += stdio.h
# We need the following in order to create <stdio.h> when the system
# doesn't have one that works with the given compiler.
-stdio.h: stdio.in.h $(LINK_WARNING_H)
+stdio.h: stdio.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -105,6 +106,7 @@ stdio.h: stdio.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/stdio.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/stdlib b/modules/stdlib
index c272737706..19129cfec7 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -8,6 +8,7 @@ m4/stdlib_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
unistd
stddef
stdint
@@ -20,7 +21,7 @@ BUILT_SOURCES += stdlib.h
# We need the following in order to create <stdlib.h> when the system
# doesn't have one that works with the given compiler.
-stdlib.h: stdlib.in.h $(LINK_WARNING_H)
+stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -77,6 +78,7 @@ stdlib.h: stdlib.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
-e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/stdlib.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/string b/modules/string
index bd9505ec34..d445e3da60 100644
--- a/modules/string
+++ b/modules/string
@@ -9,6 +9,7 @@ Depends-on:
extensions
include_next
link-warning
+arg-nonnull
stddef
configure.ac:
@@ -19,7 +20,7 @@ BUILT_SOURCES += string.h
# We need the following in order to create <string.h> when the system
# doesn't have one that works with the given compiler.
-string.h: string.in.h $(LINK_WARNING_H)
+string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -86,6 +87,7 @@ string.h: string.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/string.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/strings b/modules/strings
index 673d75d34f..33c06088a2 100644
--- a/modules/strings
+++ b/modules/strings
@@ -8,6 +8,7 @@ m4/strings_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
configure.ac:
gl_HEADER_STRINGS_H
@@ -17,7 +18,7 @@ BUILT_SOURCES += strings.h
# We need the following in order to create <strings.h> when the system
# doesn't have one that works with the given compiler.
-strings.h: strings.in.h $(LINK_WARNING_H)
+strings.h: strings.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -26,6 +27,7 @@ strings.h: strings.in.h $(LINK_WARNING_H)
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/strings.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/sys_socket b/modules/sys_socket
index 72d39596f3..b1b9ad27d7 100644
--- a/modules/sys_socket
+++ b/modules/sys_socket
@@ -9,6 +9,7 @@ m4/sockpfaf.m4
Depends-on:
include_next
link-warning
+arg-nonnull
errno
alignof
@@ -21,7 +22,7 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
# We need the following in order to create <sys/socket.h> when the system
# doesn't have one that works with the given compiler.
-sys/socket.h: sys_socket.in.h $(LINK_WARNING_H)
+sys/socket.h: sys_socket.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -51,6 +52,7 @@ sys/socket.h: sys_socket.in.h $(LINK_WARNING_H)
-e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
-e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_socket.in.h; \
} > $@-t && \
mv -f $@-t $@
diff --git a/modules/sys_stat b/modules/sys_stat
index 33ffe4a9a2..7421df67ac 100644
--- a/modules/sys_stat
+++ b/modules/sys_stat
@@ -9,6 +9,7 @@ m4/unistd_h.m4
Depends-on:
include_next
link-warning
+arg-nonnull
time
configure.ac:
@@ -20,7 +21,7 @@ BUILT_SOURCES += sys/stat.h
# We need the following in order to create <sys/stat.h> when the system
# has one that is incomplete.
-sys/stat.h: sys_stat.in.h $(LINK_WARNING_H)
+sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -60,6 +61,7 @@ sys/stat.h: sys_stat.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
-e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_stat.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/sys_time b/modules/sys_time
index 460f046e1d..f0789e5890 100644
--- a/modules/sys_time
+++ b/modules/sys_time
@@ -7,6 +7,7 @@ m4/sys_time_h.m4
Depends-on:
include_next
+arg-nonnull
configure.ac:
gl_HEADER_SYS_TIME_H
@@ -17,7 +18,7 @@ BUILT_SOURCES += $(SYS_TIME_H)
# We need the following in order to create <sys/time.h> when the system
# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h
+sys/time.h: sys_time.in.h $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -27,6 +28,7 @@ sys/time.h: sys_time.in.h
-e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
-e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
-e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_time.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/sys_times b/modules/sys_times
index b8b141d6f1..23af537414 100644
--- a/modules/sys_times
+++ b/modules/sys_times
@@ -7,6 +7,7 @@ m4/sys_times_h.m4
Depends-on:
link-warning
+arg-nonnull
configure.ac:
gl_SYS_TIMES_H
@@ -17,12 +18,13 @@ BUILT_SOURCES += $(SYS_TIMES_H)
# We need the following in order to create <sys/times.h> when the system
# doesn't have one that works with the given compiler.
-sys/times.h: sys_times.in.h $(LINK_WARNING_H)
+sys/times.h: sys_times.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GNULIB_TIMES''@|$(GNULIB_TIMES)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_times.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/sys_utsname b/modules/sys_utsname
index 2bbeb7e0bd..83e337d83f 100644
--- a/modules/sys_utsname
+++ b/modules/sys_utsname
@@ -7,6 +7,7 @@ m4/sys_utsname_h.m4
Depends-on:
link-warning
+arg-nonnull
configure.ac:
gl_SYS_UTSNAME_H
@@ -17,13 +18,14 @@ BUILT_SOURCES += $(SYS_UTSNAME_H)
# We need the following in order to create <sys/utsname.h> when the system
# does not have one.
-sys/utsname.h: sys_utsname.in.h $(LINK_WARNING_H)
+sys/utsname.h: sys_utsname.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GNULIB_UNAME''@|$(GNULIB_UNAME)|g' \
-e 's|@''HAVE_UNAME''@|$(HAVE_UNAME)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_utsname.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/time b/modules/time
index 46a85ec503..ed89cf9bd9 100644
--- a/modules/time
+++ b/modules/time
@@ -8,6 +8,7 @@ m4/time_h.m4
Depends-on:
extensions
include_next
+arg-nonnull
stddef
configure.ac:
@@ -18,7 +19,7 @@ BUILT_SOURCES += time.h
# We need the following in order to create <time.h> when the system
# doesn't have one that works with the given compiler.
-time.h: time.in.h
+time.h: time.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -31,6 +32,7 @@ time.h: time.in.h
-e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
-e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/time.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/unistd b/modules/unistd
index 8e7382d2b4..3ee8f31449 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -8,6 +8,7 @@ lib/unistd.in.h
Depends-on:
include_next
link-warning
+arg-nonnull
stddef
configure.ac:
@@ -18,7 +19,7 @@ BUILT_SOURCES += unistd.h
# We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one.
-unistd.h: unistd.in.h $(LINK_WARNING_H)
+unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@@ -117,6 +118,7 @@ unistd.h: unistd.in.h $(LINK_WARNING_H)
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/unistd.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/modules/wchar b/modules/wchar
index d6dbfd5ef7..eb8615ca9c 100644
--- a/modules/wchar
+++ b/modules/wchar
@@ -9,6 +9,7 @@ m4/wint_t.m4
Depends-on:
include_next
link-warning
+arg-nonnull
stddef
configure.ac:
@@ -19,7 +20,7 @@ BUILT_SOURCES += $(WCHAR_H)
# We need the following in order to create <wchar.h> when the system
# version does not work standalone.
-wchar.h: wchar.in.h $(LINK_WARNING_H)
+wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -62,6 +63,7 @@ wchar.h: wchar.in.h $(LINK_WARNING_H)
-e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/wchar.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/tests/test-canonicalize-lgpl.c b/tests/test-canonicalize-lgpl.c
index 19109d5836..7667983da5 100644
--- a/tests/test-canonicalize-lgpl.c
+++ b/tests/test-canonicalize-lgpl.c
@@ -43,6 +43,12 @@
#define BASE "t-can-lgpl.tmp"
+static void *
+null_ptr (void)
+{
+ return NULL;
+}
+
int
main (void)
{
@@ -75,7 +81,7 @@ main (void)
ASSERT (result == NULL);
ASSERT (errno == ENOENT);
errno = 0;
- result = canonicalize_file_name (NULL);
+ result = canonicalize_file_name (null_ptr ());
ASSERT (result == NULL);
ASSERT (errno == EINVAL);
}
diff --git a/tests/test-canonicalize.c b/tests/test-canonicalize.c
index 749cc1eec1..70b6341de9 100644
--- a/tests/test-canonicalize.c
+++ b/tests/test-canonicalize.c
@@ -44,6 +44,12 @@
#define BASE "t-can.tmp"
+static void *
+null_ptr (void)
+{
+ return NULL;
+}
+
int
main (void)
{
@@ -79,7 +85,7 @@ main (void)
ASSERT (result2 == NULL);
ASSERT (errno == ENOENT);
errno = 0;
- result1 = canonicalize_file_name (NULL);
+ result1 = canonicalize_file_name (null_ptr ());
ASSERT (result1 == NULL);
ASSERT (errno == EINVAL);
errno = 0;
diff --git a/tests/test-memmem.c b/tests/test-memmem.c
index 8f4c28c902..75a2505b7a 100644
--- a/tests/test-memmem.c
+++ b/tests/test-memmem.c
@@ -38,6 +38,12 @@
} \
while (0)
+static void *
+null_ptr (void)
+{
+ return NULL;
+}
+
int
main (int argc, char *argv[])
{
@@ -88,7 +94,7 @@ main (int argc, char *argv[])
{
const char input[] = "foo";
- const char *result = memmem (input, strlen (input), NULL, 0);
+ const char *result = memmem (input, strlen (input), null_ptr (), 0);
ASSERT (result == input);
}