[U-Boot] [PATCH] [v2] powerpc/85xx: fix compatible property for the L2 cache node

Timur Tabi timur at freescale.com
Fri Apr 29 23:01:23 CEST 2011


Wolfgang Denk wrote:
>> > Except that his version works and your version doesn't.  With your version
>> > sprintf will stop reading the format string after "controller".

> Yes, and this is why I call this a dirty hack, as it's obfuscating
> what's going on and what the intended result is.

I disagree.  It's quite clear what I'm trying to do.  I'm trying to insert a
NULL character into a string.  Since device tree properties use a NULL to
delimit multiple strings, it's clear that this is what the "0" is for.

Look at the original code:

	len = sprintf(compat_buf,
		"fsl,%c%s-l2-cache-controller",
		tolower(cpu->name[0]), cpu->name + 1);

	sprintf(&compat_buf[len + 1], "cache");

I think my patch is clearer than this.  In fact, because the original code was
so obscure, there was a bug in it.  I could have done this:

	len = sprintf(compat_buf,
		"fsl,%c%s-l2-cache-controller",
		tolower(cpu->name[0]), cpu->name + 1);

	len += sprintf(&compat_buf[len + 1], "cache") + 2;

Where the "+ 2" is for each NULL in the string.  I just don't see how this is
better than my version.

-- 
Timur Tabi
Linux kernel developer at Freescale



More information about the U-Boot mailing list