Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-30 Thread Petr Mladek
On Sun 2018-11-25 01:13:51, Joe Perches wrote:
> commit 04b8eb7a4ccd ("symbol lookup: introduce 
> dereference_symbol_descriptor()}"
> 
> deprecated vsprintf extension %pf and %pF.
> 
> so a script to convert all the %pf uses to %ps and %pF uses to %pS
> could be useful.
> 
> There are a few files that appear should not be converted.
> 
> $ git grep -w --name-only -i '%pf'| \
>   grep -vP '^(?:Documentation|tools|include/linux/freezer.h)'| \
>   xargs sed -i -e 's/%pf/%ps/g' -e 's/%pF/%pS/g'
> 
> If that script above is run, it leaves the following patch
> to be applied:

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 37a54a6dd594..393002bf5298 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1872,8 +1870,6 @@ char *pointer(const char *fmt, char *buf, char *end, 
> void *ptr,
>   }
>  
>   switch (*fmt) {
> - case 'F':
> - case 'f':

Please, keep handling these modifiers so that they do not get reused
anytime soon.

The pointer modifiers are evil. Any misuse can easily lead to a crash.
Any mistakes with upstreaming 3rd party patches or backporting stable
fixes would be hard to notice.

Well, it is perfectly fine to just explicitly fallback to
the default %p behavior. I mean something like:

case 'F':
case 'f':
/* Replaced by %ps and %pS and removed in 4.21 */
break;

Best Regards,
Petr


Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-30 Thread Petr Mladek
On Sun 2018-11-25 01:13:51, Joe Perches wrote:
> commit 04b8eb7a4ccd ("symbol lookup: introduce 
> dereference_symbol_descriptor()}"
> 
> deprecated vsprintf extension %pf and %pF.
> 
> so a script to convert all the %pf uses to %ps and %pF uses to %pS
> could be useful.
> 
> There are a few files that appear should not be converted.
> 
> $ git grep -w --name-only -i '%pf'| \
>   grep -vP '^(?:Documentation|tools|include/linux/freezer.h)'| \
>   xargs sed -i -e 's/%pf/%ps/g' -e 's/%pF/%pS/g'
> 
> If that script above is run, it leaves the following patch
> to be applied:

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 37a54a6dd594..393002bf5298 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1872,8 +1870,6 @@ char *pointer(const char *fmt, char *buf, char *end, 
> void *ptr,
>   }
>  
>   switch (*fmt) {
> - case 'F':
> - case 'f':

Please, keep handling these modifiers so that they do not get reused
anytime soon.

The pointer modifiers are evil. Any misuse can easily lead to a crash.
Any mistakes with upstreaming 3rd party patches or backporting stable
fixes would be hard to notice.

Well, it is perfectly fine to just explicitly fallback to
the default %p behavior. I mean something like:

case 'F':
case 'f':
/* Replaced by %ps and %pS and removed in 4.21 */
break;

Best Regards,
Petr


Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-26 Thread Joe Perches
On Mon, 2018-11-26 at 15:08 +0900, Sergey Senozhatsky wrote:
> > There are approximately these total uses of the symbolic
> > lookup vsprintf extensions %p[SsFf]:
> > 
> > $ git grep '".*[^%]%p[SsFf]' | \
> >   grep -oh '%p[SsFf]' | sort | uniq -c | sort -rn
> > 231 %pS
> >  65 %ps
> >  60 %pf
> >  47 %pF
> 
> I didn't bother to remove "pf/pF" because I didn't want to count on:
>   a) everyone running checkpatch.pl
>   b) everyone testing all printk-s they added
> 
> I guess pf/pF still can sneak in.

Any use of %p could sneak in.

And thanks, the checkpatch test for %p
should be updated too.

> But I don't have a really strong opinion on this. If general
> consensus is that we shall remove deprecated specifiers, then
> I'm fine.

I think converting deprecated things is generally good.

Also, the %p lettering space is limited, so
cleaning deprecated extensions is useful.

