Loading Documentation/core-api/printk-formats.rst +8 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,14 @@ A raw pointer value may be printed with %p which will hash the address before printing. The kernel also supports extended specifiers for printing pointers of different types. Some of the extended specifiers print the data on the given address instead of printing the address itself. In this case, the following error messages might be printed instead of the unreachable information:: (null) data on plain NULL address (efault) data on invalid address (einval) invalid data on a valid address Plain Pointers -------------- Loading lib/test_printf.c +22 −3 Original line number Diff line number Diff line Loading @@ -239,6 +239,7 @@ plain_format(void) #define PTR ((void *)0x456789ab) #define PTR_STR "456789ab" #define PTR_VAL_NO_CRNG "(ptrval)" #define ZEROS "" static int __init plain_format(void) Loading Loading @@ -268,7 +269,6 @@ plain_hash_to_buffer(const void *p, char *buf, size_t len) return 0; } static int __init plain_hash(void) { Loading Loading @@ -325,6 +325,24 @@ test_hashed(const char *fmt, const void *p) test(buf, fmt, p); } static void __init null_pointer(void) { test_hashed("%p", NULL); test(ZEROS "00000000", "%px", NULL); test("(null)", "%pE", NULL); } #define PTR_INVALID ((void *)0x000000ab) static void __init invalid_pointer(void) { test_hashed("%p", PTR_INVALID); test(ZEROS "000000ab", "%px", PTR_INVALID); test("(efault)", "%pE", PTR_INVALID); } static void __init symbol_ptr(void) { Loading Loading @@ -462,8 +480,7 @@ struct_rtc_time(void) .tm_year = 118, }; test_hashed("%pt", &tm); test("(%ptR?)", "%pt", &tm); test("2018-11-26T05:35:43", "%ptR", &tm); test("0118-10-26T05:35:43", "%ptRr", &tm); test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm); Loading Loading @@ -572,6 +589,8 @@ static void __init test_pointer(void) { plain(); null_pointer(); invalid_pointer(); symbol_ptr(); kernel_ptr(); struct_resource(); Loading lib/vsprintf.c +271 −160 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
Documentation/core-api/printk-formats.rst +8 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,14 @@ A raw pointer value may be printed with %p which will hash the address before printing. The kernel also supports extended specifiers for printing pointers of different types. Some of the extended specifiers print the data on the given address instead of printing the address itself. In this case, the following error messages might be printed instead of the unreachable information:: (null) data on plain NULL address (efault) data on invalid address (einval) invalid data on a valid address Plain Pointers -------------- Loading
lib/test_printf.c +22 −3 Original line number Diff line number Diff line Loading @@ -239,6 +239,7 @@ plain_format(void) #define PTR ((void *)0x456789ab) #define PTR_STR "456789ab" #define PTR_VAL_NO_CRNG "(ptrval)" #define ZEROS "" static int __init plain_format(void) Loading Loading @@ -268,7 +269,6 @@ plain_hash_to_buffer(const void *p, char *buf, size_t len) return 0; } static int __init plain_hash(void) { Loading Loading @@ -325,6 +325,24 @@ test_hashed(const char *fmt, const void *p) test(buf, fmt, p); } static void __init null_pointer(void) { test_hashed("%p", NULL); test(ZEROS "00000000", "%px", NULL); test("(null)", "%pE", NULL); } #define PTR_INVALID ((void *)0x000000ab) static void __init invalid_pointer(void) { test_hashed("%p", PTR_INVALID); test(ZEROS "000000ab", "%px", PTR_INVALID); test("(efault)", "%pE", PTR_INVALID); } static void __init symbol_ptr(void) { Loading Loading @@ -462,8 +480,7 @@ struct_rtc_time(void) .tm_year = 118, }; test_hashed("%pt", &tm); test("(%ptR?)", "%pt", &tm); test("2018-11-26T05:35:43", "%ptR", &tm); test("0118-10-26T05:35:43", "%ptRr", &tm); test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm); Loading Loading @@ -572,6 +589,8 @@ static void __init test_pointer(void) { plain(); null_pointer(); invalid_pointer(); symbol_ptr(); kernel_ptr(); struct_resource(); Loading