All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 7/7] uvc_v4l2.c: avoid using iterator used outside loop
Date: Mon, 9 May 2022 13:04:15 +0300	[thread overview]
Message-ID: <YnjnH6TPVi1kV/Yv@valkosipuli.retiisi.eu> (raw)
In-Reply-To: <20220509091553.2637089-8-hverkuil-cisco@xs4all.nl>

Hi Hans,

Thanks for the set.

On Mon, May 09, 2022 at 11:15:53AM +0200, Hans Verkuil wrote:
> Fixes these two smatch warnings:
> 
> drivers/media/usb/uvc/uvc_v4l2.c:885 uvc_ioctl_enum_input() warn: iterator used outside loop: 'iterm'
> drivers/media/usb/uvc/uvc_v4l2.c:896 uvc_ioctl_enum_input() warn: iterator used outside loop: 'iterm'
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/media/usb/uvc/uvc_v4l2.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 711556d13d03..ff3f04af4e21 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c

...

> @@ -879,21 +880,25 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh,
>  		if (index != 0)
>  			return -EINVAL;
>  		list_for_each_entry(iterm, &chain->entities, chain) {
> -			if (UVC_ENTITY_IS_ITERM(iterm))
> +			if (UVC_ENTITY_IS_ITERM(iterm)) {
> +				pin = iterm->id;
> +				found_pin = true;
>  				break;
> +			}
>  		}
> -		pin = iterm->id;
>  	} else if (index < selector->bNrInPins) {
>  		pin = selector->baSourceID[index];
>  		list_for_each_entry(iterm, &chain->entities, chain) {
>  			if (!UVC_ENTITY_IS_ITERM(iterm))
>  				continue;
> -			if (iterm->id == pin)
> +			if (iterm->id == pin) {
> +				found_pin = true;
>  				break;
> +			}
>  		}
>  	}
>  
> -	if (iterm == NULL || iterm->id != pin)
> +	if (!found_pin)
>  		return -EINVAL;
>  
>  	memset(input, 0, sizeof(*input));

iterm is used a few lines below, too, so this patch doesn't remove its use
outside the loop. Which btw. I don't think is a problem at all. Doing that
is relatively common IMO.

For the rest of the set:

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Kind regards,

Sakari Ailus

  reply	other threads:[~2022-05-09 10:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  9:15 [PATCH 0/7] Various smatch fixes Hans Verkuil
2022-05-09  9:15 ` [PATCH 1/7] v4l2-subdev.c: kvmalloc_array -> kvcalloc Hans Verkuil
2022-05-09 10:29   ` Laurent Pinchart
2022-05-09  9:15 ` [PATCH 2/7] v4l2-ctls-core.c: " Hans Verkuil
2022-05-09 10:29   ` Laurent Pinchart
2022-05-09  9:15 ` [PATCH 3/7] videobuf2-dma-sg.c: " Hans Verkuil
2022-05-09 10:29   ` Laurent Pinchart
2022-05-09  9:15 ` [PATCH 4/7] cx25821: request_irq -> devm_request_irq Hans Verkuil
2022-05-09  9:15 ` [PATCH 5/7] ccs-core.c: fix failure to call clk_disable_unprepare Hans Verkuil
2022-05-09  9:15 ` [PATCH 6/7] s5k6a3: add missing clk_disable_unprepare Hans Verkuil
2022-05-09  9:15 ` [PATCH 7/7] uvc_v4l2.c: avoid using iterator used outside loop Hans Verkuil
2022-05-09 10:04   ` Sakari Ailus [this message]
2022-05-09 10:09   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YnjnH6TPVi1kV/Yv@valkosipuli.retiisi.eu \
    --to=sakari.ailus@iki.fi \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.