staging/easycap: Avoid compiler warning about frame size ... larger than ...

Replacing some of the large automatic variables by dynamically allocated
variables in the IOCTL routines gets rid of the compiler warning.

Signed-off-by: Mike Thomas <rmthomas@sciolus.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Mike Thomas 2010-11-07 20:07:12 +00:00 committed by Greg Kroah-Hartman
parent 94155cf419
commit 2a87a0b922
1 changed files with 96 additions and 59 deletions

View File

@ -956,8 +956,8 @@ return -ENOENT;
static int easycap_ioctl_bkl(struct inode *inode, struct file *file, static int easycap_ioctl_bkl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
static struct easycap *peasycap; struct easycap *peasycap;
static struct usb_device *p; struct usb_device *p;
if (NULL == file) { if (NULL == file) {
SAY("ERROR: file is NULL\n"); SAY("ERROR: file is NULL\n");
@ -974,13 +974,6 @@ if (NULL == p) {
return -EFAULT; return -EFAULT;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/*
* MOST OF THE VARIABLES DECLARED static IN THE case{} BLOCKS BELOW ARE SO
* DECLARED SIMPLY TO AVOID A COMPILER WARNING OF THE KIND:
* easycap_ioctl.c: warning:
* the frame size of ... bytes is larger than 1024 bytes
*/
/*---------------------------------------------------------------------------*/
switch (cmd) { switch (cmd) {
case VIDIOC_QUERYCAP: { case VIDIOC_QUERYCAP: {
struct v4l2_capability v4l2_capability; struct v4l2_capability v4l2_capability;
@ -1247,57 +1240,67 @@ case VIDIOC_QUERYMENU: {
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_CTRL: { case VIDIOC_G_CTRL: {
struct v4l2_control v4l2_control; struct v4l2_control *pv4l2_control;
JOM(8, "VIDIOC_G_CTRL\n"); JOM(8, "VIDIOC_G_CTRL\n");
pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL);
if (0 != copy_from_user(&v4l2_control, (void __user *)arg, \ if (!pv4l2_control) {
sizeof(struct v4l2_control))) SAM("ERROR: out of memory\n");
return -ENOMEM;
}
if (0 != copy_from_user(pv4l2_control, (void __user *)arg, \
sizeof(struct v4l2_control))) {
kfree(pv4l2_control);
return -EFAULT; return -EFAULT;
}
switch (v4l2_control.id) { switch (pv4l2_control->id) {
case V4L2_CID_BRIGHTNESS: { case V4L2_CID_BRIGHTNESS: {
v4l2_control.value = peasycap->brightness; pv4l2_control->value = peasycap->brightness;
JOM(8, "user enquires brightness: %i\n", v4l2_control.value); JOM(8, "user enquires brightness: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_CONTRAST: { case V4L2_CID_CONTRAST: {
v4l2_control.value = peasycap->contrast; pv4l2_control->value = peasycap->contrast;
JOM(8, "user enquires contrast: %i\n", v4l2_control.value); JOM(8, "user enquires contrast: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_SATURATION: { case V4L2_CID_SATURATION: {
v4l2_control.value = peasycap->saturation; pv4l2_control->value = peasycap->saturation;
JOM(8, "user enquires saturation: %i\n", v4l2_control.value); JOM(8, "user enquires saturation: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_HUE: { case V4L2_CID_HUE: {
v4l2_control.value = peasycap->hue; pv4l2_control->value = peasycap->hue;
JOM(8, "user enquires hue: %i\n", v4l2_control.value); JOM(8, "user enquires hue: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_AUDIO_VOLUME: { case V4L2_CID_AUDIO_VOLUME: {
v4l2_control.value = peasycap->volume; pv4l2_control->value = peasycap->volume;
JOM(8, "user enquires volume: %i\n", v4l2_control.value); JOM(8, "user enquires volume: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_AUDIO_MUTE: { case V4L2_CID_AUDIO_MUTE: {
if (1 == peasycap->mute) if (1 == peasycap->mute)
v4l2_control.value = true; pv4l2_control->value = true;
else else
v4l2_control.value = false; pv4l2_control->value = false;
JOM(8, "user enquires mute: %i\n", v4l2_control.value); JOM(8, "user enquires mute: %i\n", pv4l2_control->value);
break; break;
} }
default: { default: {
SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", \ SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", \
v4l2_control.id); pv4l2_control->id);
kfree(pv4l2_control);
return -EINVAL; return -EINVAL;
} }
} }
if (0 != copy_to_user((void __user *)arg, &v4l2_control, \ if (0 != copy_to_user((void __user *)arg, pv4l2_control, \
sizeof(struct v4l2_control))) sizeof(struct v4l2_control))) {
kfree(pv4l2_control);
return -EFAULT; return -EFAULT;
}
kfree(pv4l2_control);
break; break;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@ -1596,8 +1599,9 @@ case VIDIOC_ENUM_FRAMEINTERVALS: {
} }
if (0 != copy_from_user(&v4l2_frmivalenum, (void __user *)arg, \ if (0 != copy_from_user(&v4l2_frmivalenum, (void __user *)arg, \
sizeof(struct v4l2_frmivalenum))) sizeof(struct v4l2_frmivalenum))) {
return -EFAULT; return -EFAULT;
}
index = v4l2_frmivalenum.index; index = v4l2_frmivalenum.index;
@ -1632,29 +1636,50 @@ case VIDIOC_ENUM_FRAMEINTERVALS: {
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_FMT: { case VIDIOC_G_FMT: {
struct v4l2_format v4l2_format; struct v4l2_format *pv4l2_format;
struct v4l2_pix_format v4l2_pix_format; struct v4l2_pix_format *pv4l2_pix_format;
JOM(8, "VIDIOC_G_FMT\n"); JOM(8, "VIDIOC_G_FMT\n");
pv4l2_format = kzalloc(sizeof(struct v4l2_format), GFP_KERNEL);
if (0 != copy_from_user(&v4l2_format, (void __user *)arg, \ if (!pv4l2_format) {
sizeof(struct v4l2_format))) SAM("ERROR: out of memory\n");
return -ENOMEM;
}
pv4l2_pix_format = kzalloc(sizeof(struct v4l2_pix_format), GFP_KERNEL);
if (!pv4l2_pix_format) {
SAM("ERROR: out of memory\n");
kfree(pv4l2_format);
return -ENOMEM;
}
if (0 != copy_from_user(pv4l2_format, (void __user *)arg, \
sizeof(struct v4l2_format))) {
kfree(pv4l2_format);
kfree(pv4l2_pix_format);
return -EFAULT; return -EFAULT;
}
if (v4l2_format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (pv4l2_format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
kfree(pv4l2_format);
kfree(pv4l2_pix_format);
return -EINVAL; return -EINVAL;
}
memset(&v4l2_pix_format, 0, sizeof(struct v4l2_pix_format)); memset(pv4l2_pix_format, 0, sizeof(struct v4l2_pix_format));
v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; pv4l2_format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
memcpy(&(v4l2_format.fmt.pix), \ memcpy(&pv4l2_format->fmt.pix, \
&(easycap_format[peasycap->format_offset]\ &easycap_format[peasycap->format_offset]\
.v4l2_format.fmt.pix), sizeof(v4l2_pix_format)); .v4l2_format.fmt.pix, sizeof(struct v4l2_pix_format));
JOM(8, "user is told: %s\n", \ JOM(8, "user is told: %s\n", \
&easycap_format[peasycap->format_offset].name[0]); &easycap_format[peasycap->format_offset].name[0]);
if (0 != copy_to_user((void __user *)arg, &v4l2_format, \ if (0 != copy_to_user((void __user *)arg, pv4l2_format, \
sizeof(struct v4l2_format))) sizeof(struct v4l2_format))) {
kfree(pv4l2_format);
kfree(pv4l2_pix_format);
return -EFAULT; return -EFAULT;
}
kfree(pv4l2_format);
kfree(pv4l2_pix_format);
break; break;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@ -2196,38 +2221,50 @@ case VIDIOC_STREAMOFF: {
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_PARM: { case VIDIOC_G_PARM: {
struct v4l2_streamparm v4l2_streamparm; struct v4l2_streamparm *pv4l2_streamparm;
JOM(8, "VIDIOC_G_PARM\n"); JOM(8, "VIDIOC_G_PARM\n");
pv4l2_streamparm = kzalloc(sizeof(struct v4l2_streamparm), GFP_KERNEL);
if (0 != copy_from_user(&v4l2_streamparm, (void __user *)arg, \ if (!pv4l2_streamparm) {
sizeof(struct v4l2_streamparm))) SAM("ERROR: out of memory\n");
return -ENOMEM;
}
if (0 != copy_from_user(pv4l2_streamparm, (void __user *)arg, \
sizeof(struct v4l2_streamparm))) {
kfree(pv4l2_streamparm);
return -EFAULT; return -EFAULT;
}
if (v4l2_streamparm.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (pv4l2_streamparm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
kfree(pv4l2_streamparm);
return -EINVAL; return -EINVAL;
v4l2_streamparm.parm.capture.capability = 0; }
v4l2_streamparm.parm.capture.capturemode = 0; pv4l2_streamparm->parm.capture.capability = 0;
v4l2_streamparm.parm.capture.timeperframe.numerator = 1; pv4l2_streamparm->parm.capture.capturemode = 0;
pv4l2_streamparm->parm.capture.timeperframe.numerator = 1;
if (peasycap->fps) { if (peasycap->fps) {
v4l2_streamparm.parm.capture.timeperframe.\ pv4l2_streamparm->parm.capture.timeperframe.\
denominator = peasycap->fps; denominator = peasycap->fps;
} else { } else {
if (true == peasycap->ntsc) { if (true == peasycap->ntsc) {
v4l2_streamparm.parm.capture.timeperframe.\ pv4l2_streamparm->parm.capture.timeperframe.\
denominator = 30; denominator = 30;
} else { } else {
v4l2_streamparm.parm.capture.timeperframe.\ pv4l2_streamparm->parm.capture.timeperframe.\
denominator = 25; denominator = 25;
} }
} }
v4l2_streamparm.parm.capture.readbuffers = peasycap->frame_buffer_many; pv4l2_streamparm->parm.capture.readbuffers = \
v4l2_streamparm.parm.capture.extendedmode = 0; peasycap->frame_buffer_many;
if (0 != copy_to_user((void __user *)arg, &v4l2_streamparm, \ pv4l2_streamparm->parm.capture.extendedmode = 0;
sizeof(struct v4l2_streamparm))) if (0 != copy_to_user((void __user *)arg, pv4l2_streamparm, \
sizeof(struct v4l2_streamparm))) {
kfree(pv4l2_streamparm);
return -EFAULT; return -EFAULT;
}
kfree(pv4l2_streamparm);
break; break;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */