Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH 0/2] test returned value
@ 2015-04-04 14:59 Julia Lawall
  2015-04-04 14:59 ` [PATCH 1/2] clk: versatile: " Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2015-04-04 14:59 UTC (permalink / raw)
  To: linux-clk; +Cc: kernel-janitors, linux-kernel, devel

Put NULL test on the result of the previous call instead on one of its
arguments.  The complete semantic match that finds these problems is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@r@
expression *e1;
expression *e2;
identifier f;
statement S1,S2;
position p,p2;
@@

 e1 = f@p(...,e2,...);
(
if (e1 == NULL || ...) S1 else S2
|
if (e1 != NULL || ...) S1 else S2
|
if@p2 (e2 == NULL || ...) S1 else S2
|
if@p2  (e2 != NULL || ...) S1 else S2
)

@ok@
expression e1,e2;
identifier f;
statement S1,S2;
position r.p,r.p2;
@@

 e1 = f@p(...);
(
if@p2 (e2 == NULL || ...) S1 else S2
|
if@p2  (e2 != NULL || ...) S1 else S2
)

@ok1 depends on ok exists@
position r.p;
expression *r.e2;
expression e3;
identifier f,g;
@@

e2->g
... when != e2 = e3
    when != &e2
f@p

@ok2 depends on ok exists@
position r.p;
expression *r.e2;
expression e,e3;
statement S1,S2;
identifier f;
@@

(
if (e2 == NULL || ...) {... return ...;} else S2
|
if (e2 != NULL || ...) S1 else {... return ...;}
)
... when != e2 = e3
    when != &e2
e = f@p(...);

@depends on ok1 || ok2@
expression e1;
identifier f;
position r.p;
@@

* e1 = f@p(...);
// </smpl>


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

* [PATCH 1/2] clk: versatile: test returned value
  2015-04-04 14:59 [PATCH 0/2] test returned value Julia Lawall
@ 2015-04-04 14:59 ` Julia Lawall
  2015-04-08 18:25   ` Stephen Boyd
  2015-04-09  7:30   ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Julia Lawall @ 2015-04-04 14:59 UTC (permalink / raw)
  To: Mike Turquette; +Cc: kernel-janitors, Stephen Boyd, linux-clk, linux-kernel

Put NULL test on the result of the previous call instead on one of its
arguments.  A simplified version of the semantic match that finds this
problem is as follows (http://coccinelle.lip6.fr/):

// <smpl>
r@
expression *e1;
expression *e2;
identifier f;
statement S1,S2;
@@

e1 = f(...,e2,...);
(
if (e1 == NULL || ...) S1 else S2
|
*if (e2 == NULL || ...) S1 else S2
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/clk/versatile/clk-versatile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/versatile/clk-versatile.c b/drivers/clk/versatile/clk-versatile.c
index a76981e..7a4f863 100644
--- a/drivers/clk/versatile/clk-versatile.c
+++ b/drivers/clk/versatile/clk-versatile.c
@@ -69,7 +69,7 @@ static void __init cm_osc_setup(struct device_node *np,
 		struct device_node *parent;
 
 		parent = of_get_parent(np);
-		if (!np) {
+		if (!parent) {
 			pr_err("no parent on core module clock\n");
 			return;
 		}

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

* Re: [PATCH 1/2] clk: versatile: test returned value
  2015-04-04 14:59 ` [PATCH 1/2] clk: versatile: " Julia Lawall
@ 2015-04-08 18:25   ` Stephen Boyd
  2015-04-09  7:30   ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2015-04-08 18:25 UTC (permalink / raw)
  To: Julia Lawall, Mike Turquette, Linus Walleij
  Cc: kernel-janitors, linux-clk, Linux Kernel Mailing List

On 04/04/15 07:59, Julia Lawall wrote:
> Put NULL test on the result of the previous call instead on one of its
> arguments.  A simplified version of the semantic match that finds this
> problem is as follows (http://coccinelle.lip6.fr/):
>
> // <smpl>
> r@
> expression *e1;
> expression *e2;
> identifier f;
> statement S1,S2;
> @@
>
> e1 = f(...,e2,...);
> (
> if (e1 == NULL || ...) S1 else S2
> |
> *if (e2 == NULL || ...) S1 else S2
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---

Looks right. Linus?

>  drivers/clk/versatile/clk-versatile.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/versatile/clk-versatile.c b/drivers/clk/versatile/clk-versatile.c
> index a76981e..7a4f863 100644
> --- a/drivers/clk/versatile/clk-versatile.c
> +++ b/drivers/clk/versatile/clk-versatile.c
> @@ -69,7 +69,7 @@ static void __init cm_osc_setup(struct device_node *np,
>  		struct device_node *parent;
>  
>  		parent = of_get_parent(np);
> -		if (!np) {
> +		if (!parent) {
>  			pr_err("no parent on core module clock\n");
>  			return;
>  		}
>


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 1/2] clk: versatile: test returned value
  2015-04-04 14:59 ` [PATCH 1/2] clk: versatile: " Julia Lawall
  2015-04-08 18:25   ` Stephen Boyd
@ 2015-04-09  7:30   ` Linus Walleij
  2015-04-09 15:23     ` Stephen Boyd
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2015-04-09  7:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Mike Turquette, kernel-janitors, Stephen Boyd, linux-clk,
	linux-kernel@vger.kernel.org

On Sat, Apr 4, 2015 at 4:59 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:

> Put NULL test on the result of the previous call instead on one of its
> arguments.  A simplified version of the semantic match that finds this
> problem is as follows (http://coccinelle.lip6.fr/):
>
> // <smpl>
> r@
> expression *e1;
> expression *e2;
> identifier f;
> statement S1,S2;
> @@
>
> e1 = f(...,e2,...);
> (
> if (e1 == NULL || ...) S1 else S2
> |
> *if (e2 == NULL || ...) S1 else S2
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Yep that's a bug:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 1/2] clk: versatile: test returned value
  2015-04-09  7:30   ` Linus Walleij
@ 2015-04-09 15:23     ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2015-04-09 15:23 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Julia Lawall, Mike Turquette, kernel-janitors, linux-clk,
	linux-kernel@vger.kernel.org

On 04/09, Linus Walleij wrote:
> On Sat, Apr 4, 2015 at 4:59 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> 
> > Put NULL test on the result of the previous call instead on one of its
> > arguments.  A simplified version of the semantic match that finds this
> > problem is as follows (http://coccinelle.lip6.fr/):
> >
> > // <smpl>
> > r@
> > expression *e1;
> > expression *e2;
> > identifier f;
> > statement S1,S2;
> > @@
> >
> > e1 = f(...,e2,...);
> > (
> > if (e1 == NULL || ...) S1 else S2
> > |
> > *if (e2 == NULL || ...) S1 else S2
> > )
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Yep that's a bug:
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> 

Thanks. Applied to clk-next.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2015-04-09 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-04 14:59 [PATCH 0/2] test returned value Julia Lawall
2015-04-04 14:59 ` [PATCH 1/2] clk: versatile: " Julia Lawall
2015-04-08 18:25   ` Stephen Boyd
2015-04-09  7:30   ` Linus Walleij
2015-04-09 15:23     ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox