Skip to contentSkip to conversation

s2255drv: cleanup vidioc_enum_fmt_cap()

PATCH In review Dan Carpenter 2 participants 2 messages Feb 17, 2012

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

PATCH 1/2 s2255drv: cleanup vidioc_enum_fmt_cap()

"f" wasn't checked consistently, so static checkers complain. This function is always called with a valid "f" pointer, so I have removed the check.

Also the indenting was messed up.

drivers/media/video/s2255drv.c +4 -6
index c1bef61..3505242 100644
@@ -852,15 +852,13 @@ static int vidioc_querycap(struct file *file, void *priv,
 static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
 			       struct v4l2_fmtdesc *f)
 {
-	int index = 0;
-	if (f)
-		index = f->index;
+	int index = f->index;
 
 	if (index >= ARRAY_SIZE(formats))
 		return -EINVAL;
-    if (!jpeg_enable && ((formats[index].fourcc = V4L2_PIX_FMT_JPEG) ||
-			 (formats[index].fourcc = V4L2_PIX_FMT_MJPEG)))
-	return -EINVAL;
+	if (!jpeg_enable && ((formats[index].fourcc = V4L2_PIX_FMT_JPEG) ||
+			(formats[index].fourcc = V4L2_PIX_FMT_MJPEG)))
+		return -EINVAL;
 	dprintk(4, "name %s\n", formats[index].name);
 	strlcpy(f->description, formats[index].name, sizeof(f->description));
 	f->pixelformat = formats[index].fourcc;
#1 lore raw

Thanks Dan,

I can sign off on this. The check isn't required.

Quoted 37 lines · Dan Carpenter

"f" wasn't checked consistently, so static checkers complain. This function is always called with a valid "f" pointer, so I have removed the check.

Also the indenting was messed up.

drivers/media/video/s2255drv.c +4 -7
index c1bef61..3505242 100644
@@ -852,15 +852,13 @@ static int vidioc_querycap(struct file *file, void *priv,
  static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
  			       struct v4l2_fmtdesc *f)
  {
-	int index = 0;
-	if (f)
-		index = f->index;
+	int index = f->index;
 
  	if (index>= ARRAY_SIZE(formats))
  		return -EINVAL;
-    if (!jpeg_enable&&  ((formats[index].fourcc = V4L2_PIX_FMT_JPEG) ||
-			 (formats[index].fourcc = V4L2_PIX_FMT_MJPEG)))
-	return -EINVAL;
+	if (!jpeg_enable&&  ((formats[index].fourcc = V4L2_PIX_FMT_JPEG) ||
+			(formats[index].fourcc = V4L2_PIX_FMT_MJPEG)))
+		return -EINVAL;
  	dprintk(4, "name %s\n", formats[index].name);
  	strlcpy(f->description, formats[index].name, sizeof(f->description));
  	f->pixelformat = formats[index].fourcc;
--

To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html