bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] non-null declarations


From: Bruno Haible
Subject: [PATCH] non-null declarations
Date: Thu, 10 Dec 2009 15:36:18 +0100
User-agent: KMail/1.9.9

Hi all,

Here's a proposed patch for introducing some __nonnull__ declarations. For
a start, I'm focusing on gnulib's replacement files lib/*.in.h, because these
declare the most often used functions.

I put __nonnull__ declarations
  1) in places where passing a NULL pointer leads to undefined behaviour,
  2) in places where POSIX says that the function will always fail when a NULL
     pointer is passed. (For example: tsearch.)
glibc uses __nonnull__ declarations only for case 1. But IMO warning also in
case 2 will be more good than bad.

Two points I'm not sure about:
  - Should the macro be called _GL_ARG_NONNULL or GL_ARG_NONNULL?
  - Is it worth putting the macro definition (always the same 10 lines of code)
    into a separate file, like done with link-warning.h?

I could not do anything about lib/argz.in.h, since it's generated by
config/argz.mk.

Opinions? Objections?


2009-12-10  Bruno Haible  <address@hidden>

        Declare which arguments expect non-NULL values, for GCC and clang.
        * lib/arpa_inet.in.h (_GL_ARG_NONNULL): New macro.
        (inet_ntop, inet_pton): Use it.
        * lib/dirent.in.h (_GL_ARG_NONNULL): New macro.
        (closedir, dirfd, opendir, scandir, alphasort): Use it.
        * lib/fcntl.in.h (_GL_ARG_NONNULL): New macro.
        (open, openat): Use it.
        * lib/fnmatch.in.h (_GL_ARG_NONNULL): New macro.
        (fnmatch): Use it.
        * lib/getopt.in.h (_GL_ARG_NONNULL): New macro.
        (getopt, getopt_long, getopt_long_only): Use it.
        * lib/glob.in.h (_GL_ARG_NONNULL): New macro.
        * lib/glob-libc.h (glob, globfree, glob64, globfree64, glob_pattern_p):
        Use it.
        * lib/iconv.in.h (_GL_ARG_NONNULL): New macro.
        (iconv_open): Use it.
        * lib/inttypes.in.h (_GL_ARG_NONNULL): New macro.
        (strtoimax, strtoumax): Use it.
        * lib/locale.in.h (_GL_ARG_NONNULL): New macro.
        (duplocale): Use it.
        * lib/math.in.h (_GL_ARG_NONNULL): New macro.
        (frexp, frexpl): Use it.
        * lib/netdb.in.h (_GL_ARG_NONNULL): New macro.
        (getaddrinfo, freeaddrinfo, getnameinfo): Use it.
        * lib/search.in.h (_GL_ARG_NONNULL): New macro.
        (tsearch, tfind, tdelete, twalk): Use it.
        * lib/signal.in.h (_GL_ARG_NONNULL): New macro.
        (sigismember, sigemptyset, sigaddset, sigdelset, sigfillset,
        sigpending): Use it.
        * lib/spawn.in.h (_GL_ARG_NONNULL): New macro.
        (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 macro.
        (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 macro.
        (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 macro.
        (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 macro.
        (strcasecmp, strncasecmp): Use it.
        * lib/sys_socket.in.h (_GL_ARG_NONNULL): New macro.
        (rpl_connect, rpl_accept, rpl_bind, rpl_getpeername, rpl_getsockname,
        rpl_getsockopt, rpl_recv, rpl_send, rpl_recvfrom, rpl_sendto,
        rpl_setsockopt, accept4): Use it.
        * lib/sys_stat.in.h (_GL_ARG_NONNULL): New macro.
        (fchmodat, fstat, fstatat, futimens, lchmod, rpl_lstat, mkdir, mkdirat,
        mkfifo, mkfifoat, mknod, mknodat, stat, utimensat): Use it.
        * lib/sys_time.in.h (_GL_ARG_NONNULL): New macro.
        (gettimeofday): Use it.
        * lib/sys_times.in.h (_GL_ARG_NONNULL): New macro.
        (times): Use it.
        * lib/sys_utsname.in.h (_GL_ARG_NONNULL): New macro.
        (uname): Use it.
        * lib/time.in.h (_GL_ARG_NONNULL): New macro.
        (nanosleep, mktime, localtime_r, gmtime_r, strptime, timegm): Use it.
        * lib/unistd.in.h (_GL_ARG_NONNULL): New macro.
        (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 macro.
        (mbsrtowcs, mbsnrtowcs, wcsrtombs, wcsnrtombs): Use it.
        * lib/argv-iter.h (_ATTRIBUTE_NONNULL_): Remove macro.
        (_GL_ARG_NONNULL): New macro.
        (argv_iter_init_argv, argv_iter_init_stream, argv_iter,
        argv_iter_n_args, argv_iter_free): Use it.
        Reported by Jim Meyering.

--- lib/arpa_inet.in.h.orig     2009-12-10 14:50:57.000000000 +0100
+++ lib/arpa_inet.in.h  2009-12-10 14:10:01.000000000 +0100
@@ -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,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -60,7 +71,8 @@
    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 +84,8 @@
 
 #if @GNULIB_INET_PTON@
 # if address@hidden@
-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
--- lib/dirent.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/dirent.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -29,6 +29,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -37,14 +49,14 @@
 
 #if @REPLACE_CLOSEDIR@
 # define closedir rpl_closedir
-extern int closedir (DIR *);
+extern int closedir (DIR *) _GL_ARG_NONNULL ((1));
 #endif
 
 #if @GNULIB_DIRFD@
 # if address@hidden@ && !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 +89,7 @@
 
 #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 +100,8 @@
 # if address@hidden@
 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 +114,8 @@
 #if @GNULIB_ALPHASORT@
 /* Compare two 'struct dirent' entries alphabetically.  */
 # if address@hidden@
