All of lore.kernel.org
 help / color / mirror / Atom feed
From: thomas.adam22@gmail.com (Thomas Adam)
To: cocci@systeme.lip6.fr
Subject: [Cocci] malloc/calloc/strup adding missing NULL checks
Date: Fri, 16 Dec 2016 19:10:12 +0000	[thread overview]
Message-ID: <20161216191011.cgxsa7mymssrjtsx@fbsd-laptop> (raw)
In-Reply-To: <alpine.DEB.2.10.1612162004510.3178@hadrien>

On Fri, Dec 16, 2016 at 08:05:35PM +0100, Julia Lawall wrote:
> 
> 
> On Fri, 16 Dec 2016, Thomas Adam wrote:
> 
> > On Fri, Dec 16, 2016 at 07:30:46PM +0100, Julia Lawall wrote:
> > > The file I got had only pkg_vset, with some comments and includes
> > > beforehand.  Perhaps you sent the wrong one.
> >
> > Sorry, I meant pkg_vset() -- there's too many moving parts!  I'm sending the
> > entire .c file so that you might better place it in context with the debug
> > file I attached in my previous email.  Needless to say, despite my
> > chopping/changing this file, it's still not working.
> 
> For me they are all transformed.  What is your version of spatch?  What is
> your command line?  What is your semantic patch (you sent it before, but I
> no longer have it)?

% spatch --version
spatch version 1.0.4 with Python support and with PCRE support

See 'unchecked_malloc.cocci' attached.

I'm invoking spatch like this:

spatch --in-place --sp-file ~/unchecked_malloc.cocci libpkg/pkg.c
init_defs_builtins: /usr/local/lib/coccinelle/standard.h
HANDLING: libpkg/pkg.c
Note: processing took    16.3s: libpkg/pkg.c

libpkg/pkg.c contains no transformations.

This is running atop of FreeBSD, should that somehow make any difference.

Thanks again!

Thomas
-------------- next part --------------
@@
expression T;
@@

T = malloc(...);
+ if (T == NULL)
+ 	pkg_emit_errno("malloc", __func__);
... when != (T == NULL)
    when != (T != NULL)

@@
expression T;
@@

T = calloc(...);
+ if (T == NULL)
+ 	pkg_emit_errno("calloc", __func__);
... when != (T == NULL)
    when != (T != NULL)

@@
expression T;
@@

T = realloc(...);
+ if (T == NULL)
+ 	pkg_emit_errno("realloc", __func__);
... when != (T == NULL)
    when != (T != NULL)

@@
expression T;
@@

T = strdup(...);
+ if (T == NULL)
+ 	pkg_emit_errno("strdup", __func__);
... when != (T == NULL)
    when != (T != NULL)

  reply	other threads:[~2016-12-16 19:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 11:34 [Cocci] malloc/calloc/strup adding missing NULL checks Thomas Adam
2016-12-16 11:44 ` Julia Lawall
2016-12-16 13:13   ` Thomas Adam
2016-12-16 13:54     ` Julia Lawall
2016-12-16 14:12       ` Thomas Adam
2016-12-16 14:33         ` Julia Lawall
2016-12-16 14:46           ` Thomas Adam
     [not found]             ` <alpine.DEB.2.10.1612161549220.6500@hadrien>
2016-12-16 17:08               ` Thomas Adam
     [not found]                 ` <alpine.DEB.2.10.1612161929450.3239@hadrien>
2016-12-16 18:37                   ` Thomas Adam
2016-12-16 19:05                     ` Julia Lawall
2016-12-16 19:10                       ` Thomas Adam [this message]
2016-12-16 19:21                         ` Julia Lawall
2016-12-16 19:31                           ` Thomas Adam
2016-12-16 19:33                             ` Julia Lawall
2016-12-16 21:55                               ` Thomas Adam
2016-12-20 19:45                                 ` [Cocci] … " SF Markus Elfring
2016-12-22 22:53                                   ` Thomas Adam
2016-12-23  6:43                                     ` Julia Lawall
2016-12-23  6:54                                     ` SF Markus Elfring

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=20161216191011.cgxsa7mymssrjtsx@fbsd-laptop \
    --to=thomas.adam22@gmail.com \
    --cc=cocci@systeme.lip6.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 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.