Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 May 2018 12:49:33 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        Ed Schouten <ed@nuxi.nl>, FreeBSD Hackers <freebsd-hackers@freebsd.org>, Dimitry Andric <dim@freebsd.org>, Thomas Munro <munro@ip9.org>
Subject:   Re: printf("%m") doesn't generate a warning -- shouldn't it?
Message-ID:  <20180522094933.GC88128@kib.kiev.ua>
In-Reply-To: <5221.1526981838@critter.freebsd.dk>
References:  <CADLWmXU__ZRaS=gg_Y18WYbJJgk2Rs065RhkYmAZCFY8mp1Wjg@mail.gmail.com> <BAD690AA-C51A-4125-8F23-B637758C8EB6@FreeBSD.org> <20180521134306.GT6887@kib.kiev.ua> <CABh_MKkWOaKZxqye2zW7tGF2Pro6hvnf5PHTgY8HqtHrFCprqg@mail.gmail.com> <5221.1526981838@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 22, 2018 at 09:37:18AM +0000, Poul-Henning Kamp wrote:
> --------
> In message <CABh_MKkWOaKZxqye2zW7tGF2Pro6hvnf5PHTgY8HqtHrFCprqg@mail.gmail.com>
> , Ed Schouten writes:
> >2018-05-21 15:43 GMT+02:00 Konstantin Belousov <kostikbel@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180522094933.GC88128>