-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
--- lib/fcntl.in.h.orig 2009-12-10 14:50:57.000000000 +0100
+++ lib/fcntl.in.h      2009-12-10 14:10:01.000000000 +0100
@@ -47,6 +47,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 /* Declare overridden functions.  */
 
 #ifdef __cplusplus
@@ -57,7 +69,7 @@
 # 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 +79,8 @@
 #  define openat rpl_openat
 # endif
 # if address@hidden@ || @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
--- lib/fnmatch.in.h.orig       2009-12-10 14:50:57.000000000 +0100
+++ lib/fnmatch.in.h    2009-12-10 14:10:01.000000000 +0100
@@ -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,17 @@
 #ifndef        _FNMATCH_H
 #define        _FNMATCH_H      1
 
+/* _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 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
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -56,7 +67,8 @@
 /* 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
 }
--- lib/getopt.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/getopt.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -121,6 +121,17 @@
 # endif
 #endif
 
+/* _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 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
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -222,17 +233,17 @@
    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
 
--- lib/glob-libc.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/glob-libc.h     2009-12-10 14:10:01.000000000 +0100
@@ -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 @@
 #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 @@
 #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 @@
 
    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
--- lib/glob.in.h.orig  2009-12-10 14:50:57.000000000 +0100
+++ lib/glob.in.h       2009-12-10 14:10:01.000000000 +0100
@@ -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 <address@hidden> & Paul Eggert <address@hidden>
 
@@ -40,6 +40,17 @@
 # define __THROW
 #endif
 
+/* _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 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
+
 #ifndef __size_t
 # define __size_t      size_t
 #endif
--- lib/iconv.in.h.orig 2009-12-10 14:50:57.000000000 +0100
+++ lib/iconv.in.h      2009-12-10 14:10:01.000000000 +0100
@@ -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,17 @@
 #ifndef _GL_ICONV_H
 #define _GL_ICONV_H
 
+/* _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 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
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -37,7 +48,8 @@
 /* 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@
--- lib/inttypes.in.h.orig      2009-12-10 14:50:57.000000000 +0100
+++ lib/inttypes.in.h   2009-12-10 14:10:01.000000000 +0100
@@ -47,6 +47,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 /* 7.8.1 Macros for format specifiers */
 
 #if ! defined __cplusplus || defined __STDC_FORMAT_MACROS
@@ -1066,7 +1077,7 @@
 
 #if @GNULIB_STRTOIMAX@
 # if address@hidden@
