Skip to contentSkip to conversation

media: lirc: suppress false positive smatch warning

PATCH In review Sean Young 2 participants 3 messages Mar 10, 2022

Subsystems (2)
lore
Share & tools
lore

Sean Young

author maintainer
#0 lore raw

PATCH 1/1 media: lirc: suppress false positive smatch warning

The latest smatch says:

drivers/media/rc/lirc_dev.c:632 lirc_read_mode2() error: uninitialized symbol 'copied'. drivers/media/rc/lirc_dev.c:671 lirc_read_scancode() error: uninitialized symbol 'copied'.

This is a false positive since in all reaching code paths, copied will be set. Work around this by providing a zero initializer for copied.

---
 drivers/media/rc/lirc_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/rc/lirc_dev.c +2 -2
index 765375bda0c6..efa09beae6a7 100644
@@ -601,7 +601,7 @@ static ssize_t lirc_read_mode2(struct file *file, char __user *buffer,
 {
 	struct lirc_fh *fh = file->private_data;
 	struct rc_dev *rcdev = fh->rc;
-	unsigned int copied;
+	unsigned int copied = 0;
 	int ret;
 
 	if (length < sizeof(unsigned int) || length % sizeof(unsigned int))
@@ -639,7 +639,7 @@ static ssize_t lirc_read_scancode(struct file *file, char __user *buffer,
 {
 	struct lirc_fh *fh = file->private_data;
 	struct rc_dev *rcdev = fh->rc;
-	unsigned int copied;
+	unsigned int copied = 0;
 	int ret;
 
 	if (length < sizeof(struct lirc_scancode) ||
Signature · 1 line
2.35.1
#1 lore raw
Quoted 11 lines · Sean Young

The latest smatch says:

drivers/media/rc/lirc_dev.c:632 lirc_read_mode2() error: uninitialized symbol 'copied'. drivers/media/rc/lirc_dev.c:671 lirc_read_scancode() error: uninitialized symbol 'copied'.

This is a false positive since in all reaching code paths, copied will be set. Work around this by providing a zero initializer for copied.

I'm sorry for this. I can't reproduce this on my system. I just did a push for something unrelated and I don't know what the previous HEAD was...

regards,
dan carpenter

author maintainer
#2 lore raw
Quoted 9 lines · Dan Carpenter
Quoted 8 lines · Sean Young

The latest smatch says:

drivers/media/rc/lirc_dev.c:632 lirc_read_mode2() error: uninitialized symbol 'copied'. drivers/media/rc/lirc_dev.c:671 lirc_read_scancode() error: uninitialized symbol 'copied'.

This is a false positive since in all reaching code paths, copied will be set. Work around this by providing a zero initializer for copied.

Quoted 7 lines
Quoted 3 lines

I'm sorry for this. I can't reproduce this on my system. I just did a push for something unrelated and I don't know what the previous HEAD was...

You're right, with the latest HEAD the warning goes away. Great, let's drop this patch then.

Thanks for a great tool

Sean