# HG changeset patch # User Eric Blake # Date 1260885084 25200 # Node ID 419d4e1a3d411fe5927cabdf370b03cee5b497ff # Parent 6590c835b8044acbb9b807ae675293a038961191 fcntl-h, stdio, sys_ioctl: fix declarations 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 diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-12-15 Eric Blake + + 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 areadlink, areadlink-with-size: relax license to LGPLv2+ @@ -5,7 +14,7 @@ * modules/areadlink-with-size (License): Likewise. 2009-12-15 Joel E. Denny - Bruno Haible + Bruno Haible *printf: Fix memory leak. * lib/fprintf.c (fprintf): Free memory allocated by vasnprintf. diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -61,6 +61,12 @@ # 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 @@ # 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) diff --git a/lib/stdio.in.h b/lib/stdio.in.h --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -80,10 +80,10 @@ # 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@ diff --git a/lib/sys_ioctl.in.h b/lib/sys_ioctl.in.h --- a/lib/sys_ioctl.in.h +++ b/lib/sys_ioctl.in.h @@ -54,10 +54,10 @@ # 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