lkml.org 
[lkml]   [2011]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: make checkpatch warn about memset with swapped arguments.
On Thu, Mar 17, 2011 at 02:11:08PM -0700, Andrew Morton wrote:

> Dave's patch is tested (I assume), so it wins ;)

indeed, it's the one I've been using for.. ages.

> Maybe it's just me, but I think it would be better to use bzero() for
> this operation - it's more readable and it can't be screwed up. Then
> checkpatch checks for memset(xxx, 0, xxx) and for memset(xxx, xxx, 0)
> and says "hey, use bzero".

god yes. I don't know why it fell out of favor in userspace[*], but we
don't have to follow suit in the kernel. I thought we actually had
a generic bzero, but it seems not from a quick grep. I'll hack something up.

it only needs to be a #define bzero(x,y) memset (x, 0, y);

where should it live, linux/kernel.h ?

Dave


[*] man bzero shows.. "This function is deprecated", which is possibly one
of the dumbest moves ever, given how commonplace this bug is.


\
 
 \ /
  Last update: 2011-03-17 22:35    [W:0.352 / U:0.972 seconds]
©2003-2014 Jasper Spaans. Advertise on this site