Summary: | -D_XOPEN_SOURCE=500 incorrectly warns about missing snprintf() | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Jan Beich <jbeich> | ||||||
Component: | standards | Assignee: | freebsd-standards (Nobody) <standards> | ||||||
Status: | New --- | ||||||||
Severity: | Affects Only Me | CC: | jilles, kib | ||||||
Priority: | --- | Keywords: | patch | ||||||
Version: | CURRENT | ||||||||
Hardware: | Any | ||||||||
OS: | Any | ||||||||
Attachments: |
|
Description
Jan Beich
2019-09-07 22:35:27 UTC
Real world example from a library bundled with Firefox: $ git clone https://github.com/kinetiknz/cubeb $ cd cubeb $ CFLAGS="-isystem/usr/local/include" LDFLAGS="-L/usr/local/lib" cmake . $ make [...] src/cubeb_alsa.c:564:9: warning: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Wimplicit-function-declaration] r = snprintf(node_name, sizeof(node_name), "pcm.%s", string); ^ $ fgrep XOPEN src/cubeb_alsa.c #define _XOPEN_SOURCE 500 I cannot fix the warning upstream because neither Linux nor other BSDs are affected. Created attachment 207271 [details]
Make snprintf/vscanf visible under appropriate XSI visibility.
I agree with the snprintf/vsnprintf part of https://bugs.freebsd.org/bugzilla/attachment.cgi?id=207271&action=diff except that the test should be for __POSIX_VISIBLE >= 199506 instead of __XSI_VISIBLE >= 500 since this is not an XSI extension. The change to vfscanf/vscanf/vsscanf is redundant since __XSI_VISIBLE == 600 already implies C99. Created attachment 207287 [details]
Make snprintf/vscanf visible under appropriate POSIX visibility.
Attachment 207287 [details] looks good to me.
|