[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202205070933.wIiOiR2Q-lkp@intel.com>
Date: Sat, 7 May 2022 09:36:18 +0800
From: kernel test robot <lkp@...el.com>
To: Krzysztof Kozlowski <krzk@...nel.org>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
John Garry <john.garry@...wei.com>
Subject: [krzk-github:n/qcom-ufs-opp-cleanups-v2-drv-owner-wip 5/7]
drivers/scsi/scsi_proc.c:145:6: warning: syntax error: keyword 'while' is
not allowed in global scope [syntaxError]
tree: https://github.com/krzk/linux n/qcom-ufs-opp-cleanups-v2-drv-owner-wip
head: 17609caecd53df20f631703ea084a70e7735b5d7
commit: 157eb2ee8867afbae9dac3836e4c0bedb542e5c1 [5/7] scsi: proc: do not store proc_dir in scsi_host_template
compiler: aarch64-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout 157eb2ee8867afbae9dac3836e4c0bedb542e5c1
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> drivers/scsi/scsi_proc.c:145:6: warning: syntax error: keyword 'while' is not allowed in global scope [syntaxError]
void scsi_proc_hostdir_add(const struct scsi_host_template *sht)
^
drivers/scsi/scsi_proc.c:464:61: warning: Parameter 'pos' can be declared with const [constParameter]
static void *scsi_seq_start(struct seq_file *sfile, loff_t *pos)
^
>> drivers/scsi/scsi_proc.c:115:12: warning: Uninitialized variable: dir->sht [uninitvar]
if (dir->sht == sht)
^
drivers/scsi/scsi_proc.c:154:12: warning: Uninitialized variable: dir->sht [uninitvar]
if (dir->sht == sht) {
^
drivers/scsi/scsi_proc.c:149:6: note: Assuming condition is false
if (!sht->show_info)
^
drivers/scsi/scsi_proc.c:154:12: note: Uninitialized variable: dir->sht
if (dir->sht == sht) {
^
vim +/while +145 drivers/scsi/scsi_proc.c
106
107 static struct sht_proc_dir *
108 scsi_proc_find_sht_proc_dir(const struct scsi_host_template *sht)
109 {
110 struct sht_proc_dir *dir;
111
112 lockdep_assert_held(&global_host_template_mutex);
113
114 list_for_each_entry(dir, &sht_proc_dir_list, list) {
> 115 if (dir->sht == sht)
116 return dir;
117 }
118
119 return NULL;
120 }
121
122 struct proc_dir_entry *
123 scsi_proc_get_proc_dir(const struct scsi_host_template *sht)
124 {
125 struct proc_dir_entry *proc_dir = NULL;
126 struct sht_proc_dir *dir;
127
128 mutex_lock(&global_host_template_mutex);
129 dir = scsi_proc_find_sht_proc_dir(sht);
130 if (dir)
131 proc_dir = dir->proc_dir;
132 mutex_unlock(&global_host_template_mutex);
133
134 return proc_dir;
135 }
136 EXPORT_SYMBOL_GPL(scsi_proc_get_proc_dir);
137
138 /**
139 * scsi_proc_hostdir_add - Create directory in /proc for a scsi host
140 * @sht: owner of this directory
141 *
142 * Sets sht->proc_dir to the new directory.
143 */
144
> 145 void scsi_proc_hostdir_add(const struct scsi_host_template *sht)
146 {
147 struct sht_proc_dir *dir;
148
149 if (!sht->show_info)
150 return;
151
152 mutex_lock(&global_host_template_mutex);
153 list_for_each_entry(dir, &sht_proc_dir_list, list) {
154 if (dir->sht == sht) {
155 dir->cnt++;
156 goto out;
157 }
158 }
159 dir = kzalloc(sizeof(*dir), GFP_KERNEL);
160 if (!dir)
161 goto out;
162
163 dir->proc_dir = proc_mkdir(sht->proc_name, proc_scsi);
164 if (!dir->proc_dir) {
165 printk(KERN_ERR "%s: proc_mkdir failed for %s\n",
166 __func__, sht->proc_name);
167 kfree(dir);
168 goto out;
169 }
170
171 dir->cnt++;
172 list_add_tail(&dir->list, &sht_proc_dir_list);
173
174 out:
175 mutex_unlock(&global_host_template_mutex);
176 }
177
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Powered by blists - more mailing lists