[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <8e7ba7c0-b7fe-a1f0-d28b-0c716ecbcfdb@web.de>
Date: Sun, 17 Feb 2019 10:50:05 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: Wen Yang <yellowriver2010@...mail.com>,
Julia Lawall <Julia.Lawall@...6.fr>
Cc: Gilles Muller <Gilles.Muller@...6.fr>,
Nicolas Palix <nicolas.palix@...g.fr>,
Michal Marek <michal.lkml@...kovi.net>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Wen Yang <wen.yang99@....com.cn>,
Cheng Shengyu <cheng.shengyu@....com.cn>,
kernel-janitors@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>,
Coccinelle <cocci@...teme.lip6.fr>
Subject: Re: [PATCH v6] coccinelle: semantic code search for missing
put_device()
> +@...rch exists@
> +local idexpression id;
> +expression x,e,e1;
> +position p1,p2;
> +type T,T1,T2;
> +@@
> +
> +id = of_find_device_by_node@p1(x)
> +... when != e = id
I suggest to increase your software development attention also for
another implementation detail.
Source code analysis triggers challenges for safe data flow handling.
the semantic patch language supports search specifications for
the exclusion of specific assignments.
Does this SmPL code contain a questionable order for the source
and target metavariables?
Can the following variant be more appropriate?
+ ... when != id = e
> +if (id == NULL || ...) { ... return ...; }
> +... when != put_device(&id->dev)
> + when != platform_device_put(id)
> + when != of_dev_put(id)
> + when != if (id) { ... put_device(&id->dev) ... }
> + when != e1 = (T)id
Would you like to avoid that the return value from the shown function call
gets overwritten in the variable before it was used once at least
(when a bit of extra C code is tolerated before a null pointer check)?
Regards,
Markus
Powered by blists - more mailing lists