Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753028Ab2HCJvi (ORCPT ); Fri, 3 Aug 2012 05:51:38 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:42894 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752532Ab2HCJve (ORCPT ); Fri, 3 Aug 2012 05:51:34 -0400 MIME-Version: 1.0 In-Reply-To: <87wr1g5n0r.fsf@abhimanyu.in.ibm.com> References: <1343985378-22330-1-git-send-email-vikram.pandita@ti.com> <87wr1g5n0r.fsf@abhimanyu.in.ibm.com> From: Kay Sievers Date: Fri, 3 Aug 2012 11:51:13 +0200 Message-ID: Subject: Re: [PATCH v2] printk: add option to print cpu id To: Nikunj A Dadhania Cc: Vikram Pandita , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, Mike Turquette , Vimarsh Zutshi Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 935 Lines: 28 On Fri, Aug 3, 2012 at 11:43 AM, Nikunj A Dadhania wrote: > On Fri, 3 Aug 2012 02:16:18 -0700, Vikram Pandita 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/