diff mbox series

media: lirc: suppress false positive smatch warning

Message ID 20220310132350.78729-1-sean@mess.org (mailing list archive)
State New, archived
Headers show
Series media: lirc: suppress false positive smatch warning | expand

Commit Message

Sean Young March 10, 2022, 1:23 p.m. UTC
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.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: smatch@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/media/rc/lirc_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dan Carpenter March 10, 2022, 2:42 p.m. UTC | #1
On Thu, Mar 10, 2022 at 01:23:50PM +0000, Sean Young wrote:
> 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.
> 
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: smatch@vger.kernel.org
> Signed-off-by: Sean Young <sean@mess.org>

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
Sean Young March 10, 2022, 2:49 p.m. UTC | #2
On Thu, Mar 10, 2022 at 05:42:30PM +0300, Dan Carpenter wrote:
> On Thu, Mar 10, 2022 at 01:23:50PM +0000, Sean Young wrote:
> > 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.
> > 
> > Cc: Dan Carpenter <dan.carpenter@oracle.com>
> > Cc: smatch@vger.kernel.org
> > Signed-off-by: Sean Young <sean@mess.org>
> 
> 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
diff mbox series

Patch

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 765375bda0c6..efa09beae6a7 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -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) ||