From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Date: Fri, 29 Apr 2011 16:01:23 -0500 Subject: [U-Boot] [PATCH] [v2] powerpc/85xx: fix compatible property for the L2 cache node In-Reply-To: <20110429205513.382ABD5270C@gemini.denx.de> References: <1304089126-11945-1-git-send-email-timur@freescale.com> <20110429203058.446B9D5270C@gemini.denx.de> <20110429154457.0fee37c6@schlenkerla.am.freescale.net> <20110429205513.382ABD5270C@gemini.denx.de> Message-ID: <4DBB2723.4050408@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.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