-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 +1089,7 @@
 
 #if @GNULIB_STRTOUMAX@
 # if address@hidden@
-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
--- lib/locale.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/locale.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -34,6 +34,17 @@
 # include <xlocale.h>
 #endif
 
+/* _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 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
+
 /* 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 +55,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
--- lib/math.in.h.orig  2009-12-10 14:50:57.000000000 +0100
+++ lib/math.in.h       2009-12-10 14:10:01.000000000 +0100
@@ -31,6 +31,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -74,7 +86,7 @@
 #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 +223,7 @@
 # define frexpl rpl_frexpl
 #endif
 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || address@hidden@
-extern long double frexpl (long double x, int *expptr);
+extern long double frexpl (long double x, int *expptr) _GL_ARG_NONNULL ((2));
 #endif
 #if address@hidden@ && defined GNULIB_POSIXCHECK
 # undef frexpl
--- lib/netdb.in.h.orig 2009-12-10 14:50:57.000000000 +0100
+++ lib/netdb.in.h      2009-12-10 14:15:23.000000000 +0100
@@ -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,17 @@
 /* Get netdb.h definitions such as struct hostent for MinGW.  */
 #include <sys/socket.h>
 
+/* _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 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
+
 /* Declarations for a platform that lacks <netdb.h>, or where it is
    incomplete.  */
 
@@ -141,14 +152,15 @@
 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 address@hidden@
 /* 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 address@hidden@
@@ -165,7 +177,8 @@
 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.  */
--- lib/search.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/search.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -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
@@ -32,6 +32,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -65,18 +77,21 @@
    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 +105,8 @@
      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
--- lib/signal.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/signal.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -37,6 +37,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 /* 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 +93,22 @@
 # 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
--- lib/spawn.in.h.orig 2009-12-10 14:50:57.000000000 +0100
+++ lib/spawn.in.h      2009-12-10 14:10:01.000000000 +0100
@@ -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,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 
 /* Data structure to contain attributes for thread creation.  */
 #if @REPLACE_POSIX_SPAWN@
@@ -147,7 +158,8 @@
                        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 +175,8 @@
 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 +187,8 @@
 #  define posix_spawnattr_init rpl_posix_spawnattr_init
 # endif
 # if address@hidden@ || @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 +198,8 @@
 #  define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
 # endif
 # if address@hidden@ || @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 +212,7 @@
 # if address@hidden@ || @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 +224,7 @@
 # if address@hidden@ || @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 +235,8 @@
 # endif
 # if address@hidden@ || @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 +248,7 @@
 # if address@hidden@ || @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 +259,8 @@
 # endif
 # if address@hidden@ || @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 +271,8 @@
 # endif
 # if address@hidden@ || @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 +284,7 @@
 # if address@hidden@ || @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 +295,8 @@
 # endif
 # if address@hidden@ || @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 +308,7 @@
 # if address@hidden@ || @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 +319,8 @@
 # endif
 # if address@hidden@ || @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 +331,8 @@
 # endif
 # if address@hidden@ || @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 +343,8 @@
 # endif
 # if address@hidden@ || @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 +355,8 @@
 #  define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
 # endif
 # if address@hidden@ || @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 +366,8 @@
 #  define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
 # endif
 # if address@hidden@ || @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 +382,7 @@
                                             int __fd,
                                             const char *_Restrict_ __path,
                                             int __oflag, mode_t __mode)
-     __THROW;
+     __THROW _GL_ARG_NONNULL ((1, 3));
 # endif
 #endif
 
@@ -371,7 +395,7 @@
 # if address@hidden@ || @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 +407,8 @@
 # endif
 # if address@hidden@ || @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
 
--- lib/stdio.in.h.orig 2009-12-10 14:50:57.000000000 +0100
+++ lib/stdio.in.h      2009-12-10 14:10:37.000000000 +0100
@@ -64,6 +64,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -74,7 +86,7 @@
 # endif
 # if @REPLACE_DPRINTF@ || address@hidden@
 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 +100,7 @@
 # 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 +135,8 @@
 # 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 +150,12 @@
 # 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 ((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 ((2));
 #elif defined GNULIB_POSIXCHECK
 # undef fprintf
 # define fprintf \
