Re: [PATCH v2] printk: add option to print cpu id

From: Kay Sievers
Date: Fri Aug 03 2012 - 05:51:34 EST


On Fri, Aug 3, 2012 at 11:43 AM, Nikunj A Dadhania
<nikunj@xxxxxxxxxxxxxxxxxx> wrote:
> On Fri, 3 Aug 2012 02:16:18 -0700, Vikram Pandita <vikram.pandita@xxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/