Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1238160 > unrolled thread
| Started by | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| First post | 2015-10-02 14:30 +0200 |
| Last post | 2015-10-02 16:30 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] lib/vsprintf.c: update documentation Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-02 14:30 +0200
Re: [PATCH] lib/vsprintf.c: update documentation Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-10-02 14:50 +0200
Re: [PATCH] lib/vsprintf.c: update documentation Martin Kletzander <mkletzan@redhat.com> - 2015-10-02 16:30 +0200
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-10-02 14:30 +0200 |
| Subject | [PATCH] lib/vsprintf.c: update documentation |
| Message-ID | <qf7Dj-3g0-3@gated-at.bofh.it> |
%n is no longer just ignored; it results in early return from vsnprintf. Also add a request to add test cases for future %p extensions. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- applies on top of lib-documentation-synchronize-%p-formatting-documentation.patch and its -fix. Documentation/printk-formats.txt | 12 ++++++------ lib/vsprintf.c | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index 9b8d7f746b1a..b784c270105f 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt @@ -23,6 +23,10 @@ Example: Reminder: sizeof() result is of type size_t. +The kernel's printf does not support %n. For obvious reasons, floating +point formats (%e, %f, %g, %a) are also not recognized. Use of any +unsupported specifier or length qualifier results in a WARN and early +return from vsnprintf. Raw pointer value SHOULD be printed with %p. The kernel supports the following extended format specifiers for pointer types: @@ -305,13 +309,9 @@ Command from struct task_struct Passed by reference. -Ignored argument: +If you add other %p extensions, please extend lib/test_printf.c with +one or more test cases, if at all feasible. - %n %n - - The argument passed will be ignored. In other words, literal "%n" will - be in the output and the argument will be considered for next format - specifier. Thank you for your cooperation and attention. diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 5028b044d0e5..488ee489279a 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1448,7 +1448,6 @@ int kptr_restrict __read_mostly; * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address * (legacy clock framework) of the clock * - 'Cr' For a clock, it prints the current rate of the clock - * - 'n' For ignored argument * * ** Please update also Documentation/printk-formats.txt when making changes ** * @@ -1814,8 +1813,10 @@ qualifier: * @fmt: The format string to use * @args: Arguments for the format string * - * This function follows C99 vsnprintf, but has some extensions: - * %n is ignored + * This function generally follows C99 vsnprintf, but has some + * extensions and a few limitations: + * + * %n is unsupported * %p* is handled by pointer() * * See pointer() or Documentation/printk-formats.txt for more -- 2.1.3 -- 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/
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2015-10-02 14:50 +0200 |
| Message-ID | <qf7WG-3Cy-3@gated-at.bofh.it> |
| In reply to | #1238160 |
On Fri, 2015-10-02 at 14:28 +0200, Rasmus Villemoes wrote: > %n is no longer just ignored; it results in early return from > vsnprintf. Also add a request to add test cases for future %p > extensions. Nice! Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> > --- > applies on top of > lib-documentation-synchronize-%p-formatting-documentation.patch and > its -fix. > > Documentation/printk-formats.txt | 12 ++++++------ > lib/vsprintf.c | 7 ++++--- > 2 files changed, 10 insertions(+), 9 deletions(-) > > diff --git a/Documentation/printk-formats.txt b/Documentation/printk > -formats.txt > index 9b8d7f746b1a..b784c270105f 100644 > --- a/Documentation/printk-formats.txt > +++ b/Documentation/printk-formats.txt > @@ -23,6 +23,10 @@ Example: > > Reminder: sizeof() result is of type size_t. > > +The kernel's printf does not support %n. For obvious reasons, > floating > +point formats (%e, %f, %g, %a) are also not recognized. Use of any > +unsupported specifier or length qualifier results in a WARN and > early > +return from vsnprintf. > > Raw pointer value SHOULD be printed with %p. The kernel supports > the following extended format specifiers for pointer types: > @@ -305,13 +309,9 @@ Command from struct task_struct > > Passed by reference. > > -Ignored argument: > +If you add other %p extensions, please extend lib/test_printf.c with > +one or more test cases, if at all feasible. > > - %n %n > - > - The argument passed will be ignored. In other words, > literal "%n" will > - be in the output and the argument will be considered for > next format > - specifier. > > Thank you for your cooperation and attention. > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index 5028b044d0e5..488ee489279a 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -1448,7 +1448,6 @@ int kptr_restrict __read_mostly; > * - 'Cn' For a clock, it prints the name (Common Clock Framework) > or address > * (legacy clock framework) of the clock > * - 'Cr' For a clock, it prints the current rate of the clock > - * - 'n' For ignored argument > * > * ** Please update also Documentation/printk-formats.txt when > making changes ** > * > @@ -1814,8 +1813,10 @@ qualifier: > * @fmt: The format string to use > * @args: Arguments for the format string > * > - * This function follows C99 vsnprintf, but has some extensions: > - * %n is ignored > + * This function generally follows C99 vsnprintf, but has some > + * extensions and a few limitations: > + * > + * %n is unsupported > * %p* is handled by pointer() > * > * See pointer() or Documentation/printk-formats.txt for more -- Andy Shevchenko <andriy.shevchenko@linux.intel.com> Intel Finland Oy -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Martin Kletzander <mkletzan@redhat.com> |
|---|---|
| Date | 2015-10-02 16:30 +0200 |
| Message-ID | <qf9vs-5XN-3@gated-at.bofh.it> |
| In reply to | #1238160 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Oct 02, 2015 at 02:28:06PM +0200, Rasmus Villemoes wrote: >%n is no longer just ignored; it results in early return from >vsnprintf. Also add a request to add test cases for future %p >extensions. > >Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> >--- >applies on top of >lib-documentation-synchronize-%p-formatting-documentation.patch and >its -fix. > Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web