[zanussi-trace:ftrace/masami-hitcount-v0 1/3] kernel/trace/trace_events_hist.c:4354:9: warning: variable 'n_hitcount' is uninitialized when used here

From: kernel test robot
Date: Thu Aug 25 2022 - 21:45:49 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-trace.git ftrace/masami-hitcount-v0
head: 886fe9b6098eddb9d298e8a3f07bbea61acdac16
commit: 2b0a73549f8fb4115c06639c75a4b7abd7825aaa [1/3] tracing: Allow multiple hitcount values in histograms
config: x86_64-randconfig-a005 (https://download.01.org/0day-ci/archive/20220826/202208260943.kWLI2lN6-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-trace.git/commit/?id=2b0a73549f8fb4115c06639c75a4b7abd7825aaa
git remote add zanussi-trace https://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-trace.git
git fetch --no-tags zanussi-trace ftrace/masami-hitcount-v0
git checkout 2b0a73549f8fb4115c06639c75a4b7abd7825aaa
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash kernel/trace/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> kernel/trace/trace_events_hist.c:4354:9: warning: variable 'n_hitcount' is uninitialized when used here [-Wuninitialized]
if (!n_hitcount++)
^~~~~~~~~~
kernel/trace/trace_events_hist.c:4335:35: note: initialize the variable 'n_hitcount' to silence this warning
unsigned int i, j = 1, n_hitcount;
^
= 0
1 warning generated.


vim +/n_hitcount +4354 kernel/trace/trace_events_hist.c

4331
4332 static int create_val_fields(struct hist_trigger_data *hist_data,
4333 struct trace_event_file *file)
4334 {
4335 unsigned int i, j = 1, n_hitcount;
4336 char *fields_str, *field_str;
4337 int ret;
4338
4339 ret = create_hitcount_val(hist_data);
4340 if (ret)
4341 goto out;
4342
4343 fields_str = hist_data->attrs->vals_str;
4344 if (!fields_str)
4345 goto out;
4346
4347 for (i = 0, j = 1; i < TRACING_MAP_VALS_MAX &&
4348 j < TRACING_MAP_VALS_MAX; i++) {
4349 field_str = strsep(&fields_str, ",");
4350 if (!field_str)
4351 break;
4352
4353 if (strcmp(field_str, "hitcount") == 0) {
> 4354 if (!n_hitcount++)
4355 continue;
4356 }
4357
4358 ret = create_val_field(hist_data, j++, file, field_str);
4359 if (ret)
4360 goto out;
4361 }
4362
4363 if (fields_str && (strcmp(fields_str, "hitcount") != 0))
4364 ret = -EINVAL;
4365 out:
4366 return ret;
4367 }
4368

--
0-DAY CI Kernel Test Service
https://01.org/lkp