[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 0c255248cbcdb2054a3e02d4899f6f2688c2844f..e2e0b8faf7a4021cb476c0c5e3a54f558bba0ca6 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 de0f1af74e415bc516cd9b12fd97b4b34a8cc45e..cf2d69615838a120d9293eadbf3e9d2f036fd1d2 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 d77f8ecab9d7e6d7c4cc8eaad534dcf0d3c72188..deede6e25d94d90386e7a7a675b273cd6b13bac5 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,