Skip to contentSkip to conversation

usb/uvc_v4l2: cleanup test for end of loop

PATCH In review Dan Carpenter 2 participants 2 messages Aug 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb/uvc_v4l2: cleanup test for end of loop

We're trying to test for the the end of the loop here. "format" is never NULL. We don't know what "format->fcc" is because we're past the end of the loop and I think "fmt->fmt.pix.pixelformat" comes from the user so we don't know what that is either. It works, but it's cleaner to just test to see if (i = ARRAY_SIZE(uvc_formats).

drivers/usb/gadget/uvc_v4l2.c +1 -1
index 2dcffda..5e807f0 100644
@@ -94,7 +94,7 @@ uvc_v4l2_set_format(struct uvc_video *video, struct v4l2_format *fmt)
 			break;
 	}
 
-	if (format = NULL || format->fcc != fmt->fmt.pix.pixelformat) {
+	if (i = ARRAY_SIZE(uvc_formats)) {
 		printk(KERN_INFO "Unsupported format 0x%08x.\n",
 			fmt->fmt.pix.pixelformat);
 		return -EINVAL;
Acked-by on v1 1/1
#1 lore raw

Hi Dan,

Thanks for the patch.

Quoted 7 lines · On Thursday 12 August 2010 09:59:58 Dan Carpenter wrote:

We're trying to test for the the end of the loop here. "format" is never NULL. We don't know what "format->fcc" is because we're past the end of the loop and I think "fmt->fmt.pix.pixelformat" comes from the user so we don't know what that is either. It works, but it's cleaner to just test to see if (i = ARRAY_SIZE(uvc_formats).

Quoted 13 lines
drivers/usb/gadget/uvc_v4l2.c +1 -1
index 2dcffda..5e807f0 100644
@@ -94,7 +94,7 @@ uvc_v4l2_set_format(struct uvc_video *video, struct
 v4l2_format *fmt) break;
 	}
 
-	if (format = NULL || format->fcc != fmt->fmt.pix.pixelformat) {
+	if (i = ARRAY_SIZE(uvc_formats)) {
 		printk(KERN_INFO "Unsupported format 0x%08x.\n",
 			fmt->fmt.pix.pixelformat);
 		return -EINVAL;
Signature · 3 lines
Regards,

Laurent Pinchart