mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Himangi Saraogi <himangi774@gmail.com>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <mmarek@suse.cz>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Coccinelle : Script to detect cast after memory allocation
Date: Sat, 14 Jun 2014 10:01:54 -0700	[thread overview]
Message-ID: <1402765314.2756.20.camel@joe-AO725> (raw)
In-Reply-To: <alpine.DEB.2.02.1406141809050.1962@localhost6.localdomain6>

On Sat, 2014-06-14 at 18:11 +0200, Julia Lawall wrote:
> On Sat, 14 Jun 2014, Joe Perches wrote:
[]
> > Perhaps make this more generic for any void *?
> > 
> > Something like:
> > 
> > @@
> > void *t;
> > type other;
> > @@
> > 
> > -       (other *)t
> > +       t
[]
> Perhaps it would be reasonable to add this among the specific functions.  
> That is, t could be part of the disjunctions.

You do have to make sure that the
"casted to" type is not dereferenced.

ie: don't transform

void func(void *foo)
{
	unsigned long bar = *(unsigned long *)foo;
}

Also there may be some __user cast types and
such that may be necessary to exclude too.




  reply	other threads:[~2014-06-14 17:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-14 15:45 Himangi Saraogi
2014-06-14 16:06 ` Joe Perches
2014-06-14 16:11   ` Julia Lawall
2014-06-14 17:01     ` Joe Perches [this message]
     [not found]       ` <CAB78YHwDpK988sKk5pzXWhuMszyyS=wtk5ETP-B-JBGdwRPxhw@mail.gmail.com>
2014-06-14 19:37         ` Julia Lawall
2014-06-14 20:03         ` Joe Perches

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=1402765314.2756.20.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=Gilles.Muller@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=himangi774@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=nicolas.palix@imag.fr \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®