All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Finding missing return value checks for some function calls with SmPL
@ 2016-12-02 10:00 SF Markus Elfring
  2016-12-02 10:20 ` SF Markus Elfring
  2016-12-02 13:38 ` [Cocci] Comparing SmPL script constraints with direct regular expression interface SF Markus Elfring
  0 siblings, 2 replies; 13+ messages in thread
From: SF Markus Elfring @ 2016-12-02 10:00 UTC (permalink / raw)
  To: cocci

Hello,

I would like to try another search pattern out with the semantic patch language
from the software ?Coccinelle 1.0.6-00022-g862f5b29 (OCaml 4.03)?.


SmPL script example:

@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
 }


Source code example:

static void __init cpg_mstp_clocks_init(struct device_node *np)
{
	struct mstp_clock_group *group;
	const char *idxname;
	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);
		kfree(clks);
		pr_err("%s: failed to allocate group\n", __func__);
		return;
	}
}


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


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 would appreciate your advices.

Regards,
Markus

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [Cocci] Excluding specific assignment combinations with SmPL
@ 2016-12-03 10:01 SF Markus Elfring
  2016-12-03 13:14 ` Julia Lawall
  0 siblings, 1 reply; 13+ messages in thread
From: SF Markus Elfring @ 2016-12-03 10:01 UTC (permalink / raw)
  To: cocci

Hello,

I am experimenting with another source code search pattern. This approach
pointed a place like the following out for further considerations.

?
	ice->akm = kcalloc(?);
	ak = ice->akm;
?


My evolving SmPL script used also two separate metavariables with the
type ?expression? so that the value and target should be distinguished
for assignment statements. Now I would like to exclude cases where the target
is directly used again for the value specification as in the small example above.

How should be checked with the means of the semantic patch language that
the same expression is not used in subsequent lines?

Regards,
Markus

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-12-07 11:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.