lkml.org 
[lkml]   [2013]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/15] drivers/sh/intc/of_intc.c: adjust duplicate test
Date
From: Julia Lawall <Julia.Lawall@lip6.fr>

Delete successive tests to the same location. In this case intc_node has
already been tested for being NULL, and calling of_find_node_by_name will
not make it NULL. On the other hand, of_find_node_by_name can return NULL
on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@s exists@
local idexpression y;
expression x,e;
@@

*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
{ ... when forall
return ...; }
... when != \(y = e\|y += e\|y -= e\|y |= e\|y &= e\|y++\|y--\|&y\)
when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
{ ... when forall
return ...; }
// </smpl>

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

---
drivers/sh/intc/of_intc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sh/intc/of_intc.c b/drivers/sh/intc/of_intc.c
index 1d5f47e..8dfded3 100644
--- a/drivers/sh/intc/of_intc.c
+++ b/drivers/sh/intc/of_intc.c
@@ -330,7 +330,7 @@ static int __init of_sh_intc_get_prio(struct device_node *np,

reg_node = of_find_node_by_name(intc_node, node_name);

- if (!intc_node) {
+ if (!reg_node) {
pr_err("INTC prio register not found\n");
ret = -EINVAL;
goto error;
@@ -386,7 +386,7 @@ static int __init of_sh_intc_get_sense(struct device_node *np,

reg_node = of_find_node_by_name(intc_node, node_name);

- if (!intc_node) {
+ if (!reg_node) {
pr_err("INTC senses register not found\n");
ret = -EINVAL;
goto error;


\
 
 \ /
  Last update: 2013-01-21 16:21    [W:0.274 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site