fcntl-h, stdio, sys_ioctl: fix declarations
authorEric Blake <ebb9@byu.net>
Tue, 15 Dec 2009 13:51:24 +0000 (06:51 -0700)
committerEric Blake <ebb9@byu.net>
Wed, 16 Dec 2009 04:20:15 +0000 (21:20 -0700)
We cannot use a function-like macro to provide a link-time warning
of a variadic function during GNULIB_POSIXCHECK; at least, not
without assuming C99 variadic macros.  We can, however,
use an object-like macro (as was already done for printf).

On the other hand, this patch is only a stop-gap measure to fix
an obvious bug; a more complete patch that switches from a
link-time warning (specific to GNU ld, gcc, and ELF image) to
a compile-time attribute is in the works.

* lib/stdio.in.h (dprintf): Use of link warning on a variadic
function must not take arguments.
* lib/sys_ioctl.in.h (ioctl): Likewise.
* lib/fcntl.in.h (openat): Likewise.  Declare extern.
(open): Add a link warning.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/fcntl.in.h
lib/stdio.in.h
lib/sys_ioctl.in.h

index 7655b07..efa426c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-12-15  Eric Blake  <ebb9@byu.net>
+
+       fcntl-h, stdio, sys_ioctl: fix declarations
+       * lib/stdio.in.h (dprintf): Use of link warning on a variadic
+       function must not take arguments.
+       * lib/sys_ioctl.in.h (ioctl): Likewise.
+       * lib/fcntl.in.h (openat): Likewise.  Declare extern.
+       (open): Add a link warning.
+
 2009-12-15  Jim Meyering  <meyering@redhat.com>
 
        areadlink, areadlink-with-size: relax license to LGPLv2+
@@ -5,7 +14,7 @@
        * modules/areadlink-with-size (License): Likewise.
 
 2009-12-15  Joel E. Denny  <jdenny@clemson.edu>
-            Bruno Haible  <bruno@clisp.org>
+           Bruno Haible  <bruno@clisp.org>
 
        *printf: Fix memory leak.
        * lib/fprintf.c (fprintf): Free memory allocated by vasnprintf.
index 75e1b55..953e065 100644 (file)
@@ -61,6 +61,12 @@ extern "C" {
 #  define open rpl_open
 extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1));
 # endif
+#elif defined GNULIB_POSIXCHECK
+# undef open
+# define open \
+    (GL_LINK_WARNING ("open is not always POSIX compliant - " \
+                      "use gnulib module open for portability"), \
+     open)
 #endif
 
 #if @GNULIB_OPENAT@
@@ -69,12 +75,12 @@ extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1));
 #  define openat rpl_openat
 # endif
 # if !@HAVE_OPENAT@ || @REPLACE_OPENAT@
-int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
+extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
      _GL_ARG_NONNULL ((2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef openat
-# define openat(f,u,g) \
+# define openat \
     (GL_LINK_WARNING ("openat is not portable - " \
                       "use gnulib module openat for portability"), \
      openat)
index 0bcf154..a52f65f 100644 (file)
@@ -80,10 +80,10 @@ extern int dprintf (int fd, const char *format, ...)
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef dprintf
-# define dprintf(d,f,a) \
+# define dprintf \
     (GL_LINK_WARNING ("dprintf is unportable - " \
                       "use gnulib module dprintf for portability"), \
-     dprintf (d, f, a))
+     dprintf)
 #endif
 
 #if @GNULIB_FCLOSE@
index 55d3b35..dfcb54e 100644 (file)
@@ -54,10 +54,10 @@ extern int ioctl (int fd, int request, ... /* {void *,char *} arg */);
 # define ioctl ioctl_used_without_requesting_gnulib_module_ioctl
 #elif defined GNULIB_POSIXCHECK
 # undef ioctl
-# define ioctl(f,c,a) \
+# define ioctl \
     (GL_LINK_WARNING ("ioctl does not portably work on sockets - " \
                       "use gnulib module ioctl for portability"), \
-     ioctl (f, c, a))
+     ioctl)
 #endif