Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1708917 > unrolled thread

[PATCH] printk-formats.txt: Add examples for %pS and %pF

Started byHelge Deller <deller@gmx.de>
First post2017-08-10 19:40 +0200
Last post2017-08-11 09:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] printk-formats.txt: Add examples for %pS and %pF Helge Deller <deller@gmx.de> - 2017-08-10 19:40 +0200
    Re: [PATCH] printk-formats.txt: Add examples for %pS and %pF Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-08-11 02:20 +0200
      Re: [PATCH] printk-formats.txt: Add examples for %pS and %pF Helge Deller <deller@gmx.de> - 2017-08-11 09:40 +0200

#1708917 — [PATCH] printk-formats.txt: Add examples for %pS and %pF

FromHelge Deller <deller@gmx.de>
Date2017-08-10 19:40 +0200
Subject[PATCH] printk-formats.txt: Add examples for %pS and %pF
Message-ID<ucZB7-fd-11@gated-at.bofh.it>
Sometimes people seems unclear when to use the %pS or %pF printk format.
Adding some examples may help to avoid such mistakes.

See for example commit 51d96dc2e2dc ("random: fix warning message on ia64 and
parisc") which fixed such a wrong format string.

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 65ea591..be8c05b 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -73,6 +73,12 @@ actually function descriptors which must first be resolved. The ``F`` and
 ``f`` specifiers perform this resolution and then provide the same
 functionality as the ``S`` and ``s`` specifiers.
 
+Examples::
+
+	printk("Called from %pS.\n", __builtin_return_address(0));
+	printk("Called from %pS.\n", (void *)regs->ip);
+	printk("Called from %pF.\n", &gettimeofday);
+
 Kernel Pointers
 ===============
 

[toc] | [next] | [standalone]


#1709137

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2017-08-11 02:20 +0200
Message-ID<ud5Qe-4M6-5@gated-at.bofh.it>
In reply to#1708917
On (08/10/17 19:35), Helge Deller wrote:
> Sometimes people seems unclear when to use the %pS or %pF printk format.
> Adding some examples may help to avoid such mistakes.
> 
> See for example commit 51d96dc2e2dc ("random: fix warning message on ia64 and
> parisc") which fixed such a wrong format string.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 65ea591..be8c05b 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -73,6 +73,12 @@ actually function descriptors which must first be resolved. The ``F`` and
>  ``f`` specifiers perform this resolution and then provide the same
>  functionality as the ``S`` and ``s`` specifiers.
>  
> +Examples::
> +
> +	printk("Called from %pS.\n", __builtin_return_address(0));
> +	printk("Called from %pS.\n", (void *)regs->ip);
> +	printk("Called from %pF.\n", &gettimeofday);

sorry, but how does it help?


there is this paragraph

: On ia64, ppc64 and parisc64 architectures function pointers are
: actually function descriptors which must first be resolved. The ``F`` and
: ``f`` specifiers perform this resolution and then provide the same
: functionality as the ``S`` and ``s`` specifiers.

which supposed to explain everything in details. the examples
don't make it any `clearer', IMHO.


*may be* on "ia64, ppc64 and parisc64" we can somehow check
that the pointer, which we pass as %pS, belongs to .text and
print some build-time warnings. well, if it's actually a
problem. dunno.

	-ss

[toc] | [prev] | [next] | [standalone]


#1709340

FromHelge Deller <deller@gmx.de>
Date2017-08-11 09:40 +0200
Message-ID<udcI2-Db-13@gated-at.bofh.it>
In reply to#1709137
On 11.08.2017 02:15, Sergey Senozhatsky wrote:
> On (08/10/17 19:35), Helge Deller wrote:
>> Sometimes people seems unclear when to use the %pS or %pF printk format.
>> Adding some examples may help to avoid such mistakes.
>>
>> See for example commit 51d96dc2e2dc ("random: fix warning message on ia64 and
>> parisc") which fixed such a wrong format string.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>>
>> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
>> index 65ea591..be8c05b 100644
>> --- a/Documentation/printk-formats.txt
>> +++ b/Documentation/printk-formats.txt
>> @@ -73,6 +73,12 @@ actually function descriptors which must first be resolved. The ``F`` and
>>  ``f`` specifiers perform this resolution and then provide the same
>>  functionality as the ``S`` and ``s`` specifiers.
>>  
>> +Examples::
>> +
>> +	printk("Called from %pS.\n", __builtin_return_address(0));
>> +	printk("Called from %pS.\n", (void *)regs->ip);
>> +	printk("Called from %pF.\n", &gettimeofday);
> 
> sorry, but how does it help?
> 
> 
> there is this paragraph
> 
> : On ia64, ppc64 and parisc64 architectures function pointers are
> : actually function descriptors which must first be resolved. The ``F`` and
> : ``f`` specifiers perform this resolution and then provide the same
> : functionality as the ``S`` and ``s`` specifiers.
> 
> which supposed to explain everything in details. the examples
> don't make it any `clearer', IMHO.

Experts surely do know what function descriptors are.
Nevertheless even those often get it wrong as can be seen in
various commits.

The hope with this patch is to show widely-used examples
and avoid additional commits afterwards to fix it up.

This patch was meant to be RFC.
If you decide not to take it, I'm fine as well.

> *may be* on "ia64, ppc64 and parisc64" we can somehow check
> that the pointer, which we pass as %pS, belongs to .text and
> print some build-time warnings. well, if it's actually a
> problem. dunno.

I think it's not needed. Those bugs will be seen and fixed.

Helge

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web