summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-03-03 20:21:02 -0800
committerTrent Piepho <xyzzy@speakeasy.org>2009-03-03 20:21:02 -0800
commitf848a016635d7ec5b7624ef9235b5a39ca0afee7 (patch)
tree2b9206f040b1ef2fbb685964c5beed52ad8d7ac3 /linux
parent4f05fe5a173aafe4fd81efaa5a3288f2ab482ca1 (diff)
downloadmediapointer-dvb-s2-f848a016635d7ec5b7624ef9235b5a39ca0afee7.tar.gz
mediapointer-dvb-s2-f848a016635d7ec5b7624ef9235b5a39ca0afee7.tar.bz2
v4l2: Zero out read-only ioctls in one place
From: Trent Piepho <xyzzy@speakeasy.org> If an ioctl is read-only then the driver fills in all the fields. Lots of times drivers only care about some fields so it's best if video_ioctl2 takes care of zeroing out the entire structure before handing it to the driver. This saves code in each driver to do it and driver authors often forget. The existing memset code in some of the read-only ioctl handlers can be deleted. Convert a case statement to a single if statement. Deleted a debug line from ENUMAUDOUT that was copy-and-pasted to G_AUDOUT by mistake. Priority: normal Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/video/v4l2-ioctl.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/linux/drivers/media/video/v4l2-ioctl.c b/linux/drivers/media/video/v4l2-ioctl.c
index 71e7633b5..90a58523b 100644
--- a/linux/drivers/media/video/v4l2-ioctl.c
+++ b/linux/drivers/media/video/v4l2-ioctl.c
@@ -656,8 +656,6 @@ static long __video_do_ioctl(struct file *file,
if (cmd == VIDIOCGMBUF) {
struct video_mbuf *p = arg;
- memset(p, 0, sizeof(*p));
-
if (!ops->vidiocgmbuf)
return ret;
ret = ops->vidiocgmbuf(file, fh, p);
@@ -684,7 +682,6 @@ static long __video_do_ioctl(struct file *file,
case VIDIOC_QUERYCAP:
{
struct v4l2_capability *cap = (struct v4l2_capability *)arg;
- memset(cap, 0, sizeof(*cap));
if (!ops->vidioc_querycap)
break;
@@ -1368,7 +1365,6 @@ static long __video_do_ioctl(struct file *file,
if (!ops->vidioc_g_audio)
break;
- memset(p, 0, sizeof(*p));
ret = ops->vidioc_g_audio(file, fh, p);
if (!ret)
dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
@@ -1410,7 +1406,7 @@ static long __video_do_ioctl(struct file *file,
if (!ops->vidioc_g_audout)
break;
- dbgarg(cmd, "Enum for index=%d\n", p->index);
+
ret = ops->vidioc_g_audout(file, fh, p);
if (!ret)
dbgarg2("index=%d, name=%s, capability=%d, "
@@ -1507,8 +1503,6 @@ static long __video_do_ioctl(struct file *file,
if (!ops->vidioc_g_jpegcomp)
break;
- memset(p, 0, sizeof(*p));
-
ret = ops->vidioc_g_jpegcomp(file, fh, p);
if (!ret)
dbgarg(cmd, "quality=%d, APPn=%d, "
@@ -1874,13 +1868,7 @@ long video_ioctl2(struct file *file,
cmd == VIDIOC_TRY_EXT_CTRLS);
/* Copy arguments into temp kernel buffer */
- switch (_IOC_DIR(cmd)) {
- case _IOC_NONE:
- parg = NULL;
- break;
- case _IOC_READ:
- case _IOC_WRITE:
- case (_IOC_WRITE | _IOC_READ):
+ if (_IOC_DIR(cmd) != _IOC_NONE) {
if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
parg = sbuf;
} else {
@@ -1901,8 +1889,10 @@ long video_ioctl2(struct file *file,
/* zero out anything we don't copy from userspace */
if (n < _IOC_SIZE(cmd))
memset((u8 *)parg + n, 0, _IOC_SIZE(cmd) - n);
+ } else {
+ /* read-only ioctl */
+ memset(parg, 0, _IOC_SIZE(cmd));
}
- break;
}
if (is_ext_ctrl) {