Hi Jeroen, On Fri, 10 Oct 2014 18:09:19 +0200, Jeroen Hofstee <jer...@myspectrum.nl> wrote:
> Hello Marek, > > On 10-10-14 16:26, Marek Vasut wrote: > > On Friday, October 10, 2014 at 04:04:40 PM, Jeroen Hofstee wrote: > >> Hello Wolfgang, > >> > >> On 10-10-14 14:22, Wolfgang Denk wrote: > >>>> It does not mention puts() vs. printf(), if it is indeed meant to be > >>>> u-boot policy. > >>> This is not just U-Boot philosophy, but something that I would > >>> consider a matter of course when writing code - using the appropriate > >>> tools for the task at hand. If all you want to do is sendout a > >>> constant string to the utput device, there is no need to invoke a > >>> function that provides fancy formatting options. > >>> > >>> Don't we always try to use the smallest, most efficient tool that is > >>> suited for a task? > >> calling printf("%s\n", "string") gets translated into puts by the > >> compiler. There should be no difference in the binary > > Is this LLVM specific or does GCC do that too ? This is interesting > > information. > > I was talking about gcc, it has been doing such since ages ago > (unless you purposely disable it). clang does it as well. That's a good thing, but generally speaking, I think that just because the compiler is being clever doesn't mean we are allowed to rely on that, because if we do take a habit of relying on the compiler being clever, two things will happen: 1) we will keep thinking the compiler is being clever even when for some reason it will stop being clever -- for instance, because someone decided to disable the clever feature; 2) we will begin thinking the compiler is clever in situations where it never has and never will. IMO, a quick cost/benefit comparison of choosing between manually turning printf() into puts whenever doable vs letting the compiler do the changes automatically, the manual option wins -- it's bit like Pascal's Wager: you don't lose much but you can only win. > Regards, > Jeroen > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot Amicalement, -- Albert. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot