media: uvcvideo: Remove unused variable

Message ID YIyCJoEwdqgqkxYN@fedora (mailing list archive)
State New
Delegated to: Laurent Pinchart
Headers
Series media: uvcvideo: Remove unused variable |

Commit Message

Nigel Christian April 30, 2021, 10:18 p.m. UTC
  The variable buflen is being assigned a value that is never read,
which can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Nigel Christian <nigel.l.christian@gmail.com>
---
 drivers/media/usb/uvc/uvc_driver.c | 1 -
 1 file changed, 1 deletion(-)
  

Comments

Dan Carpenter May 3, 2021, 9:29 a.m. UTC | #1
On Fri, Apr 30, 2021 at 06:18:14PM -0400, Nigel Christian wrote:
> The variable buflen is being assigned a value that is never read,
> which can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Nigel Christian <nigel.l.christian@gmail.com>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index 9a791d8ef200..370b086c6e22 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -768,7 +768,6 @@ static int uvc_parse_format(struct uvc_device *dev,
>  		format->xfer_func = uvc_xfer_func(buffer[4]);
>  		format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]);
>  
> -		buflen -= buffer[0];
>  		buffer += buffer[0];
>  	}

This is a situation where I think that the unused assignment helps
readability because it shows how buflen and buffer are connected.

regards,
dan carpenter
  
Laurent Pinchart May 3, 2021, 10:07 a.m. UTC | #2
On Mon, May 03, 2021 at 12:29:24PM +0300, Dan Carpenter wrote:
> On Fri, Apr 30, 2021 at 06:18:14PM -0400, Nigel Christian wrote:
> > The variable buflen is being assigned a value that is never read,
> > which can be removed.
> > 
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Nigel Christian <nigel.l.christian@gmail.com>
> > ---
> >  drivers/media/usb/uvc/uvc_driver.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> > index 9a791d8ef200..370b086c6e22 100644
> > --- a/drivers/media/usb/uvc/uvc_driver.c
> > +++ b/drivers/media/usb/uvc/uvc_driver.c
> > @@ -768,7 +768,6 @@ static int uvc_parse_format(struct uvc_device *dev,
> >  		format->xfer_func = uvc_xfer_func(buffer[4]);
> >  		format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]);
> >  
> > -		buflen -= buffer[0];
> >  		buffer += buffer[0];
> >  	}
> 
> This is a situation where I think that the unused assignment helps
> readability because it shows how buflen and buffer are connected.

And removing it may cause issues later if we end up adding more code
below (unlikely in practice though). I'd rather keep this line.
  

Patch

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 9a791d8ef200..370b086c6e22 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -768,7 +768,6 @@  static int uvc_parse_format(struct uvc_device *dev,
 		format->xfer_func = uvc_xfer_func(buffer[4]);
 		format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]);
 
-		buflen -= buffer[0];
 		buffer += buffer[0];
 	}