From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932338AbcARU5u (ORCPT ); Mon, 18 Jan 2016 15:57:50 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:34392 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756251AbcARU5r (ORCPT ); Mon, 18 Jan 2016 15:57:47 -0500 From: Rasmus Villemoes To: Andy Shevchenko Cc: Robert Elliott , Matt Fleming , Andrew Morton , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-kernel@vger.kernel.org, Brian Norris , Hariprasad S Subject: Re: [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in human-readable form Organization: D03 References: <1452810221-116505-1-git-send-email-andriy.shevchenko@linux.intel.com> <1452810221-116505-7-git-send-email-andriy.shevchenko@linux.intel.com> X-Hashcash: 1:20:160118:hpa@zytor.com::YWgghVwZxNRD9SBG:0000038B X-Hashcash: 1:20:160118:hariprasad@chelsio.com::O5+M+qcdzoSgJDv4:0000000000000000000000000000000000000000fJ1 X-Hashcash: 1:20:160118:linux-kernel@vger.kernel.org::oA2NhA+aVQlhxAU9:00000000000000000000000000000000011Ib X-Hashcash: 1:20:160118:elliott@hpe.com::vxeBkNeqMdprf4h1:001hjL X-Hashcash: 1:20:160118:matt@codeblueprint.co.uk::j7PDKFNADRRkp9wH:00000000000000000000000000000000000003gMg X-Hashcash: 1:20:160118:tglx@linutronix.de::BmISfYN7TTihG/l1:00000000000000000000000000000000000000000003oLw X-Hashcash: 1:20:160118:computersforpeace@gmail.com::C2zWLnSuAt+pWO88:00000000000000000000000000000000004XFC X-Hashcash: 1:20:160118:mingo@redhat.com::Zw6vG1qm/dbi2Hq7:06Rpl X-Hashcash: 1:20:160118:akpm@linux-foundation.org::ggZ3+4a9f/M0wKd6:000000000000000000000000000000000000CCIO X-Hashcash: 1:20:160118:andriy.shevchenko@linux.intel.com::KmaDeRVnUmkZX7qy:0000000000000000000000000000E2I2 Date: Mon, 18 Jan 2016 21:57:44 +0100 In-Reply-To: <1452810221-116505-7-git-send-email-andriy.shevchenko@linux.intel.com> (Andy Shevchenko's message of "Fri, 15 Jan 2016 00:23:36 +0200") Message-ID: <87mvs2ehbr.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 14 2016, Andy Shevchenko wrote: > Introduce a new extension for printing given unsigned long long value in > human-readable form with automatically choosen IEC binary prefix. The value is > passed by reference. > I don't like this, and don't find it particularly useful. There's also the problem Joe mentions with types; inevitably, someone wants to pass a size_t or an unsigned int or whatnot, and allowing that gets ugly, as is forcing the caller to copy the value to a temp u64. If you really want this, I think it would be much better to introduce a helper which takes a user-supplied (typically small stack) buffer, formats into that, and maybe for convenience returns that buffer (so it can be passed directly to a %s). That's a lot more flexible, and avoids the annoying type issue since the user's value just gets passed directly (and thus auto-promoted to u64) to the helper. The %pX space is also rapidly diminishing, so we should think twice before introducing yet another rarely used extension. In any case, I had to read the implementation to figure out that the prefix chosen is the largest for which the printed value is exactly what was passed in. Please make that more explicit. [It also means that the printed string isn't necessarily human readable at all, as your test value 1097364144125 shows]. Rasmus