Skip to contentSkip to conversation

staging: wlan-ng: Fix memset warning found by sparse

PATCH In review Bilel DRIRA 3 participants 3 messages Jun 18, 2015 – Jun 19, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wlan-ng: Fix memset warning found by sparse

This patch fixes the following sparse warnings:

drivers/staging/wlan-ng/prism2fw.c:251:15: warning: memset with byte count of 120000 drivers/staging/wlan-ng/prism2fw.c:470:15: warning: memset with byte count of 120000

---
 drivers/staging/wlan-ng/prism2fw.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/wlan-ng/prism2fw.c +6 -2
index fe36613589ae..7652ca70da1b 100644
@@ -245,10 +245,12 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,
 	struct p80211msg_dot11req_mibget getmsg;
 	p80211itemd_t *item;
 	u32 *data;
+	unsigned int s3data_count = 0;
 
 	/* Initialize the data structures */
 	ns3data = 0;
-	memset(s3data, 0, sizeof(s3data));
+	for (s3data_count = 0; s3data_count < S3DATA_MAX; s3data_count++)
+		memset(&s3data[s3data_count], 0, sizeof(struct s3datarec));
 	ns3plug = 0;
 	memset(s3plug, 0, sizeof(s3plug));
 	ns3crc = 0;
@@ -466,8 +468,10 @@ static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks)
 ----------------------------------------------------------------*/
 static void free_srecs(void)
 {
+	unsigned int s3data_count = 0;
 	ns3data = 0;
-	memset(s3data, 0, sizeof(s3data));
+	for (s3data_count = 0; s3data_count < S3DATA_MAX; s3data_count++)
+		memset(&s3data[s3data_count], 0, sizeof(struct s3datarec));
 	ns3plug = 0;
 	memset(s3plug, 0, sizeof(s3plug));
 	ns3crc = 0;
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 15 lines · Bilel DRIRA

This patch fixes the following sparse warnings:

drivers/staging/wlan-ng/prism2fw.c:251:15: warning: memset with byte count of 120000 drivers/staging/wlan-ng/prism2fw.c:470:15: warning: memset with byte count of 120000

---
 drivers/staging/wlan-ng/prism2fw.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/wlan-ng/prism2fw.c +0 -0
index fe36613589ae..7652ca70da1b 100644

drivers/staging/wlan-ng/prism2fw.c static int prism2_fwapply(const struct ihex_binrec *rfptr, · line 253

Quoted 10 lines
drivers/staging/wlan-ng/prism2fw.c +3 -1
@@ -245,10 +245,12 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,
 	struct p80211msg_dot11req_mibget getmsg;
 	p80211itemd_t *item;
 	u32 *data;
+	unsigned int s3data_count = 0;
 
 	/* Initialize the data structures */
 	ns3data = 0;
-	memset(s3data, 0, sizeof(s3data));
+	for (s3data_count = 0; s3data_count < S3DATA_MAX; s3data_count++)
+		memset(&s3data[s3data_count], 0, sizeof(struct s3datarec));

You are doing the exact same thing here that the original code did, so why change it?

That sparse warning is just a hint, I don't see anything wrong here with the original code, sorry.

greg k-h

#2 lore raw
Quoted 2 lines · Greg KH
Quoted 1 line · Bilel DRIRA

This patch fixes the following sparse warnings:

[]

Quoted 1 line

drivers/staging/wlan-ng/prism2fw.c

Quoted 1 line
drivers/staging/wlan-ng/prism2fw.c +0 -0

[]

Quoted 1 line

drivers/staging/wlan-ng/prism2fw.c static int prism2_fwapply(const struct ihex_binrec *rfptr,

Quoted 1 line
drivers/staging/wlan-ng/prism2fw.c +0 -0
@@ -245,10 +245,12 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,

[]

Quoted 9 lines

drivers/staging/wlan-ng/prism2fw.c static int prism2_fwapply(const struct ihex_binrec *rfptr, · line 253

Quoted 3 lines
drivers/staging/wlan-ng/prism2fw.c +2 -1
-	memset(s3data, 0, sizeof(s3data));
+	for (s3data_count = 0; s3data_count < S3DATA_MAX; s3data_count++)
+		memset(&s3data[s3data_count], 0, sizeof(struct s3datarec));

You are doing the exact same thing here that the original code did, so why change it?

That sparse warning is just a hint, I don't see anything wrong here with the original code, sorry.

Greg's right.

A possible improvement would be to malloc/free memory as necessary instead of using large static buffers.