lkml.org 
[lkml]   [2007]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Make checkpatch warn about pointless casting of kalloc returns.
On Wed, Aug 08, 2007 at 12:05:13PM -0500, jschopp wrote:
> > +# check for pointless casting of kmalloc return
> > + if ($rawline =~ /\*\)[ ]k[czm]alloc/) {
>
> It looks to me like this will catch
>
> foo = (char *) kmalloc(512);
>
> but not
>
> for = (char* )kmalloc(512);
>
> I haven't tried it but how about something like:
>
> if($rawline =~/\(.*\)\s*k[czm]alloc/){

Hmm, could even just drop the check for the '*'
)[ ]k.. should be good enough.

> which if I got it right should match the typecast with any combination of spacing.
>
> > + WARN("No need to cast return value.\n");
>
> Could the warning be more descriptive? This describes what, but it should also describe
> why; after all if somebody made this error they may not know they why.

I'm open to suggestions..

Dave

--
http://www.codemonkey.org.uk
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-08-08 20:03    [W:0.188 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site