printf("%m") doesn't generate a warning -- shouldn't it?
Konstantin Belousov
kostikbel at gmail.com
Tue May 22 09:49:45 UTC 2018
On Tue, May 22, 2018 at 09:37:18AM +0000, Poul-Henning Kamp wrote:
> --------
> In message <CABh_MKkWOaKZxqye2zW7tGF2Pro6hvnf5PHTgY8HqtHrFCprqg at mail.gmail.com>
> , Ed Schouten writes:
> >2018-05-21 15:43 GMT+02:00 Konstantin Belousov <kostikbel at gmail.com>:
> >> Why not add %m instead ? It is very easy and several people did it in
> >> round-about ways.
> >
> >Added advantage of that approach is that it allows the syslog()
> >function to be simplified significantly. No need to expand the %m
> >there, which ends up being quite messy.
>
> We have an cleanly expandable printf implementation for exactly
> this kind of stuff, so that is not really the case.
>
> However, expandable printf is close to useless when there is no
> sane/portable way to teach compilers about new formatting arguments.
Expandable printf(3) could serve a situation when application wants and
implements an extenstion. It does not work, or is rather weird thing to
try to make it work, when application assumes that the extension is provided
by the operating system.
There was at least one patch which tried to add %m as an extension, and
of course the problem with this approach is that errno may be already
obliterated when the format handler for %m got called.
More information about the freebsd-hackers
mailing list