[U-Boot] [PATCH] removed '!' in for loop stop condition
Tom Rini
trini at konsulko.com
Tue Aug 27 14:07:10 UTC 2019
On Tue, Aug 27, 2019 at 03:08:36PM +0200, Marek Vasut wrote:
> On 8/27/19 3:02 PM, Niv Shetrit wrote:
> > Signed-off-by: Niv Shetrit <niv.shetrit at altair-semi.com>
> > ---
> > drivers/usb/gadget/core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/core.c b/drivers/usb/gadget/core.c
> > index ffaf161fb7..ae7387ee0a 100644
> > --- a/drivers/usb/gadget/core.c
> > +++ b/drivers/usb/gadget/core.c
> > @@ -307,7 +307,7 @@ struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor (struct usb_devi
> > struct usb_endpoint_descriptor *endpoint_descriptor;
> > int i;
> >
> > - for (i = 0; !(endpoint_descriptor = usbd_device_endpoint_descriptor_index (device, port, configuration, interface, alternate, i)); i++) {
> > + for (i = 0; endpoint_descriptor = usbd_device_endpoint_descriptor_index (device, port, configuration, interface, alternate, i); i++) {
> > if (endpoint_descriptor->bEndpointAddress == endpoint) {
> > return endpoint_descriptor;
> > }
> >
>
> This changes the behavior of the code. Why is this needed ? The patch
> needs detailed explanation of and rationale behind the change.
To start with, please put the coverity message you're addressing in the
commit itself, not the introductory patch. Also please use Reported-by:
Coverity (CID: xxx) in the commit itself.
That said, not all issues coverity finds are strictly a problem and may
be intentional or false positive. Coverity is complaining about how
we're testing things here, but this rewrite doesn't have the same
behavior. This type of issue is also a "code isn't as clear as it could
be" thing because yes, it's uncommon to write the loop as it is here,
but it's correct. Thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190827/3bd2b280/attachment.sig>
More information about the U-Boot
mailing list