Skip to contentSkip to conversation

ravb: kill redundant check in the probe() method

PATCH In review Sergei Shtylyov 2 participants 3 messages Dec 31, 2017 – Jan 2, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ravb: kill redundant check in the probe() method

Browsing thru the driver diassembly, I noticed that gcc was able to figure out that the 'ndev' pointer is always non-NULL when calling free_netdev() on the probe() method's error path and thus skip that redundant NULL check... gcc is smart, be like gcc! :-)

---
 drivers/net/ethernet/renesas/ravb_main.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +1 -2
Index: net-next/drivers/net/ethernet/renesas/ravb_main.c
===================================================================
@@ -2205,8 +2205,7 @@ out_dma_free:
 	if (chip_id != RCAR_GEN2)
 		ravb_ptp_stop(ndev);
 out_release:
-	if (ndev)
-		free_netdev(ndev);
+	free_netdev(ndev);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
Reviewed-by on v1 1/2
#1 lore raw

Hi Sergei,

Quoted 4 lines · Sergei Shtylyov

Browsing thru the driver diassembly, I noticed that gcc was able to figure out that the 'ndev' pointer is always non-NULL when calling free_netdev() on the probe() method's error path and thus skip that redundant NULL check... gcc is smart, be like gcc! :-)

Thanks for your patch!

Quoted 1 line

drivers/net/ethernet/renesas/ravb_main.c out_dma_free: · line 2211

Quoted 12 lines
drivers/net/ethernet/renesas/ravb_main.c +1 -2
@@ -2205,8 +2205,7 @@ out_dma_free:
        if (chip_id != RCAR_GEN2)
                ravb_ptp_stop(ndev);
 out_release:
-       if (ndev)
-               free_netdev(ndev);
+       free_netdev(ndev);
 
        pm_runtime_put(&pdev->dev);
        pm_runtime_disable(&pdev->dev);

BTW, there isn't a functional dependency, but you may want to move the freeing of the netdev below disabling of Runtime PM for symmetry (use reverse order in cleanup).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw
In reply to Sergei Shtylyov

Hello!

Quoted 1 line · Sergei Shtylyov

Browsing thru the driver diassembly, I noticed that gcc was able to

Aw, it's disassembly!
DaveM, is that worth reposting?

Quoted 5 lines

figure out that the 'ndev' pointer is always non-NULL when calling free_netdev() on the probe() method's error path and thus skip that redundant NULL check... gcc is smart, be like gcc!

[...]

MBR, Sergei