@@ -163,7 +176,7 @@
      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 +189,21 @@
 #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 ((1, 2, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef freopen
@@ -200,7 +214,7 @@
 #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 +240,7 @@
 /* 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 address@hidden@
 #   undef fseek
 #   define fseek(f,o,w) \
@@ -245,7 +259,7 @@
 #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 +283,7 @@
 #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 address@hidden@
 #   undef ftell
 #   define ftell(f) \
@@ -290,7 +304,8 @@
 #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 +317,7 @@
    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 +339,8 @@
    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 +363,10 @@
      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 +390,8 @@
 # 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 +406,13 @@
 /* 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 +432,7 @@
 #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 +444,14 @@
 #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 +465,8 @@
 # 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 +482,8 @@
 #  define renameat rpl_renameat
 # endif
 # if address@hidden@ || @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 +499,8 @@
 # endif
 # if @REPLACE_SNPRINTF@ || address@hidden@
 extern int snprintf (char *str, size_t size, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 3, 4)));
+       __attribute__ ((__format__ (__printf__, 3, 4)))
+       _GL_ARG_NONNULL ((1, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef snprintf
@@ -494,7 +514,8 @@
 # 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 +537,9 @@
      *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 +549,7 @@
 # endif
 # if @REPLACE_VDPRINTF@ || address@hidden@
 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 +563,14 @@
 # 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 +584,12 @@
 # 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 +605,8 @@
 # endif
 # if @REPLACE_VSNPRINTF@ || address@hidden@
 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 ((1, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef vsnprintf
@@ -596,7 +620,8 @@
 # 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
--- lib/stdlib.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/stdlib.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -69,6 +69,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
 #ifndef EXIT_SUCCESS
 # define EXIT_SUCCESS 0
@@ -91,7 +103,7 @@
 # if address@hidden@
 /* 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 +132,7 @@
 #  define canonicalize_file_name rpl_canonicalize_file_name
 # endif
 # if address@hidden@ || @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 +148,7 @@
    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 +171,8 @@
    For more details see the POSIX:2001 specification.
    http://www.opengroup.org/susv3xsh/getsubopt.html */
 # if address@hidden@
