All of lore.kernel.org
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Finding missing return value checks for some function calls with SmPL
Date: Fri, 2 Dec 2016 11:44:00 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.10.1612021143050.3056@hadrien> (raw)
In-Reply-To: <e853f47b-78be-7450-a420-b301f4f504d1@users.sourceforge.net>



On Fri, 2 Dec 2016, SF Markus Elfring wrote:

> > Now I wonder why the first assignment is not marked together with the function call
> > for further considerations by my source code analysis approach so far.
>
> I should have adjusted one of the used regular expressions a bit more like the following.
>
>
> @find_too_late_checking@
> expression ex1, ex2;
> identifier action1 =~ "^(?x)
> (?:
>    kzalloc
> |  kmalloc_array
> )$",
>            action2 =~ "^(?x)
> (?:
>    kzalloc
> |  kmalloc(?:_array)?
> )$",
>            work;
> type return_type;
> @@
>  return_type work(...)
>  {
>  ... when any
> *ex1 = action1(...);
>  ex2 = action2(...);
>  ... when any
>  }
>
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt show_too_late_checking2.cocci ../Probe/clk-mstp-excerpt1.c
> init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
> HANDLING: ../Probe/clk-mstp-excerpt1.c
> diff =
> --- ../Probe/clk-mstp-excerpt1.c
> +++ /tmp/cocci-output-20109-52f048-clk-mstp-excerpt1.c
> @@ -5,7 +5,6 @@ static void __init cpg_mstp_clocks_init(
>  	struct clk **clks;
>  	unsigned int i;
>
> -	group = kzalloc(sizeof(*group), GFP_KERNEL);
>  	clks = kmalloc(MSTP_MAX_CLOCKS * sizeof(*clks), GFP_KERNEL);
>  	if (group == NULL || clks == NULL) {
>  		kfree(group);
>
>
> I imagine that there are further software improvements to consider around
> such use cases.

Not sure what you are asking about here.  Note that it is unlikely that
anyone would accept a patch on the above code.  Group is tested before it
is used.

julia

  reply	other threads:[~2016-12-02 10:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02 10:00 [Cocci] Finding missing return value checks for some function calls with SmPL SF Markus Elfring
2016-12-02 10:20 ` SF Markus Elfring
2016-12-02 10:44   ` Julia Lawall [this message]
2016-12-02 11:55     ` SF Markus Elfring
     [not found]       ` <alpine.DEB.2.10.1612021324520.3056@hadrien>
2016-12-02 13:10         ` SF Markus Elfring
2016-12-02 13:38 ` [Cocci] Comparing SmPL script constraints with direct regular expression interface SF Markus Elfring
2016-12-02 13:42   ` Julia Lawall
2016-12-02 13:54     ` SF Markus Elfring
     [not found]       ` <alpine.DEB.2.10.1612021456580.3056@hadrien>
2016-12-02 14:20         ` SF Markus Elfring
     [not found]           ` <alpine.DEB.2.10.1612021526560.3056@hadrien>
2016-12-02 15:06             ` SF Markus Elfring
2016-12-02 20:48             ` SF Markus Elfring
2016-12-07 11:19               ` Michael Stefaniuc
2016-12-03 10:01 [Cocci] Excluding specific assignment combinations with SmPL SF Markus Elfring
2016-12-03 13:14 ` Julia Lawall
2016-12-03 17:43   ` SF Markus Elfring
2016-12-03 17:46     ` Julia Lawall
2016-12-03 17:58       ` SF Markus Elfring
2016-12-03 18:01         ` Julia Lawall
2016-12-06 10:15           ` [Cocci] Finding missing return value checks for some function calls " 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=alpine.DEB.2.10.1612021143050.3056@hadrien \
    --to=julia.lawall@lip6.fr \
    --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.