Eric Blake <ebb9 <at> byu.net> writes: > > So, what should I do? Options: > 1. Check in the patches below as-is > 2. Ditch this series, and instead go and change all uses of GNULIB_POSIXCHECK > that used > #define func(args) (GL_LINK_WARNING("..."),func(args)) > to instead use > #define func (GL_LINK_WARNING("..."),func) > 3. Like 2, but also check in the new va-args module (others might have a use > for it, even though it would be unused in gnulib at this point)
Another thing to consider. Why are we even bothering with a link warning, which only works for ELF, when gcc provides a more generic solution that will also work for Cygwin and other non-ELF platforms? For example, on cygwin: $ cat foo.c #include <stdlib.h> int main (int argc, char **argv) { char x[] = "aaaXXXXXX"; char * (*func) (char *) = mktemp; func (x); mktemp (x); return 0; } $ gcc -E foo.c | grep mktemp char * __attribute__((__cdecl__)) mktemp (char *) __attribute__ ((warning ("the use of `mktemp' is dangerous; use `mkstemp' instead"))); char * __attribute__((__cdecl__)) _mktemp_r (struct _reent *, char *) __attribute__ ((warning ("the use of `mktemp' is dangerous; use `mkstemp' instead"))); char * (*func) (char *) = mktemp; mktemp (x); $ gcc -Wall -o foo foo.c foo.c: In function ‘main’: foo.c:8: warning: call to ‘mktemp’ declared with attribute warning: the use of `mktemp' is dangerous; use `mkstemp' instead OK, so gcc didn't warn about the suspicious use of the address of mktemp in line 6, such that the call to mktemp in line 7 didn't warn. I guess we should report that as a bug to the gcc folks. But as indirection is less common, the use of __attribute__((__warning__(""))) would allow even more platforms to detect GNULIB_POSIXCHECK holes, without resorting to ELF-only magic that doesn't kick in until the link phase. In other words, maybe I should go with option: 4. Redefine GL_LINK_WARNING to instead be a way to apply __attribute__ ((__warning__)) as a function attribute when gcc supports it (and probably rename the module/macro from link-warning/GL_LINK_WARNING to usage- warning/GL_USAGE_WARNING, since it would now be a compiler rather than a linker warning), and adjust all GNULIB_POSIXCHECK call points to use the new semantics. -- Eric Blake