* [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
* Re: [PATCH] tracing/hist: make err_text array fully const
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
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-11-05 7:17 UTC (permalink / raw)
To: Huiwen He, Steven Rostedt
Cc: oe-kbuild-all, Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
linux-trace-kernel, Huiwen He
Hi Huiwen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v6.18-rc4 next-20251104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Huiwen-He/tracing-hist-make-err_text-array-fully-const/20251104-125932
base: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link: https://lore.kernel.org/r/20251104045558.1644671-1-hehuiwen%40kylinos.cn
patch subject: [PATCH] tracing/hist: make err_text array fully const
config: riscv-randconfig-001-20251105 (https://download.01.org/0day-ci/archive/20251105/202511051436.6ZUGn3Af-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251105/202511051436.6ZUGn3Af-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511051436.6ZUGn3Af-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/trace/trace_events_hist.c: In function 'hist_err':
>> kernel/trace/trace_events_hist.c:808:46: warning: passing argument 4 of 'tracing_log_err' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
tracing_log_err(tr, last_cmd_loc, last_cmd, err_text,
^~~~~~~~
In file included from kernel/trace/trace_dynevent.h:14,
from kernel/trace/trace_synth.h:5,
from kernel/trace/trace_events_hist.c:22:
kernel/trace/trace.h:2113:21: note: expected 'const char **' but argument is of type 'const char * const*'
const char **errs, u8 type, u16 pos);
~~~~~~~~~~~~~^~~~
vim +808 kernel/trace/trace_events_hist.c
4b147936fa50965 Tom Zanussi 2018-01-15 802
edfeed318d59ff2 Tom Zanussi 2022-01-28 803 static void hist_err(struct trace_array *tr, u8 err_type, u16 err_pos)
7bbab38d07f3185 Masami Hiramatsu 2018-11-05 804 {
edfeed318d59ff2 Tom Zanussi 2022-01-28 805 if (!last_cmd)
edfeed318d59ff2 Tom Zanussi 2022-01-28 806 return;
edfeed318d59ff2 Tom Zanussi 2022-01-28 807
726721a51838e39 Tom Zanussi 2020-05-28 @808 tracing_log_err(tr, last_cmd_loc, last_cmd, err_text,
726721a51838e39 Tom Zanussi 2020-05-28 809 err_type, err_pos);
7bbab38d07f3185 Masami Hiramatsu 2018-11-05 810 }
7bbab38d07f3185 Masami Hiramatsu 2018-11-05 811
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/hist: make err_text array fully const
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
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-11-05 10:05 UTC (permalink / raw)
To: Huiwen He, Steven Rostedt
Cc: oe-kbuild-all, Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
linux-trace-kernel, Huiwen He
Hi Huiwen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v6.18-rc4 next-20251105]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Huiwen-He/tracing-hist-make-err_text-array-fully-const/20251104-125932
base: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link: https://lore.kernel.org/r/20251104045558.1644671-1-hehuiwen%40kylinos.cn
patch subject: [PATCH] tracing/hist: make err_text array fully const
config: sh-randconfig-r121-20251105 (https://download.01.org/0day-ci/archive/20251105/202511051755.CU1HPYCx-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251105/202511051755.CU1HPYCx-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511051755.CU1HPYCx-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> kernel/trace/trace_events_hist.c:808:53: sparse: sparse: incorrect type in argument 4 (different modifiers) @@ expected char const **errs @@ got char const *const * @@
kernel/trace/trace_events_hist.c:808:53: sparse: expected char const **errs
kernel/trace/trace_events_hist.c:808:53: sparse: got char const *const *
vim +808 kernel/trace/trace_events_hist.c
4b147936fa5096 Tom Zanussi 2018-01-15 802
edfeed318d59ff Tom Zanussi 2022-01-28 803 static void hist_err(struct trace_array *tr, u8 err_type, u16 err_pos)
7bbab38d07f318 Masami Hiramatsu 2018-11-05 804 {
edfeed318d59ff Tom Zanussi 2022-01-28 805 if (!last_cmd)
edfeed318d59ff Tom Zanussi 2022-01-28 806 return;
edfeed318d59ff Tom Zanussi 2022-01-28 807
726721a51838e3 Tom Zanussi 2020-05-28 @808 tracing_log_err(tr, last_cmd_loc, last_cmd, err_text,
726721a51838e3 Tom Zanussi 2020-05-28 809 err_type, err_pos);
7bbab38d07f318 Masami Hiramatsu 2018-11-05 810 }
7bbab38d07f318 Masami Hiramatsu 2018-11-05 811
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/hist: make err_text array fully const
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
3 siblings, 0 replies; 5+ messages in thread
From: Huiwen He @ 2025-11-05 11:50 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu; +Cc: Mathieu Desnoyers, linux-kernel
Hi Steven and Masami,
Sorry, I didn’t notice this warning when building the kernel locally.
Please ignore this patch. After further analysis, I found that unless the
prototype of tracing_log_err() is modified, this patch has no effect. It
might not be worth doing this, since the tracing_log_err() interface is
already used in multiple files in the trace subsystem.
Best regards,
Huiwen He
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/hist: make err_text array fully const
2025-11-04 4:55 [PATCH] tracing/hist: make err_text array fully const Huiwen He
` (2 preceding siblings ...)
2025-11-05 11:50 ` Huiwen He
@ 2025-11-05 15:09 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-11-05 15:09 UTC (permalink / raw)
To: Huiwen He, Steven Rostedt
Cc: llvm, oe-kbuild-all, Masami Hiramatsu, Mathieu Desnoyers,
linux-kernel, linux-trace-kernel, Huiwen He
Hi Huiwen,
kernel test robot noticed the following build errors:
[auto build test ERROR on trace/for-next]
[also build test ERROR on linus/master v6.18-rc4 next-20251105]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Huiwen-He/tracing-hist-make-err_text-array-fully-const/20251104-125932
base: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link: https://lore.kernel.org/r/20251104045558.1644671-1-hehuiwen%40kylinos.cn
patch subject: [PATCH] tracing/hist: make err_text array fully const
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20251105/202511052258.kdB9B0rI-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251105/202511052258.kdB9B0rI-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511052258.kdB9B0rI-lkp@intel.com/
All errors (new ones prefixed by >>):
>> kernel/trace/trace_events_hist.c:808:46: error: passing 'const char *const[49]' to parameter of type 'const char **' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
808 | tracing_log_err(tr, last_cmd_loc, last_cmd, err_text,
| ^~~~~~~~
kernel/trace/trace.h:2113:21: note: passing argument to parameter 'errs' here
2113 | const char **errs, u8 type, u16 pos);
| ^
1 error generated.
vim +808 kernel/trace/trace_events_hist.c
4b147936fa5096 Tom Zanussi 2018-01-15 802
edfeed318d59ff Tom Zanussi 2022-01-28 803 static void hist_err(struct trace_array *tr, u8 err_type, u16 err_pos)
7bbab38d07f318 Masami Hiramatsu 2018-11-05 804 {
edfeed318d59ff Tom Zanussi 2022-01-28 805 if (!last_cmd)
edfeed318d59ff Tom Zanussi 2022-01-28 806 return;
edfeed318d59ff Tom Zanussi 2022-01-28 807
726721a51838e3 Tom Zanussi 2020-05-28 @808 tracing_log_err(tr, last_cmd_loc, last_cmd, err_text,
726721a51838e3 Tom Zanussi 2020-05-28 809 err_type, err_pos);
7bbab38d07f318 Masami Hiramatsu 2018-11-05 810 }
7bbab38d07f318 Masami Hiramatsu 2018-11-05 811
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [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