All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: jschopp <jschopp@austin.ibm.com>
Cc: apw@shadowen.org, rdunlap@xenotime.net,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: Make checkpatch warn about pointless casting of kalloc returns.
Date: Wed, 8 Aug 2007 14:00:56 -0400	[thread overview]
Message-ID: <20070808180056.GF26440@redhat.com> (raw)
In-Reply-To: <46B9F7C9.9060406@austin.ibm.com>

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

  reply	other threads:[~2007-08-08 18:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-08  2:43 Make checkpatch warn about pointless casting of kalloc returns Dave Jones
2007-08-08 17:05 ` jschopp
2007-08-08 18:00   ` Dave Jones [this message]
2007-08-08 18:10     ` Cal Peake
2007-08-08 18:27     ` jschopp
2007-08-08 18:40       ` Nish Aravamudan
2007-08-13 10:24   ` Andy Whitcroft

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070808180056.GF26440@redhat.com \
    --to=davej@redhat.com \
    --cc=apw@shadowen.org \
    --cc=jschopp@austin.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.