-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 +203,7 @@
    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 +227,7 @@
    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 +252,8 @@
    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 +275,7 @@
    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 +300,8 @@
    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 +315,7 @@
 # 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 +326,14 @@
 #   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 +377,7 @@
 #  define realpath rpl_realpath
 # endif
 # if address@hidden@ || @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 +391,7 @@
 # if address@hidden@
 /* 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 +409,8 @@
 # if address@hidden@ || @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 +426,7 @@
 # endif
 # if address@hidden@ || @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 +446,8 @@
    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 +467,8 @@
    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 +485,7 @@
 # endif
 # if address@hidden@ || @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
--- lib/string.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/string.in.h     2009-12-10 14:30:04.000000000 +0100
@@ -46,6 +46,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -56,7 +68,7 @@
 # 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 +86,7 @@
 # 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 +102,8 @@
 #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 +117,7 @@
 #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 +133,7 @@
 #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 +146,8 @@
 /* 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 +163,8 @@
 # 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 +189,7 @@
 #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 +206,7 @@
 #  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 +223,7 @@
 #  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 +239,7 @@
 #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 +266,7 @@
 #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 +328,8 @@
    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 +350,8 @@
 #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 +376,7 @@
 # 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 +423,8 @@
 # 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 +449,13 @@
 #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 +464,7 @@
    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 +473,7 @@
    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 +481,8 @@
    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 +492,8 @@
    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 +506,8 @@
    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 +520,8 @@
    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 +530,8 @@
    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 +540,8 @@
    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 +550,8 @@
    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 +560,8 @@
    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 +579,8 @@
    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 +600,8 @@
    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 +636,7 @@
 
 #if @GNULIB_STRVERSCMP@
 # if address@hidden@
-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
--- lib/strings.in.h.orig       2009-12-10 14:50:57.000000000 +0100
+++ lib/strings.in.h    2009-12-10 14:16:13.000000000 +0100
@@ -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
@@ -32,6 +32,18 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* _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 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
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -42,7 +54,8 @@
    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 +77,8 @@
    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:
--- lib/sys_socket.in.h.orig    2009-12-10 14:50:57.000000000 +0100
+++ lib/sys_socket.in.h 2009-12-10 14:10:01.000000000 +0100
@@ -43,6 +43,17 @@
 #ifndef _GL_SYS_SOCKET_H
 #define _GL_SYS_SOCKET_H
 
+/* _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 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
+
 #if address@hidden@
 typedef unsigned short  sa_family_t;
 #endif
@@ -195,7 +206,7 @@
 #  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
@@ -212,7 +223,7 @@
 #  if @HAVE_WINSOCK2_H@
 #   undef accept
 #   define accept              rpl_accept
-extern int rpl_accept (int, struct sockaddr *, int *);
+extern int rpl_accept (int, struct sockaddr *, int *) _GL_ARG_NONNULL ((3));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef accept
@@ -229,7 +240,7 @@
 #  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 +257,8 @@
 #  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 +275,8 @@
 #  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 +293,8 @@
 #  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 +328,7 @@
 #  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 +345,7 @@
 #  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 +362,8 @@
 #  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, 6));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef recvfrom
@@ -365,7 +380,8 @@
 #  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, 5));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef sendto
@@ -382,7 +398,8 @@
 #  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
@@ -437,7 +454,8 @@
 #  define accept4 rpl_accept4
 # endif
 extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
-                   int flags);
+                   int flags)
+     _GL_ARG_NONNULL ((3));
 #elif defined GNULIB_POSIXCHECK
 # undef accept4
 # define accept4(s,a,l,f) \
--- lib/sys_stat.in.h.orig      2009-12-10 14:50:57.000000000 +0100
+++ lib/sys_stat.in.h   2009-12-10 14:10:01.000000000 +0100
@@ -49,6 +49,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 /* 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 +306,8 @@
 
 #if @GNULIB_FCHMODAT@
 # if address@hidden@
-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 +320,7 @@
 
 #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 +330,8 @@
 #  define fstatat rpl_fstatat
 # endif
 # if address@hidden@ || @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
@@ -335,7 +348,8 @@
 #  define futimens rpl_futimens
 # endif
 # if address@hidden@ || @REPLACE_FUTIMENS@
-extern int futimens (int fd, struct timespec const times[2]);
+extern int futimens (int fd, struct timespec const times[2])
+     _GL_ARG_NONNULL ((2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef futimens
@@ -360,7 +374,7 @@
 #  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 +393,8 @@
 # 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 +408,7 @@
 #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 +428,8 @@
 
 #if @GNULIB_MKDIRAT@
 # if address@hidden@
-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 +446,7 @@
 #  define mkfifo rpl_mkfifo
 # endif
 # if address@hidden@ || @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 +459,8 @@
 
 #if @GNULIB_MKFIFOAT@
 # if address@hidden@
-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 +477,8 @@
 #  define mknod rpl_mknod
 # endif
 # if address@hidden@ || @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 +491,8 @@
 
 #if @GNULIB_MKNODAT@
 # if address@hidden@
-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 +518,7 @@
 #  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 +536,8 @@
 # endif
 # if address@hidden@ || @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, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef utimensat
--- lib/sys_time.in.h.orig      2009-12-10 14:50:57.000000000 +0100
+++ lib/sys_time.in.h   2009-12-10 14:10:01.000000000 +0100
@@ -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,17 @@
 #  include <time.h>
 # endif
 
+/* _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 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
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -54,7 +65,7 @@
 # if @REPLACE_GETTIMEOFDAY@
 #  undef gettimeofday
 #  define gettimeofday rpl_gettimeofday
-int gettimeofday (struct timeval *restrict, void *restrict);
+int gettimeofday (struct timeval *restrict, void *restrict) _GL_ARG_NONNULL 
((1));
 # endif
 
 #ifdef __cplusplus
--- lib/sys_times.in.h.orig     2009-12-10 14:50:57.000000000 +0100
+++ lib/sys_times.in.h  2009-12-10 14:10:01.000000000 +0100
@@ -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,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 # ifdef __cplusplus
 extern "C" {
 # endif
@@ -43,7 +54,7 @@
   };
 
 # 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)                                             \
--- lib/sys_utsname.in.h.orig   2009-12-10 14:50:57.000000000 +0100
+++ lib/sys_utsname.in.h        2009-12-10 14:10:01.000000000 +0100
@@ -20,6 +20,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -65,7 +76,7 @@
 
 #if @GNULIB_UNAME@
 # if address@hidden@
-extern int uname (struct utsname *buf);
+extern int uname (struct utsname *buf) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef uname
--- lib/time.in.h.orig  2009-12-10 14:50:57.000000000 +0100
+++ lib/time.in.h       2009-12-10 14:21:52.000000000 +0100
@@ -40,6 +40,17 @@
 /* NetBSD 5.0 mis-defines NULL.  */
 #include <stddef.h>
 
