linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS
@ 2018-11-25  9:13 Joe Perches
  2018-11-26  5:35 ` Sergey Senozhatsky
  2018-11-30 16:58 ` Petr Mladek
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2018-11-25  9:13 UTC (permalink / raw)
  To: Sergey Senozhatsky, Linus Torvalds; +Cc: LKML

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

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:
---
 Documentation/core-api/printk-formats.rst | 10 ----------
 lib/vsprintf.c                            | 12 ++----------
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index ff48b55040ef..ab5a6d1b05c0 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -70,8 +70,6 @@ Symbols/Function Pointers
 
 	%pS	versatile_init+0x0/0x110
 	%ps	versatile_init
-	%pF	versatile_init+0x0/0x110
-	%pf	versatile_init
 	%pSR	versatile_init+0x9/0x110
 		(with __builtin_extract_return_addr() translation)
 	%pB	prev_fn_of_versatile_init+0x88/0x88
@@ -81,14 +79,6 @@ The ``S`` and ``s`` specifiers are used for printing a pointer in symbolic
 format. They result in the symbol name with (S) or without (s)
 offsets. If KALLSYMS are disabled then the symbol address is printed instead.
 
-Note, that the ``F`` and ``f`` specifiers are identical to ``S`` (``s``)
-and thus deprecated. We have ``F`` and ``f`` because on ia64, ppc64 and
-parisc64 function pointers are indirect and, in fact, are function
-descriptors, which require additional dereferencing before we can lookup
-the symbol. As of now, ``S`` and ``s`` perform dereferencing on those
-platforms (when needed), so ``F`` and ``f`` exist for compatibility
-reasons only.
-
 The ``B`` specifier results in the symbol name with offsets and should be
 used when printing stack backtraces. The specifier takes into
 consideration the effect of compiler optimisations which may occur
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 37a54a6dd594..393002bf5298 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -795,7 +795,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
 #ifdef CONFIG_KALLSYMS
 	if (*fmt == 'B')
 		sprint_backtrace(sym, value);
-	else if (*fmt != 'f' && *fmt != 's')
+	else if (*fmt != 's')
 		sprint_symbol(sym, value);
 	else
 		sprint_symbol_no_offset(sym, value);
@@ -1756,9 +1756,7 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
  *
  * - 'S' For symbolic direct pointers (or function descriptors) with offset
  * - 's' For symbolic direct pointers (or function descriptors) without offset
- * - 'F' Same as 'S'
- * - 'f' Same as 's'
- * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
+ * - '[Ss]R' as above with __builtin_extract_return_addr() translation
  * - 'B' For backtraced symbolic direct pointers with offset
  * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
  * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
@@ -1872,8 +1870,6 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 	}
 
 	switch (*fmt) {
-	case 'F':
-	case 'f':
 	case 'S':
 	case 's':
 		ptr = dereference_symbol_descriptor(ptr);
@@ -2603,8 +2599,6 @@ int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args)
 			/* Dereference of functions is still OK */
 			case 'S':
 			case 's':
-			case 'F':
-			case 'f':
 			case 'x':
 			case 'K':
 				save_arg(void *);
@@ -2779,8 +2773,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
 			switch (*fmt) {
 			case 'S':
 			case 's':
-			case 'F':
-			case 'f':
 			case 'x':
 			case 'K':
 				process = true;
---



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-30 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-25  9:13 RFC: script to convert vsprintf uses of %pf to %ps and %pF to %pS Joe Perches
2018-11-26  5:35 ` Sergey Senozhatsky
2018-11-26  6:08   ` Sergey Senozhatsky
2018-11-26 17:13     ` Joe Perches
2018-11-30 16:58 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).