Skip to contentSkip to conversation

drivers/input/serio/serio_raw.c:204:12: warning: variable 'written' is uninitialized when used here

PATCH kernel test robot 1 participant 1 message Oct 20, 2024 HID

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
head:   00850d7b542aa4a8240cf977d43dc6d2158e48d7
commit: 5b53a9d40c4f83b44de8da06af9a9c9b3fb14988 [104/120] Input: serio_raw - use guard notation for locks and other resources
config: i386-buildonly-randconfig-002-20241019 (https://download.01.org/0day-ci/archive/20241020/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241020/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/input/serio/serio_raw.c:204:12: warning: variable 'written' is uninitialized when used here [-Wuninitialized]
     204 |                                 return written ?: -EIO;
         |                                        ^~~~~~~
   drivers/input/serio/serio_raw.c:188:13: note: initialize the variable 'written' to silence this warning
     188 |         int written;
         |                    ^
         |                     = 0

1 warning generated.

vim +/written +204 drivers/input/serio/serio_raw.c

182
183 static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
184 size_t count, loff_t *ppos)
185 {
186 struct serio_raw_client *client = file->private_data;
187 struct serio_raw *serio_raw = client->serio_raw;
188 int written;
189 unsigned char c;
190
191 scoped_guard(mutex_intr, &serio_raw_mutex) {
192 if (serio_raw->dead)
193 return -ENODEV;
194
195 if (count > 32)
196 count = 32;
197
198 while (count--) {
199 if (get_user(c, buffer++))
200 return -EFAULT;
201
202 if (serio_write(serio_raw->serio, c)) {
203 /* Either signal error or partial write */

 > 204					return written ?: -EIO;

205 }
206
207 written++;
208 }
209
210 return written;
211 }
212
213 return -EINTR;
214 }
215

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki