summaryrefslogtreecommitdiff
path: root/Documentation/core-api
diff options
context:
space:
mode:
authorMiles Chen <miles.chen@mediatek.com>2019-10-01 13:04:49 +0300
committerJonathan Corbet <corbet@lwn.net>2019-11-07 23:17:26 +0300
commit88288ed050adb5a96f6063d2d0e3e35bac8e84c2 (patch)
tree6afe900cb45ca65658dfb47b2def26b3372f7e08 /Documentation/core-api
parentf0ae2cfae53b8057380801a7549f388adee59a8e (diff)
downloadlinux-88288ed050adb5a96f6063d2d0e3e35bac8e84c2.tar.xz
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. Signed-off-by: Miles Chen <miles.chen@mediatek.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/core-api')
-rw-r--r--Documentation/core-api/printk-formats.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index ecbebf4ca8e7..8a0f49cd158b 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -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
----------------