* broken 0 sized memset checks?
@ 2006-09-05 21:05 Dave Jones
2006-09-05 21:20 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: Dave Jones @ 2006-09-05 21:05 UTC (permalink / raw)
To: linux-sparse
I ran sparse over the current linux kernel, and noticed this..
drivers/net/chelsio/sge.c:341:9: warning: memset with byte count of 0
drivers/net/chelsio/sge.c:469:9: warning: memset with byte count of 0
The first..
q->size = p->freelQ_size[i];
....
size = sizeof(struct freelQ_ce) * q->size;
q->centries = kmalloc(size, GFP_KERNEL);
if (!q->centries)
goto err_no_mem;
memset(q->centries, 0, size);
Looks valid enough, as does the second..
q->size = p->cmdQ_size[i];
....
size = sizeof(struct cmdQ_ce) * q->size;
q->centries = kmalloc(size, GFP_KERNEL);
if (!q->centries)
goto err_no_mem;
memset(q->centries, 0, size);
Sparse bug ?
Dave
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: broken 0 sized memset checks?
2006-09-05 21:05 broken 0 sized memset checks? Dave Jones
@ 2006-09-05 21:20 ` Linus Torvalds
0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2006-09-05 21:20 UTC (permalink / raw)
To: Dave Jones; +Cc: linux-sparse
On Tue, 5 Sep 2006, Dave Jones wrote:
>
> I ran sparse over the current linux kernel, and noticed this..
>
> drivers/net/chelsio/sge.c:341:9: warning: memset with byte count of 0
> drivers/net/chelsio/sge.c:469:9: warning: memset with byte count of 0
>
> The first..
>
> q->size = p->freelQ_size[i];
> ....
> size = sizeof(struct freelQ_ce) * q->size;
> q->centries = kmalloc(size, GFP_KERNEL);
> if (!q->centries)
> goto err_no_mem;
> memset(q->centries, 0, size);
>
> Sparse bug ?
I _suspect_ sparse has had some type-parsing bug, and thinks that
"sizeof(struct freelQ_ce)" is zero for some reason, and then does all the
constant folding (yeah, sparse is clever when it isn't really stupid ;),
and that's what is going on.
I'll see if I can figure out what's up.
Linus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-09-05 21:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-05 21:05 broken 0 sized memset checks? Dave Jones
2006-09-05 21:20 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox