public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/hist: make err_text array fully const
@ 2025-11-04  4:55 Huiwen He
  2025-11-05  7:17 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Huiwen He @ 2025-11-04  4:55 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel, Huiwen He

The err_text array contains string literals that are never modified.
Previously it was declared as:

    static const char *err_text[]

which makes the strings themselves const but allows the pointers
in the array to be changed.

Change it to:

    static const char * const err_text[]

This prevents accidental modification of the array pointers,
fixes checkpatch warnings, and allows the compiler to place the
entire array in the read-only data section (.rodata).

Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 1d536219b624..3be35ebdaa62 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -80,7 +80,7 @@ enum { ERRORS };
 #undef C
 #define C(a, b)		b
 
-static const char *err_text[] = { ERRORS };
+static const char * const err_text[] = { ERRORS };
 
 struct hist_field;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-05 15:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04  4:55 [PATCH] tracing/hist: make err_text array fully const Huiwen He
2025-11-05  7:17 ` kernel test robot
2025-11-05 10:05 ` kernel test robot
2025-11-05 11:50 ` Huiwen He
2025-11-05 15:09 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox