net/usb: remove goto in ax88772_reset()
Subsystems (4)
PATCH 1/1 net/usb: remove goto in ax88772_reset()
goto statements in ax88772_reset() in net/usb/asix_devices.c are used to return ret variable. As function by default returns 0 if ret variable >= 0 and "out:" only returns ret, I assume goto might be removed.
--- drivers/net/usb/asix_devices.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/usb/asix_devices.c +3 -6
@@ -332,23 +332,20 @@ static int ax88772_reset(struct usbnet *dev) ret =asix_write_cmd (dev,AX_CMD_WRITE_NODE_ID ,0 ,0 ,ETH_ALEN , data->mac_addr,0 );if (ret <0 ) - goto out; +return ret;/* Set RX_CTL to default values with 2k buffer, and enable cactus */ ret =asix_write_rx_ctl (dev,AX_DEFAULT_RX_CTL ,0 );if (ret <0 ) - goto out; +return ret; ret =asix_write_medium_mode (dev,AX88772_MEDIUM_DEFAULT ,0 );if (ret <0 ) - goto out; +return ret;phy_start (priv->phydev);return 0 ; - -out: -return ret; }static int ax88772_hw_reset (struct usbnet *dev,int in_pm)
Signature · 1 line
2.34.0
Greg KH
maintainerQuoted 30 lines · Adam Kandur
goto statements in
ax88772_reset()innet/usb/asix_devices.care used to return ret variable. As function by default returns 0 if ret variable >= 0 and "out:" only returns ret, I assume goto might be removed.Signed-off-by Adam Kandur <[email protected]>--- drivers/net/usb/asix_devices.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/net/usb/asix_devices.c +2
-2@@ -332,23 +332,20 @@ static int ax88772_reset(struct usbnet *dev) ret =asix_write_cmd (dev,AX_CMD_WRITE_NODE_ID ,0 ,0 ,ETH_ALEN , data->mac_addr,0 );if (ret <0 ) - goto out; +return ret;/* Set RX_CTL to default values with 2k buffer, and enable cactus */ ret =asix_write_rx_ctl (dev,AX_DEFAULT_RX_CTL ,0 );if (ret <0 ) - goto out; +return ret; ret =asix_write_medium_mode (dev,AX88772_MEDIUM_DEFAULT ,0 );if (ret <0 )
drivers/net/usb/asix_devices.c static int ax88772_reset(struct usbnet *dev) · line 349
Quoted 10 lines
drivers/net/usb/asix_devices.c +1
-4- goto out; +return ret;phy_start (priv->phydev);return 0 ; - -out: -return ret; }
There is nothing wrong with the goto here, it's the common error path style for the kernel. Why should it be removed? What is the benefit here?
thanks,
greg k-h
Greetings.
I thought, there is no reason to have out label. Because it has only one return statement and there is return 0 before. So it seemed to me that "goto out;" could be replaced with the "return ret;" line. Which seems more readable to me.
thanks,
adam k.
Quoted 50 lines · Greg KH
Quoted 30 lines · Adam Kandur
goto statements in
ax88772_reset()innet/usb/asix_devices.care used to return ret variable. As function by default returns 0 if ret variable >= 0 and "out:" only returns ret, I assume goto might be removed.Signed-off-by Adam Kandur <[email protected]>--- drivers/net/usb/asix_devices.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/net/usb/asix_devices.c +2
-2@@ -332,23 +332,20 @@ static int ax88772_reset(struct usbnet *dev) ret =asix_write_cmd (dev,AX_CMD_WRITE_NODE_ID ,0 ,0 ,ETH_ALEN , data->mac_addr,0 );if (ret <0 ) - goto out; +return ret;/* Set RX_CTL to default values with 2k buffer, and enable cactus */ ret =asix_write_rx_ctl (dev,AX_DEFAULT_RX_CTL ,0 );if (ret <0 ) - goto out; +return ret; ret =asix_write_medium_mode (dev,AX88772_MEDIUM_DEFAULT ,0 );if (ret <0 )drivers/net/usb/asix_devices.c static int ax88772_reset(struct usbnet *dev) · line 349
Quoted 10 lines
drivers/net/usb/asix_devices.c +1
-4- goto out; +return ret;phy_start (priv->phydev);return 0 ; - -out: -return ret; }There is nothing wrong with the goto here, it's the common error path style for the kernel. Why should it be removed? What is the benefit here?
thanks,
greg k-h