diff options
author | Ezequiel Garcia <elezegarcia@gmail.com> | 2012-10-23 14:57:07 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-12-27 15:44:46 -0500 |
commit | 5869bb39f8e1f671746dcb5f070e3b1c38b23e5c (patch) | |
tree | 197aa51ef5ee694c1427862740b992296993d03b | |
parent | 8fe392b8fdb93ced86e1661bff91af95ee234cf9 (diff) |
[media] sn9c102: Replace memcpy with struct assignment
This kind of memcpy() is error-prone. Its replacement with a struct
assignment is prefered because it's type-safe and much easier to read.
Found by coccinelle. Hand patched and reviewed.
Tested by compilation only.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier struct_name;
struct struct_name to;
struct struct_name from;
expression E;
@@
-memcpy(&(to), &(from), E);
+to = from;
// </smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/usb/sn9c102/sn9c102_core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/usb/sn9c102/sn9c102_core.c b/drivers/media/usb/sn9c102/sn9c102_core.c index 6bda81aebf87..c957e9aa6077 100644 --- a/drivers/media/usb/sn9c102/sn9c102_core.c +++ b/drivers/media/usb/sn9c102/sn9c102_core.c | |||
@@ -2827,7 +2827,7 @@ sn9c102_vidioc_querybuf(struct sn9c102_device* cam, void __user * arg) | |||
2827 | b.index >= cam->nbuffers || cam->io != IO_MMAP) | 2827 | b.index >= cam->nbuffers || cam->io != IO_MMAP) |
2828 | return -EINVAL; | 2828 | return -EINVAL; |
2829 | 2829 | ||
2830 | memcpy(&b, &cam->frame[b.index].buf, sizeof(b)); | 2830 | b = cam->frame[b.index].buf; |
2831 | 2831 | ||
2832 | if (cam->frame[b.index].vma_use_count) | 2832 | if (cam->frame[b.index].vma_use_count) |
2833 | b.flags |= V4L2_BUF_FLAG_MAPPED; | 2833 | b.flags |= V4L2_BUF_FLAG_MAPPED; |
@@ -2930,7 +2930,7 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, | |||
2930 | 2930 | ||
2931 | f->state = F_UNUSED; | 2931 | f->state = F_UNUSED; |
2932 | 2932 | ||
2933 | memcpy(&b, &f->buf, sizeof(b)); | 2933 | b = f->buf; |
2934 | if (f->vma_use_count) | 2934 | if (f->vma_use_count) |
2935 | b.flags |= V4L2_BUF_FLAG_MAPPED; | 2935 | b.flags |= V4L2_BUF_FLAG_MAPPED; |
2936 | 2936 | ||