tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: printf and -m



On 2015-08-22 03:26, David Holland wrote:
On Fri, Aug 21, 2015 at 12:43:10PM -0400, Christos Zoulas wrote:
 > We should decide what we want to do:
 >
 > - Make %m work in printf() like linux does.
> - Apply the following patch to prevent programs use %m in printf formats, > keep fixing 3rd party code, and maintain the custom format attribute to > find new offenders. It is unlikely that the gnu folks will take a patch > that makes %m warn for printf. We could coordinate with other BSD's to
 >   do the same. Note that this patch can break pkgsrc code...

The second, please.

I also think we should deprecate %m in syslog, but I don't see how
it's possible to do so in practice.

Could you expand on the rationale for this please?

%m in syslog is valid POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/

Let us list %m advantages in syslog
1) reduces code size
2) standard

Let us list %m advantages in printf
1) reduces code size
2) if syslog requires %m, there should be zero code size increase moving the logic to printf
3) increases portability

So given the above, the best outcome is to extend accepted standards (POSIX syslog %m) and be portable with other implementations (printf %m which syslog can use).
Any other alternative is this:

I also think we should deprecate %m in syslog

Which is encourages a break in standards support and is surely not portable.

Roy


Home | Main Index | Thread Index | Old Index