Skip to content

Commit

Permalink
[SCSI] mpt2sas: take size of pointed value, not pointer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and James Bottomley committed Sep 22, 2011
1 parent 12b8fc1 commit 96a9950
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/mpt2sas/mpt2sas_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 96a9950

Please sign in to comment.