[media] cx88: Replace memcpy with struct assignment
authorEzequiel Garcia <elezegarcia@gmail.com>
Tue, 23 Oct 2012 18:57:19 +0000 (15:57 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 27 Dec 2012 21:01:51 +0000 (19:01 -0200)
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>
drivers/media/pci/cx88/cx88-cards.c
drivers/media/pci/cx88/cx88-i2c.c
drivers/media/pci/cx88/cx88-vp3054-i2c.c

index 0c25524..e2e0b8f 100644 (file)
@@ -3743,7 +3743,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
                cx88_card_list(core, pci);
        }
 
-       memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board));
+       core->board = cx88_boards[core->boardnr];
 
        if (!core->board.num_frontends && (core->board.mpeg & CX88_MPEG_DVB))
                core->board.num_frontends = 1;
index de0f1af..cf2d696 100644 (file)
@@ -139,8 +139,7 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
        if (i2c_udelay<5)
                i2c_udelay=5;
 
-       memcpy(&core->i2c_algo, &cx8800_i2c_algo_template,
-              sizeof(core->i2c_algo));
+       core->i2c_algo = cx8800_i2c_algo_template;
 
 
        core->i2c_adap.dev.parent = &pci->dev;
index d77f8ec..deede6e 100644 (file)
@@ -118,8 +118,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
                return -ENOMEM;
        dev->vp3054 = vp3054_i2c;
 
-       memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template,
-              sizeof(vp3054_i2c->algo));
+       vp3054_i2c->algo = vp3054_i2c_algo_template;
 
        vp3054_i2c->adap.dev.parent = &dev->pci->dev;
        strlcpy(vp3054_i2c->adap.name, core->name,