[PATCH 06/10] mtd-utils: add common version printing function

Mike Frysinger vapier.adi at gmail.com
Mon Jun 27 16:20:09 EDT 2011


On Mon, Jun 27, 2011 at 16:15, Brian Norris wrote:
> On Mon, Jun 27, 2011 at 12:51 PM, Mike Frysinger wrote:
>> if the string is const, then it could just be puts().  but i wonder if
>> it shouldnt instead use printf("%s %s\n", PROGRAM_NAME, VERSION) so
>> that the string that represents PROGRAM_NAME isn't duplicated in the
>> .rodata section.
>
> I'm not sure I know what the exact technical difference would be
> between the string concatenation version and the '%s' argument
> version...

"%s %s\n" is one string in .rodata, and PROGRAM_NAME is another.  so
anytime the app uses PROGRAM_NAME (like in all the helpers in
common.h), they'll reuse that same PROGRAM_NAME string rather than
constantly duplicating it.

if however you use PROGRAM_NAME " " VERSION, you have a unique string
that is only used by the version code.

minor details, but all these duplicate const strings slowly add up ...
-mike



More information about the linux-mtd mailing list