Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/vsprintf: declare no_hash_pointers in sprintf.h

Sparse is not happy to see non-static variable without declaration:
lib/vsprintf.c:61:6: warning: symbol 'no_hash_pointers' was not declared.
Should it be static?

Declare respective variable in the sprintf.h. With this, add a comment to
discourage its use if no real need.

Link: https://lkml.kernel.org/r/20230814163344.17429-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Marco Elver <elver@google.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Andrew Morton
66553609 39ced19b

+3 -4
+2
include/linux/sprintf.h
··· 20 20 __scanf(2, 3) int sscanf(const char *, const char *, ...); 21 21 __scanf(2, 0) int vsscanf(const char *, const char *, va_list); 22 22 23 + /* These are for specific cases, do not use without real need */ 24 + extern bool no_hash_pointers; 23 25 int no_hash_pointers_enable(char *str); 24 26 25 27 #endif /* _LINUX_KERNEL_SPRINTF_H */
-2
lib/test_printf.c
··· 42 42 static char *test_buffer __initdata; 43 43 static char *alloced_buffer __initdata; 44 44 45 - extern bool no_hash_pointers; 46 - 47 45 static int __printf(4, 0) __init 48 46 do_test(int bufsize, const char *expect, int elen, 49 47 const char *fmt, va_list ap)
+1 -2
mm/kfence/report.c
··· 13 13 #include <linux/printk.h> 14 14 #include <linux/sched/debug.h> 15 15 #include <linux/seq_file.h> 16 + #include <linux/sprintf.h> 16 17 #include <linux/stacktrace.h> 17 18 #include <linux/string.h> 18 19 #include <trace/events/error_report.h> ··· 26 25 #ifndef ARCH_FUNC_PREFIX 27 26 #define ARCH_FUNC_PREFIX "" 28 27 #endif 29 - 30 - extern bool no_hash_pointers; 31 28 32 29 /* Helper function to either print to a seq_file or to console. */ 33 30 __printf(2, 3)