From: Timur Tabi <timur@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] [v2] powerpc/85xx: fix compatible property for the L2 cache node
Date: Fri, 29 Apr 2011 16:01:23 -0500 [thread overview]
Message-ID: <4DBB2723.4050408@freescale.com> (raw)
In-Reply-To: <20110429205513.382ABD5270C@gemini.denx.de>
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
next prev parent reply other threads:[~2011-04-29 21:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 14:58 [U-Boot] [PATCH] [v2] powerpc/85xx: fix compatible property for the L2 cache node Timur Tabi
2011-04-29 15:31 ` Kumar Gala
2011-04-29 20:33 ` Wolfgang Denk
2011-04-29 20:36 ` Kumar Gala
2011-04-29 20:40 ` Wolfgang Denk
2011-04-29 20:30 ` Wolfgang Denk
2011-04-29 20:44 ` Scott Wood
2011-04-29 20:55 ` Wolfgang Denk
2011-04-29 21:01 ` Timur Tabi [this message]
2011-04-29 22:16 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DBB2723.4050408@freescale.com \
--to=timur@freescale.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.