* [PATCH] staging: wlan-ng: Fix memset warning found by sparse
@ 2015-06-18 17:49 Bilel DRIRA
2015-06-18 23:04 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Bilel DRIRA @ 2015-06-18 17:49 UTC (permalink / raw)
To: gregkh, eng.douglasfigueiredo, matt, josh, raghav3276,
tapaswenipathak, artemiyv
Cc: devel, linux-kernel, 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
Signed-off-by: Bilel DRIRA <bilel.dr@gmail.com>
---
drivers/staging/wlan-ng/prism2fw.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index fe36613589ae..7652ca70da1b 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -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;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: wlan-ng: Fix memset warning found by sparse
2015-06-18 17:49 [PATCH] staging: wlan-ng: Fix memset warning found by sparse Bilel DRIRA
@ 2015-06-18 23:04 ` Greg KH
2015-06-19 0:24 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-06-18 23:04 UTC (permalink / raw)
To: Bilel DRIRA
Cc: eng.douglasfigueiredo, matt, josh, raghav3276, tapaswenipathak,
artemiyv, devel, linux-kernel
On Thu, Jun 18, 2015 at 06:49:51PM +0100, Bilel DRIRA wrote:
> 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
>
> Signed-off-by: Bilel DRIRA <bilel.dr@gmail.com>
> ---
> drivers/staging/wlan-ng/prism2fw.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
> index fe36613589ae..7652ca70da1b 100644
> --- a/drivers/staging/wlan-ng/prism2fw.c
> +++ b/drivers/staging/wlan-ng/prism2fw.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: wlan-ng: Fix memset warning found by sparse
2015-06-18 23:04 ` Greg KH
@ 2015-06-19 0:24 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2015-06-19 0:24 UTC (permalink / raw)
To: Greg KH
Cc: Bilel DRIRA, eng.douglasfigueiredo, matt, josh, raghav3276,
tapaswenipathak, artemiyv, devel, linux-kernel
On Thu, 2015-06-18 at 16:04 -0700, Greg KH wrote:
> On Thu, Jun 18, 2015 at 06:49:51PM +0100, Bilel DRIRA wrote:
> > This patch fixes the following sparse warnings:
[]
> > diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
[]
> > @@ -245,10 +245,12 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,
[]
> > - 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-19 0:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18 17:49 [PATCH] staging: wlan-ng: Fix memset warning found by sparse Bilel DRIRA
2015-06-18 23:04 ` Greg KH
2015-06-19 0:24 ` Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.