Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] dvb-usb/friio-fe: 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>

authored by

Ezequiel Garcia and committed by
Mauro Carvalho Chehab
d3a95091 37320d7b

+2 -3
+2 -3
drivers/media/usb/dvb-usb/friio-fe.c
··· 421 421 422 422 /* setup the state */ 423 423 state->i2c = &d->i2c_adap; 424 - memcpy(&state->config, &friio_fe_config, sizeof(friio_fe_config)); 424 + state->config = friio_fe_config; 425 425 426 426 /* create dvb_frontend */ 427 - memcpy(&state->frontend.ops, &jdvbt90502_ops, 428 - sizeof(jdvbt90502_ops)); 427 + state->frontend.ops = jdvbt90502_ops; 429 428 state->frontend.demodulator_priv = state; 430 429 431 430 if (jdvbt90502_init(&state->frontend) < 0)