
30 Apr
2011
30 Apr
'11
12:38 a.m.
Wolfgang Denk wrote:
Why do we need this "if" at all? tolower() on a digit is a nop, so you can omit the first branch.
Because cpu->name looks like one of two ways:
8578
or P4080
In the case of "8578", we want to convert that to "mpc8578". In the case of "P4080", we want to convert that to "p4080".
The "if" is need to determine whether to prepend the "mpc".
/* append "cache" to the string */
len += sprintf(buf + len, "cache") + 1;
This is wrong and misleading. This is not an operation on a C string. You do not "append" (or concatenate) the string cache. You build a specifically structured data set, which is not a C string. So please don't call it a string.
Ok.
--
Timur Tabi
Linux kernel developer at Freescale