Date: Mon, 21 May 2018 14:38:55 +1200
From: Thomas Munro <munro@ip9.org>
To: freebsd-hackers@freebsd.org
Subject: printf("%m") doesn't generate a warning -- shouldn't it?
Message-ID: <CADLWmXU__ZRaS=gg_Y18WYbJJgk2Rs065RhkYmAZCFY8mp1Wjg@mail.gmail.com>
index | next in thread | raw e-mail
Hi,
As discussed on the PostgreSQL[1] and NetBSD mailing lists[2][3],
syslog-like printf("%m") is a GNU extension that doesn't generate a
warning from Clang or GCC on other operating systems even though when
it doesn't actually work. That's because the __printf__ attribute
that our __printflike macro in /usr/include/stdio.h expands to
effectively means "like printf in glibc, allowing %m", not like POSIX
or our actual libc which just prints out "m" when it sees it.
It'd sure be nice to get a compiler warning on FreeBSD when porting
software that uses that if it doesn't actually work (or ... to support
it).
Concretely, contrib/llvm/tools/clang/include/clang/Analysis/Analyses/FormatString.h
thinks that 'm' is valid but lib/libc/stdio/vfprintf.c doesn't.
Apologies if this was already discussed, it's quite hard to search for
a short squiggly format control string...
Thanks,
[1] https://www.postgresql.org/message-id/2975.1526862605%40sss.pgh.pa.us
[2] https://mail-index.netbsd.org/tech-userlevel/2015/08/21/msg009282.html
[3] https://mail-index.netbsd.org/tech-userlevel/2015/10/23/msg009371.html
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADLWmXU__ZRaS=gg_Y18WYbJJgk2Rs065RhkYmAZCFY8mp1Wjg>
