lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiDSCu96Sf6DzU+_+sFH4h6=aN9zV7+rLrn-Kxs-1Q5HCdOZg@mail.gmail.com>
Date: Thu, 22 Jan 2026 08:49:11 +0100
From: Ricardo Ribalda <ribalda@...omium.org>
To: Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc: Hans de Goede <hansg@...nel.org>, Mauro Carvalho Chehab <mchehab@...nel.org>, 
	Johannes Berg <johannes@...solutions.net>, Laurent Pinchart <laurent.pinchart@...net.be>, 
	linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] media: uvcvideo: use min() for npacket calculation

Hi Laurent

On Thu, 22 Jan 2026 at 02:49, Laurent Pinchart
<laurent.pinchart@...asonboard.com> wrote:
>
> Hi Ricardo,
>
> Thank you for the patch.
>
> On Wed, Jan 14, 2026 at 10:32:15AM +0000, Ricardo Ribalda wrote:
> > Make the code slightly more appealing by making use of min(). There
> > shall not be any functional change from this patch.
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
> > ---
> >  drivers/media/usb/uvc/uvc_video.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> > index 59eb95a4b70c05b1a12986e908b7e9979b064fd0..db02080f15772e0bc1d5cfcadd32463f4e6ea045 100644
> > --- a/drivers/media/usb/uvc/uvc_video.c
> > +++ b/drivers/media/usb/uvc/uvc_video.c
> > @@ -1808,9 +1808,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream,
> >        * Compute the number of packets. Bulk endpoints might transfer UVC
> >        * payloads across multiple URBs.
> >        */
> > -     npackets = DIV_ROUND_UP(size, psize);
> > -     if (npackets > UVC_MAX_PACKETS)
> > -             npackets = UVC_MAX_PACKETS;
> > +     npackets = min(UVC_MAX_PACKETS, DIV_ROUND_UP(size, psize));
>
> Do you think this improves readability ? I find the existing code easier
> to read, its purpose is immediately clear: it computes npackets and
> clamps it to a max value. With min() I have to pause and think.

I guess it is a matter of taste. I left it as a separate patch for that reason.

>
> I'll take patches 1/3 and 2/3 in my tree already as 1/3 fixes an issue.
Thanks!


Regards!

>
> >
> >       /* Retry allocations until one succeed. */
> >       for (; npackets > 0; npackets /= 2) {
>
> --
> Regards,
>
> Laurent Pinchart



-- 
Ricardo Ribalda

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