diff mbox

[2/2] sh_eth: kill redundant check in the probe() method

Message ID 20171231184448.233694839@cogentembedded.com (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Sergei Shtylyov Dec. 31, 2017, 6:41 p.m. UTC
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! :-)

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/net/ethernet/renesas/sh_eth.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Geert Uytterhoeven Jan. 2, 2018, 7:54 a.m. UTC | #1
H Sergei,

On Sun, Dec 31, 2017 at 7:41 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> 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!

> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
> +++ net-next/drivers/net/ethernet/renesas/sh_eth.c
> @@ -3282,8 +3282,7 @@ out_napi_del:
>
>  out_release:
>         /* net_dev free */
> -       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 -- geert@linux-m68k.org

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
diff mbox

Patch

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -3282,8 +3282,7 @@  out_napi_del:
 
 out_release:
 	/* net_dev free */
-	if (ndev)
-		free_netdev(ndev);
+	free_netdev(ndev);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);