]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] mpt2sas: take size of pointed value, not pointer
authorJulia Lawall <julia@diku.dk>
Fri, 16 Sep 2011 06:57:34 +0000 (08:57 +0200)
committerJames Bottomley <JBottomley@Parallels.com>
Thu, 22 Sep 2011 11:13:12 +0000 (15:13 +0400)
Sizeof a pointer-typed expression returns the size of the pointer, not that
of the pointed data.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *e;
type T;
identifier f;
@@

f(...,(T)e,...,
-sizeof(e)
+sizeof(*e)
,...)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/mpt2sas/mpt2sas_transport.c

index 15c798026217d3b1f595a68bf9eb66e02b9f37a7..230732241aa2ff86b4de8ec6aa953351f4a1d9ed 100644 (file)
@@ -163,7 +163,7 @@ _transport_set_identify(struct MPT2SAS_ADAPTER *ioc, u16 handle,
                return -EIO;
        }
 
-       memset(identify, 0, sizeof(identify));
+       memset(identify, 0, sizeof(*identify));
        device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
 
        /* sas_address */