+/* _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 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
+
 # ifdef __cplusplus
 extern "C" {
 # endif
@@ -66,13 +77,14 @@
    <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 +95,12 @@
 #  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 +109,17 @@
 # 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
--- lib/unistd.in.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/unistd.in.h     2009-12-10 14:10:01.000000000 +0100
@@ -96,6 +96,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 
 /* OS/2 EMX lacks these macros.  */
 #ifndef STDIN_FILENO
@@ -135,7 +146,8 @@
    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 +251,7 @@
 # if address@hidden@
 /* 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 +264,8 @@
 
 #if @GNULIB_FACCESSAT@
 # if address@hidden@
-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 +286,8 @@
 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 +308,8 @@
 #  define fchownat rpl_fchownat
 # endif
 # if address@hidden@ || @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 +393,7 @@
    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 address@hidden@
-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 +454,7 @@
 #  define gethostname rpl_gethostname
 # endif
 # if @UNISTD_H_HAVE_WINSOCK2_H@ || address@hidden@
-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 +479,7 @@
    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
  */
 # if address@hidden@
-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 +589,8 @@
    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 +610,8 @@
    See POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/link.html>.  */
 # if address@hidden@ || @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 +631,8 @@
    Return 0 if successful, otherwise -1 and errno set.  */
 # if address@hidden@ || @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 +672,7 @@
 # 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 +691,8 @@
    set errno and return -1.  0 indicates EOF.  See the POSIX:2001
    specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
 # if address@hidden@ || @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 +713,8 @@
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
 # if address@hidden@ || @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 +727,8 @@
 
 #if @GNULIB_READLINKAT@
 # if address@hidden@
-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 +743,7 @@
 # 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 +781,8 @@
 #  define symlink rpl_symlink
 # endif
 # if address@hidden@ || @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 +795,8 @@
 
 #if @GNULIB_SYMLINKAT@
 # if address@hidden@
-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 +811,7 @@
 # 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 +828,7 @@
 #  define unlinkat rpl_unlinkat
 # endif
 # if address@hidden@ || @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 +866,8 @@
    <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
 
 
--- lib/wchar.in.h.orig 2009-12-10 14:50:57.000000000 +0100
+++ lib/wchar.in.h      2009-12-10 14:10:01.000000000 +0100
@@ -74,6 +74,17 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* _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 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
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -197,7 +208,8 @@
 #  define mbsrtowcs rpl_mbsrtowcs
 # endif
 # if address@hidden@ || @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 +227,8 @@
 #  define mbsnrtowcs rpl_mbsnrtowcs
 # endif
 # if address@hidden@ || @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 +264,8 @@
 #  define wcsrtombs rpl_wcsrtombs
 # endif
 # if address@hidden@ || @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 +283,8 @@
 #  define wcsnrtombs rpl_wcsnrtombs
 # endif
 # if address@hidden@ || @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
--- lib/argv-iter.h.orig        2009-12-10 14:50:57.000000000 +0100
+++ lib/argv-iter.h     2009-12-10 14:10:01.000000000 +0100
@@ -20,11 +20,15 @@
 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)
+/* _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 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
 
 enum argv_iter_err
@@ -36,12 +40,12 @@
 };
 
 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));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]