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

[media] wl128x: 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
c84401c2 2b9b325d

+1 -2
+1 -2
drivers/media/radio/wl128x/fmdrv_common.c
··· 1563 1563 fmdev->irq_info.mask = FM_MAL_EVENT; 1564 1564 1565 1565 /* Region info */ 1566 - memcpy(&fmdev->rx.region, &region_configs[default_radio_region], 1567 - sizeof(struct region_info)); 1566 + fmdev->rx.region = region_configs[default_radio_region]; 1568 1567 1569 1568 fmdev->rx.mute_mode = FM_MUTE_OFF; 1570 1569 fmdev->rx.rf_depend_mute = FM_RX_RF_DEPENDENT_MUTE_OFF;