Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1311803 > unrolled thread
| Started by | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| First post | 2016-01-18 22:00 +0100 |
| Last post | 2016-01-18 22:00 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in human-readable form Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-01-18 22:00 +0100
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2016-01-18 22:00 +0100 |
| Subject | Re: [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in human-readable form |
| Message-ID | <qSp47-5SG-19@gated-at.bofh.it> |
On Thu, Jan 14 2016, Andy Shevchenko <andriy.shevchenko@linux.intel.com> 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
Back to top | Article view | linux.kernel
csiph-web