Skip to contentSkip to conversation

fpga: fpga-bridge: remove unnecessary null check in of_fpga_bridge_get

PATCH In review Gustavo A. R. Silva 3 participants 5 messages Oct 27, 2017 – Oct 30, 2017 FPGA manager framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: fpga-bridge: remove unnecessary null check in of_fpga_bridge_get

Notice that bridge = to_fpga_bridge(dev); expands to:

bridge = container_of(dev, struct fpga_bridge, dev);

and container_of is never null, so this null check is unnecessary.

Addresses-Coverity-ID: 1397912

---
 drivers/fpga/fpga-bridge.c | 2 --
 1 file changed, 2 deletions(-)
drivers/fpga/fpga-bridge.c +0 -2
index 9651aa5..409d1ac 100644
@@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
 		goto err_dev;
 
 	bridge = to_fpga_bridge(dev);
-	if (!bridge)
-		goto err_dev;
 
 	bridge->info = info;
 
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Gustavo A. R. Silva

Notice that bridge = to_fpga_bridge(dev); expands to:

bridge = container_of(dev, struct fpga_bridge, dev);

and container_of is never null, so this null check is unnecessary.

Addresses-Coverity-ID: 1397912

Quoted 24 lines
---
 drivers/fpga/fpga-bridge.c | 2 --
 1 file changed, 2 deletions(-)
drivers/fpga/fpga-bridge.c +0 -2
index 9651aa5..409d1ac 100644
@@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
 		goto err_dev;
 
 	bridge = to_fpga_bridge(dev);
-	if (!bridge)
-		goto err_dev;
 
 	bridge->info = info;
 
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks for the fix,

Moritz

#2 lore raw

Hi Moritz,

Quoting Moritz Fischer <[email protected]>:

Quoted 33 lines · Gustavo A. R. Silva
Quoted 10 lines

Notice that bridge = to_fpga_bridge(dev); expands to:

bridge = container_of(dev, struct fpga_bridge, dev);

and container_of is never null, so this null check is unnecessary.

Addresses-Coverity-ID: 1397912

Quoted 21 lines
---
 drivers/fpga/fpga-bridge.c | 2 --
 1 file changed, 2 deletions(-)
drivers/fpga/fpga-bridge.c +0 -3
index 9651aa5..409d1ac 100644
@@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct  
 device_node *np,
 		goto err_dev;
 
 	bridge = to_fpga_bridge(dev);
-	if (!bridge)
-		goto err_dev;
 
 	bridge->info = info;
 
--

2.7.4

Quoted 7 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks for the fix,

Glad to help.

Thanks
--
Gustavo A. R. Silva

#3 lore raw
In reply to Moritz Fischer

On Sat, Oct 28, 2017 at 12:15 PM, Moritz Fischer <[email protected]> wrote:

Hi Gustavo,

Thanks!

Alan

Quoted 5 lines · Gustavo A. R. Silva
Quoted 4 lines

Notice that bridge = to_fpga_bridge(dev); expands to:

bridge = container_of(dev, struct fpga_bridge, dev);

Quoted 7 lines
Quoted 6 lines

and container_of is never null, so this null check is unnecessary.

Addresses-Coverity-ID: 1397912

Quoted 28 lines
Quoted 20 lines
---
 drivers/fpga/fpga-bridge.c | 2 --
 1 file changed, 2 deletions(-)
drivers/fpga/fpga-bridge.c +0 -3
index 9651aa5..409d1ac 100644
@@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
              goto err_dev;
 
      bridge = to_fpga_bridge(dev);
-     if (!bridge)
-             goto err_dev;
 
      bridge->info = info;
 
--

2.7.4

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks for the fix,

Moritz