Messages in this thread | | | From | Kay Sievers <> | Date | Fri, 3 Aug 2012 11:51:13 +0200 | Subject | Re: [PATCH v2] printk: add option to print cpu id |
| |
On Fri, Aug 3, 2012 at 11:43 AM, Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> wrote: > On Fri, 3 Aug 2012 02:16:18 -0700, Vikram Pandita <vikram.pandita@ti.com> wrote:
>> +static size_t print_cpuid(u8 cpuid, char *buf) >> +{ >> + >> + if (!printk_cpuid) >> + return 0; >> + >> + if (!buf) >> + return 4; >> +
> Firstly, why this magic number? > Secondly, if buf is NULL, why should you increment?
The !buffer logic is used when we only calculate the size of the output buffer, but do not print to it. It's just an optimization. And yes, the number returned should match the number of chars that would have been printed, so this does not look right.
Kay
| |