Skip to contentSkip to conversation

docs: printk-formats: add ptrdiff_t type to printk-formats

PATCH Applied Miles Chen 2 participants 2 messages Oct 1, 2019 – Nov 7, 2019

Subsystems (3)
lore
Share & tools
lore

Miles Chen

author
#0 lore raw

PATCH 1/1 docs: printk-formats: add ptrdiff_t type to printk-formats

When print the difference between two pointers, we should use the ptrdiff_t modifier %t.

---
 Documentation/core-api/printk-formats.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/core-api/printk-formats.rst +14 -0
index ecbebf4ca8e7..8a0f49cd158b 100644
@@ -135,6 +135,20 @@ equivalent to %lx (or %lu). %px is preferred because it is more uniquely
 grep'able. If in the future we need to modify the way the kernel handles
 printing pointers we will be better equipped to find the call sites.
 
+Pointer Differences
+-------------------
+
+::
+
+	%td	2560
+	%tx	a00
+
+For printing the pointer differences, use the %t modifier for ptrdiff_t.
+
+Example::
+
+	printk("test: difference between pointers: %td\n", ptr2 - ptr1);
+
 Struct Resources
 ----------------
 
Signature · 1 line
2.18.0
maintainer Applied
#1 lore raw
Quoted 7 lines · On Tue, 1 Oct 2019 18:04:49 +0800 Miles Chen <[email protected]> wrote:

When print the difference between two pointers, we should use the ptrdiff_t modifier %t.

---
 Documentation/core-api/printk-formats.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Applied, thanks.

jon