Patchwork [4/6] rtc-at91sam9: Correct size given to memset

login
register
mail settings
Submitter Alessandro Zummo
Date Jan. 20, 2010, 11:54 p.m.
Message ID <20100121005426.32665b23@linux.lan.towertech.it>
Download mbox | patch
Permalink /patch/43382/
State New
Headers show

Comments

Alessandro Zummo - Jan. 20, 2010, 11:54 p.m.
From: Julia Lawall <julia@diku.dk>

Memset should be given the size of the structure, not the size of the pointer.

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

// <smpl>
@@
type T;
T *x;
expression E;
@@

memset(x, E, sizeof(
+ *
 x))
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>

patch-name: 6-12-drivers-rtc-Correct-size-given-to-memset.patch
patch-rev1: 2016bb275bbeff1778779932b50d77f77f65fb24
patch-rev2: eea6ad3745b7f6f40dd4aec494fcf3d113008d83
---
 drivers/rtc/rtc-at91sam9.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 86c61f1..78a018b 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -161,7 +161,7 @@  static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (offset == 0)
 		return -EILSEQ;
 
-	memset(alrm, 0, sizeof(alrm));
+	memset(alrm, 0, sizeof(*alrm));
 	if (alarm != ALARM_DISABLED && offset != 0) {
 		rtc_time_to_tm(offset + alarm, tm);