Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format()
@ 2026-08-20 20:11 Sergey Shtylyov
  2026-08-20 20:15 ` Sergey Shtylyov
  2026-08-27  9:24 ` Ricardo Ribalda
  0 siblings, 2 replies; 6+ messages in thread
From: Sergey Shtylyov @ 2026-08-20 20:11 UTC (permalink / raw)
  To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab,
	linux-media
  Cc: Sergey Shtylyov

Close to the end of uvc_parse_format(), the parameter buflen is decremented
(again) but that statement seems pointless as buflen isn't used afterwards.
Drop the useless assignment (gcc doesn't generate any code for it anyways).

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
---
 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 e289cc71ba98..0e78e8bcd320 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -520,7 +520,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];
 	} else {
 		format->colorspace = V4L2_COLORSPACE_SRGB;
-- 
2.55.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format()
  2026-08-20 20:11 [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format() Sergey Shtylyov
@ 2026-08-20 20:15 ` Sergey Shtylyov
  2026-08-27  9:24 ` Ricardo Ribalda
  1 sibling, 0 replies; 6+ messages in thread
From: Sergey Shtylyov @ 2026-08-20 20:15 UTC (permalink / raw)
  To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab,
	linux-media

On 8/20/26 11:11 PM, Sergey Shtylyov wrote:

> Close to the end of uvc_parse_format(), the parameter buflen is decremented
> (again) but that statement seems pointless as buflen isn't used afterwards.
> Drop the useless assignment (gcc doesn't generate any code for it anyways).
> 
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
    Duh, forgot to add that the patch is against the next branch of the
linuxtv.org/media.git repo!

[...]

MBR, Sergey


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format()
  2026-08-20 20:11 [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format() Sergey Shtylyov
  2026-08-20 20:15 ` Sergey Shtylyov
@ 2026-08-27  9:24 ` Ricardo Ribalda
  2026-09-28 20:29   ` Laurent Pinchart
  1 sibling, 1 reply; 6+ messages in thread
From: Ricardo Ribalda @ 2026-08-27  9:24 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab,
	linux-media

Hi Sergey

On Thu, 20 Aug 2026 at 22:12, Sergey Shtylyov <s.shtylyov@auroraos.dev> wrote:
>
> Close to the end of uvc_parse_format(), the parameter buflen is decremented
> (again) but that statement seems pointless as buflen isn't used afterwards.
> Drop the useless assignment (gcc doesn't generate any code for it anyways).

The patch is correct, although I do not see a great benefit in
removing it. As you say, the compiler will remove it anyway. If we
modify the function to add logging or continue parsing the left over
buffer, it is going to come back to haunt us....

I leave it to Laurent or HansG to decide if they want to merge it.

Thanks!


>
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
>
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
> ---
>  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 e289cc71ba98..0e78e8bcd320 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -520,7 +520,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];
>         } else {
>                 format->colorspace = V4L2_COLORSPACE_SRGB;
> --
> 2.55.0
>


--
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format()
  2026-08-27  9:24 ` Ricardo Ribalda
@ 2026-09-28 20:29   ` Laurent Pinchart
  2026-09-29  9:16     ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2026-09-28 20:29 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Sergey Shtylyov, Hans de Goede, Mauro Carvalho Chehab,
	linux-media

On Thu, Aug 27, 2026 at 11:24:33AM +0200, Ricardo Ribalda wrote:
> Hi Sergey
> 
> On Thu, 20 Aug 2026 at 22:12, Sergey Shtylyov <s.shtylyov@auroraos.dev> wrote:
> >
> > Close to the end of uvc_parse_format(), the parameter buflen is decremented
> > (again) but that statement seems pointless as buflen isn't used afterwards.
> > Drop the useless assignment (gcc doesn't generate any code for it anyways).
> 
> The patch is correct, although I do not see a great benefit in
> removing it. As you say, the compiler will remove it anyway. If we
> modify the function to add logging or continue parsing the left over
> buffer, it is going to come back to haunt us....
> 
> I leave it to Laurent or HansG to decide if they want to merge it.

I'd rather keep the buflen update in place for the reasons explained by
Ricardo.

/me wishes for std::span<> in C

> > Found by Linux Verification Center (linuxtesting.org) with the Svace static
> > analysis tool.
> >
> > Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
> > ---
> >  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 e289cc71ba98..0e78e8bcd320 100644
> > --- a/drivers/media/usb/uvc/uvc_driver.c
> > +++ b/drivers/media/usb/uvc/uvc_driver.c
> > @@ -520,7 +520,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];
> >         } else {
> >                 format->colorspace = V4L2_COLORSPACE_SRGB;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format()
  2026-09-28 20:29   ` Laurent Pinchart
@ 2026-09-29  9:16     ` Hans de Goede
  2026-09-29 14:25       ` Sergey Shtylyov
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2026-09-29  9:16 UTC (permalink / raw)
  To: Laurent Pinchart, Ricardo Ribalda
  Cc: Sergey Shtylyov, Mauro Carvalho Chehab, linux-media

Hi,

On 28-Sep-26 22:29, Laurent Pinchart wrote:
> On Thu, Aug 27, 2026 at 11:24:33AM +0200, Ricardo Ribalda wrote:
>> Hi Sergey
>>
>> On Thu, 20 Aug 2026 at 22:12, Sergey Shtylyov <s.shtylyov@auroraos.dev> wrote:
>>>
>>> Close to the end of uvc_parse_format(), the parameter buflen is decremented
>>> (again) but that statement seems pointless as buflen isn't used afterwards.
>>> Drop the useless assignment (gcc doesn't generate any code for it anyways).
>>
>> The patch is correct, although I do not see a great benefit in
>> removing it. As you say, the compiler will remove it anyway. If we
>> modify the function to add logging or continue parsing the left over
>> buffer, it is going to come back to haunt us....
>>
>> I leave it to Laurent or HansG to decide if they want to merge it.
> 
> I'd rather keep the buflen update in place for the reasons explained by
> Ricardo.
> 
> /me wishes for std::span<> in C

Ack, I've dropped this patch from patchwork.

Regards,

Hans


> 
>>> Found by Linux Verification Center (linuxtesting.org) with the Svace static
>>> analysis tool.
>>>
>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
>>> ---
>>>  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 e289cc71ba98..0e78e8bcd320 100644
>>> --- a/drivers/media/usb/uvc/uvc_driver.c
>>> +++ b/drivers/media/usb/uvc/uvc_driver.c
>>> @@ -520,7 +520,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];
>>>         } else {
>>>                 format->colorspace = V4L2_COLORSPACE_SRGB;
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format()
  2026-09-29  9:16     ` Hans de Goede
@ 2026-09-29 14:25       ` Sergey Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Shtylyov @ 2026-09-29 14:25 UTC (permalink / raw)
  To: Hans de Goede, Laurent Pinchart, Ricardo Ribalda
  Cc: Mauro Carvalho Chehab, linux-media

On 9/29/26 12:16 PM, Hans de Goede wrote:

[...]

>>>> Close to the end of uvc_parse_format(), the parameter buflen is decremented
>>>> (again) but that statement seems pointless as buflen isn't used afterwards.
>>>> Drop the useless assignment (gcc doesn't generate any code for it anyways).
>>>
>>> The patch is correct, although I do not see a great benefit in
>>> removing it. As you say, the compiler will remove it anyway. If we
>>> modify the function to add logging or continue parsing the left over
>>> buffer, it is going to come back to haunt us....
>>>
>>> I leave it to Laurent or HansG to decide if they want to merge it.
>>
>> I'd rather keep the buflen update in place for the reasons explained by
>> Ricardo.
>>
>> /me wishes for std::span<> in C
> 
> Ack, I've dropped this patch from patchwork.

   OK, but why "Not Applicable" and not "Rejected"? :-)

> Regards,
> 
> Hans
[...]

MBR, Sergey


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-29 14:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 20:11 [PATCH] media: uvcvideo: drop useless assignment in uvc_parse_format() Sergey Shtylyov
2026-08-20 20:15 ` Sergey Shtylyov
2026-08-27  9:24 ` Ricardo Ribalda
2026-09-28 20:29   ` Laurent Pinchart
2026-09-29  9:16     ` Hans de Goede
2026-09-29 14:25       ` Sergey Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox