Commit 01a5cbeb authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab

[media] ivtv: 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: default avatarPeter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: default avatarEzequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: default avatarAndy Walls <awalls@md.metrocast.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7f05b245
...@@ -719,13 +719,10 @@ int init_ivtv_i2c(struct ivtv *itv) ...@@ -719,13 +719,10 @@ int init_ivtv_i2c(struct ivtv *itv)
return -ENODEV; return -ENODEV;
} }
if (itv->options.newi2c > 0) { if (itv->options.newi2c > 0) {
memcpy(&itv->i2c_adap, &ivtv_i2c_adap_hw_template, itv->i2c_adap = ivtv_i2c_adap_hw_template;
sizeof(struct i2c_adapter));
} else { } else {
memcpy(&itv->i2c_adap, &ivtv_i2c_adap_template, itv->i2c_adap = ivtv_i2c_adap_template;
sizeof(struct i2c_adapter)); itv->i2c_algo = ivtv_i2c_algo_template;
memcpy(&itv->i2c_algo, &ivtv_i2c_algo_template,
sizeof(struct i2c_algo_bit_data));
} }
itv->i2c_algo.udelay = itv->options.i2c_clock_period / 2; itv->i2c_algo.udelay = itv->options.i2c_clock_period / 2;
itv->i2c_algo.data = itv; itv->i2c_algo.data = itv;
...@@ -735,8 +732,7 @@ int init_ivtv_i2c(struct ivtv *itv) ...@@ -735,8 +732,7 @@ int init_ivtv_i2c(struct ivtv *itv)
itv->instance); itv->instance);
i2c_set_adapdata(&itv->i2c_adap, &itv->v4l2_dev); i2c_set_adapdata(&itv->i2c_adap, &itv->v4l2_dev);
memcpy(&itv->i2c_client, &ivtv_i2c_client_template, itv->i2c_client = ivtv_i2c_client_template;
sizeof(struct i2c_client));
itv->i2c_client.adapter = &itv->i2c_adap; itv->i2c_client.adapter = &itv->i2c_adap;
itv->i2c_adap.dev.parent = &itv->pdev->dev; itv->i2c_adap.dev.parent = &itv->pdev->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment