On Thu, Aug 14, 2014 at 03:28:51PM +0100, Laszlo Papp wrote:
> On Thu, Aug 14, 2014 at 2:44 PM, Tanguy Pruvot <tanguy.pru...@gmail.com>
> wrote:
> 
> > its the same with bionic libc (arm)
> >
> > printf("test") is ok but not printf(buf) with char buf[] = "test";
> > printf("%s", buf) is ok
> >
> 
> Yeah, I guess it is about personal preference. I personally do not like the
> extended code just to make some "smart" option silent. IMHO, it makes the
> code needlessly longer by adding another small layer for the content of the
> variable. If there is no need for formatting, why use printf in the first
> place and not fputs with stdout? IMHO, stdout is nicer than "%s" :-) On the
> other hand, it is too bad that there is nothing between fputs and puts
> where you do not need to use the file descriptor and you do not get a new
> line either.

In principle stdout is more expensive than "". stdout is a GOT
reference in PIC, and "" is just PC-relative. For non-PIC it makes no
difference though.

As for the topic at hand, I don't think it's necessary to make this
change if the messages are DOCUMENTED as being format strings that are
required not to contain any format specifiers, and there's a big
warning to this effect in the source wherever they appear. printf
allows format strings chosen (or even constructed) at runtime and the
-W option to make this an error is bogus; at least it cannot be
applied to code that was not written for a specific coding style that
forbids such usage.

Rich
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to