ref_tracker: use %ld format specifier for PTR_ERR() during directory creation failure
PATCH 1/1 ref_tracker: use %ld format specifier for PTR_ERR() during directory creation failure
PTR_ERR yields type long, so use %ld format specifier in pr_warn.
--- lib/ref_tracker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ref_tracker.c +1 -1
@@ -283,7 +283,7 @@ static int __init ref_tracker_debug_init(void) { ref_tracker_debug_dir =debugfs_create_dir ("ref_tracker" ,NULL );if (IS_ERR (ref_tracker_debug_dir)) { -pr_warn ("ref_tracker: unable to create ref_tracker debugfs directory: %d\n" , +pr_warn ("ref_tracker: unable to create ref_tracker debugfs directory: %ld\n" ,PTR_ERR (ref_tracker_debug_dir)); ref_tracker_debug_dir =NULL ; }
Signature · 1 line
2.39.5
Hi Qasim,
Quoted 15 lines · Qasim Ijaz
PTR_ERRyields type long, so use %ld format specifier inpr_warn.Fixes ada5a12aae58 ("ref_tracker: add a top level debugfs directory for ref_tracker")Reported-by kernel test robot <[email protected]>Signed-off-by Qasim Ijaz <[email protected]>--- lib/ref_tracker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/ref_tracker.c +0
-0
lib/ref_tracker.c static int __init ref_tracker_debug_init(void) · line 286
Quoted 5 lines
lib/ref_tracker.c +1
-1@@ -283,7 +283,7 @@ static int __init ref_tracker_debug_init(void) { ref_tracker_debug_dir =debugfs_create_dir ("ref_tracker" ,NULL );if (IS_ERR (ref_tracker_debug_dir)) { - pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %d\n", + pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %ld\n",
While there is nothing wrong with doing this to resolve the warning, I think this would be a good opportunity to use the '%pe' format specifier
[1] instead of '%ld', as that will print the symbolic error name (such as -EINVAL instead of just -22) and make it easier for people to decipher what has gone wrong.
pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %pe\n",
ref_tracker_debug_dir);
[1]: From the "error pointers" section in Documentation/core-api/printk-formats.rst
Cheers,
Nathan
Quoted 7 lines
lib/ref_tracker.c +0
-0PTR_ERR(ref_tracker_debug_dir)); ref_tracker_debug_dir =NULL ; }Signature · 1 line
2.39.5
Quoted 13 lines · Nathan Chancellor
Hi Qasim,
Quoted 10 lines · Qasim Ijaz
PTR_ERRyields type long, so use %ld format specifier inpr_warn.Fixes ada5a12aae58 ("ref_tracker: add a top level debugfs directory for ref_tracker")Reported-by kernel test robot <[email protected]>Signed-off-by Qasim Ijaz <[email protected]>--- lib/ref_tracker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines
lib/ref_tracker.c static int __init ref_tracker_debug_init(void) · line 286
Quoted 10 lines
lib/ref_tracker.c +1
-1@@ -283,7 +283,7 @@ static int __init ref_tracker_debug_init(void) { ref_tracker_debug_dir =debugfs_create_dir ("ref_tracker" ,NULL );if (IS_ERR (ref_tracker_debug_dir)) { - pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %d\n", + pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %ld\n",While there is nothing wrong with doing this to resolve the warning, I think this would be a good opportunity to use the '%pe' format specifier
[1] instead of '%ld', as that will print the symbolic error name (such as-EINVALinstead of just -22) and make it easier for people to decipher what has gone wrong.
Hi Nathan,
Thanks for the suggestion, I think this would be an improvement over using %ld.
Would you like me to include you in a suggested-by tag in patch v2?
Regards,
Qasim
Quoted 15 lines
pr_warn("ref_tracker: unable to create
ref_trackerdebugfs directory: %pe\n",ref_tracker_debug_dir);[1]: From the "error pointers" section in
Documentation/core-api/printk-formats.rstCheers,
NathanQuoted 7 lines
lib/ref_tracker.c +0
-0PTR_ERR(ref_tracker_debug_dir)); ref_tracker_debug_dir =NULL ; }Signature · 1 line
2.39.5
Quoted 6 lines · Qasim Ijaz
Hi Nathan,
Thanks for the suggestion, I think this would be an improvement over using %ld.
Would you like me to include you in a suggested-by tag in patch v2?
No, I do not need a Suggested-by tag, feel free to send v2 without it.
Cheers,
Nathan