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

[media] zr36067: 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
37320d7b 8ba6220f

+1 -2
+1 -2
drivers/media/pci/zoran/zoran_card.c
··· 708 708 static int 709 709 zoran_register_i2c (struct zoran *zr) 710 710 { 711 - memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, 712 - sizeof(struct i2c_algo_bit_data)); 711 + zr->i2c_algo = zoran_i2c_bit_data_template; 713 712 zr->i2c_algo.data = zr; 714 713 strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), 715 714 sizeof(zr->i2c_adapter.name));