broken 0 sized memset checks?
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
Quoted 16 lines · Dave Jones
I ran sparse over the current linux kernel, and noticed this..
drivers/net/chelsio/sge.c:341:9: warning: memset with byte count of 0drivers/net/chelsio/sge.c:469:9: warning: memset with byte count of 0The 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);
Quoted 1 line
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