> After running this script I still have a bunch of leftovers:
> 
> //
> // these two are probably not really relevant, but still - %pF/%pf
> //
> tools/lib/traceevent/event-parse.c: if (asprintf(, "%%pf: 
> (NO FORMAT FOUND at %llx)\n", addr) < 0)
> tools/lib/traceevent/event-parse.c: if (asprintf(, "%s: %s", 
> "%pf", printk->printk) < 0)

I was not/am not sure about those.

> arch/um/kernel/sysrq.c: pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" 
> : "? ",
> arch/x86/xen/multicalls.c:  printk(KERN_DEBUG "  
> call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
> kernel/async.c: pr_debug("calling  %lli_%pF @ %i\n",
> kernel/async.c: pr_debug("initcall %lli_%pF returned 0 after %lld 
> usecs\n",

Missed those by using \b, thanks again.




Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-26 Thread Joe Perches
On Mon, 2018-11-26 at 15:08 +0900, Sergey Senozhatsky wrote:
> > There are approximately these total uses of the symbolic
> > lookup vsprintf extensions %p[SsFf]:
> > 
> > $ git grep '".*[^%]%p[SsFf]' | \
> >   grep -oh '%p[SsFf]' | sort | uniq -c | sort -rn
> > 231 %pS
> >  65 %ps
> >  60 %pf
> >  47 %pF
> 
> I didn't bother to remove "pf/pF" because I didn't want to count on:
>   a) everyone running checkpatch.pl
>   b) everyone testing all printk-s they added
> 
> I guess pf/pF still can sneak in.

Any use of %p could sneak in.

And thanks, the checkpatch test for %p
should be updated too.

> But I don't have a really strong opinion on this. If general
> consensus is that we shall remove deprecated specifiers, then
> I'm fine.

I think converting deprecated things is generally good.

Also, the %p lettering space is limited, so
cleaning deprecated extensions is useful.

> After running this script I still have a bunch of leftovers:
> 
> //
> // these two are probably not really relevant, but still - %pF/%pf
> //
> tools/lib/traceevent/event-parse.c: if (asprintf(, "%%pf: 
> (NO FORMAT FOUND at %llx)\n", addr) < 0)
> tools/lib/traceevent/event-parse.c: if (asprintf(, "%s: %s", 
> "%pf", printk->printk) < 0)

I was not/am not sure about those.

> arch/um/kernel/sysrq.c: pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" 
> : "? ",
> arch/x86/xen/multicalls.c:  printk(KERN_DEBUG "  
> call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
> kernel/async.c: pr_debug("calling  %lli_%pF @ %i\n",
> kernel/async.c: pr_debug("initcall %lli_%pF returned 0 after %lld 
> usecs\n",

Missed those by using \b, thanks again.




Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-25 Thread Sergey Senozhatsky
And I forgot to actually Cc Petr and Steven...
Top-posting.

---

Hi,

Cc-ing Petr and Steven

On (11/25/18 01:13), Joe Perches wrote:
> commit 04b8eb7a4ccd ("symbol lookup: introduce 
> dereference_symbol_descriptor()}"
> 
> deprecated vsprintf extension %pf and %pF.
> 
> There are approximately these total uses of the symbolic
> lookup vsprintf extensions %p[SsFf]:
> 
> $ git grep '".*[^%]%p[SsFf]' | \
>   grep -oh '%p[SsFf]' | sort | uniq -c | sort -rn
> 231 %pS
>  65 %ps
>  60 %pf
>  47 %pF

I didn't bother to remove "pf/pF" because I didn't want to count on:
  a) everyone running checkpatch.pl
  b) everyone testing all printk-s they added

I guess pf/pF still can sneak in.

But I don't have a really strong opinion on this. If general
consensus is that we shall remove deprecated specifiers, then
I'm fine.

> which is about a 3:1 ratio favoring %pS
> 
> so a script to convert all the %pf uses to %ps and %pF uses to %pS
> could be useful.
> 
> There are a few files that appear should not be converted.
> 
> $ git grep -w --name-only -i '%pf'| \
>   grep -vP '^(?:Documentation|tools|include/linux/freezer.h)'| \
>   xargs sed -i -e 's/%pf/%ps/g' -e 's/%pF/%pS/g'
> 
> If that script above is run, it leaves the following patch
> to be applied:

After running this script I still have a bunch of leftovers:

//
// these two are probably not really relevant, but still - %pF/%pf
//
tools/lib/traceevent/event-parse.c: if (asprintf(, "%%pf: 
(NO FORMAT FOUND at %llx)\n", addr) < 0)
tools/lib/traceevent/event-parse.c: if (asprintf(, "%s: %s", "%pf", 
printk->printk) < 0)

arch/um/kernel/sysrq.c: pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : 
"? ",
arch/x86/xen/multicalls.c:  printk(KERN_DEBUG "  
call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
kernel/async.c: pr_debug("calling  %lli_%pF @ %i\n",
kernel/async.c: pr_debug("initcall %lli_%pF returned 0 after %lld 
usecs\n",

-ss


Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-25 Thread Sergey Senozhatsky
And I forgot to actually Cc Petr and Steven...
Top-posting.

---

Hi,

Cc-ing Petr and Steven

On (11/25/18 01:13), Joe Perches wrote:
> commit 04b8eb7a4ccd ("symbol lookup: introduce 
> dereference_symbol_descriptor()}"
> 
> deprecated vsprintf extension %pf and %pF.
> 
> There are approximately these total uses of the symbolic
> lookup vsprintf extensions %p[SsFf]:
> 
> $ git grep '".*[^%]%p[SsFf]' | \
>   grep -oh '%p[SsFf]' | sort | uniq -c | sort -rn
> 231 %pS
>  65 %ps
>  60 %pf
>  47 %pF

I didn't bother to remove "pf/pF" because I didn't want to count on:
  a) everyone running checkpatch.pl
  b) everyone testing all printk-s they added

I guess pf/pF still can sneak in.

But I don't have a really strong opinion on this. If general
consensus is that we shall remove deprecated specifiers, then
I'm fine.

> which is about a 3:1 ratio favoring %pS
> 
> so a script to convert all the %pf uses to %ps and %pF uses to %pS
> could be useful.
> 
> There are a few files that appear should not be converted.
> 
> $ git grep -w --name-only -i '%pf'| \
>   grep -vP '^(?:Documentation|tools|include/linux/freezer.h)'| \
>   xargs sed -i -e 's/%pf/%ps/g' -e 's/%pF/%pS/g'
> 
> If that script above is run, it leaves the following patch
> to be applied:

After running this script I still have a bunch of leftovers:

//
// these two are probably not really relevant, but still - %pF/%pf
//
tools/lib/traceevent/event-parse.c: if (asprintf(, "%%pf: 
(NO FORMAT FOUND at %llx)\n", addr) < 0)
tools/lib/traceevent/event-parse.c: if (asprintf(, "%s: %s", "%pf", 
printk->printk) < 0)

arch/um/kernel/sysrq.c: pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : 
"? ",
arch/x86/xen/multicalls.c:  printk(KERN_DEBUG "  
call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
kernel/async.c: pr_debug("calling  %lli_%pF @ %i\n",
kernel/async.c: pr_debug("initcall %lli_%pF returned 0 after %lld 
usecs\n",

-ss


Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-25 Thread Sergey Senozhatsky
Hi,

Cc-ing Petr and Steven

On (11/25/18 01:13), Joe Perches wrote:
> commit 04b8eb7a4ccd ("symbol lookup: introduce 
> dereference_symbol_descriptor()}"
> 
> deprecated vsprintf extension %pf and %pF.
> 
> There are approximately these total uses of the symbolic
> lookup vsprintf extensions %p[SsFf]:
> 
> $ git grep '".*[^%]%p[SsFf]' | \
>   grep -oh '%p[SsFf]' | sort | uniq -c | sort -rn
> 231 %pS
>  65 %ps
>  60 %pf
>  47 %pF

I didn't bother to remove "pf/pF" because I didn't want to count on:
  a) everyone running checkpatch.pl
  b) everyone testing all printk-s they added

I guess pf/pF still can sneak in.

But I don't have a really strong opinion on this. If general
consensus is that we shall remove deprecated specifiers, then
I'm fine.

> which is about a 3:1 ratio favoring %pS
> 
> so a script to convert all the %pf uses to %ps and %pF uses to %pS
> could be useful.
> 
> There are a few files that appear should not be converted.
> 
> $ git grep -w --name-only -i '%pf'| \
>   grep -vP '^(?:Documentation|tools|include/linux/freezer.h)'| \
>   xargs sed -i -e 's/%pf/%ps/g' -e 's/%pF/%pS/g'
> 
> If that script above is run, it leaves the following patch
> to be applied:

After running this script I still have a bunch of leftovers:

//
// these two are probably not really relevant, but still - %pF/%pf
//
tools/lib/traceevent/event-parse.c: if (asprintf(, "%%pf: 
(NO FORMAT FOUND at %llx)\n", addr) < 0)
tools/lib/traceevent/event-parse.c: if (asprintf(, "%s: %s", "%pf", 
printk->printk) < 0)

arch/um/kernel/sysrq.c: pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : 
"? ",
arch/x86/xen/multicalls.c:  printk(KERN_DEBUG "  
call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
kernel/async.c: pr_debug("calling  %lli_%pF @ %i\n",
kernel/async.c: pr_debug("initcall %lli_%pF returned 0 after %lld 
usecs\n",

-ss


Re: RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS

2018-11-25 Thread Sergey Senozhatsky
Hi,

Cc-ing Petr and Steven

On (11/25/18 01:13), Joe Perches wrote:
> commit 04b8eb7a4ccd ("symbol lookup: introduce 
> dereference_symbol_descriptor()}"
> 
> deprecated vsprintf extension %pf and %pF.
> 
> There are approximately these total uses of the symbolic
> lookup vsprintf extensions %p[SsFf]:
> 
> $ git grep '".*[^%]%p[SsFf]' | \
>   grep -oh '%p[SsFf]' | sort | uniq -c | sort -rn
> 231 %pS
>  65 %ps
>  60 %pf
>  47 %pF

I didn't bother to remove "pf/pF" because I didn't want to count on:
  a) everyone running checkpatch.pl
  b) everyone testing all printk-s they added

I guess pf/pF still can sneak in.

But I don't have a really strong opinion on this. If general
consensus is that we shall remove deprecated specifiers, then
I'm fine.

> which is about a 3:1 ratio favoring %pS
> 
> so a script to convert all the %pf uses to %ps and %pF uses to %pS
> could be useful.
> 
> There are a few files that appear should not be converted.
> 
> $ git grep -w --name-only -i '%pf'| \
>   grep -vP '^(?:Documentation|tools|include/linux/freezer.h)'| \
>   xargs sed -i -e 's/%pf/%ps/g' -e 's/%pF/%pS/g'
> 
> If that script above is run, it leaves the following patch
> to be applied:

After running this script I still have a bunch of leftovers:

//
// these two are probably not really relevant, but still - %pF/%pf
//
tools/lib/traceevent/event-parse.c: if (asprintf(, "%%pf: 
(NO FORMAT FOUND at %llx)\n", addr) < 0)
tools/lib/traceevent/event-parse.c: if (asprintf(, "%s: %s", "%pf", 
printk->printk) < 0)

arch/um/kernel/sysrq.c: pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : 
"? ",
arch/x86/xen/multicalls.c:  printk(KERN_DEBUG "  
call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
kernel/async.c: pr_debug("calling  %lli_%pF @ %i\n",
kernel/async.c: pr_debug("initcall %lli_%pF returned 0 after %lld 
usecs\n",

-ss