linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: gdm72xx: remove unneeded test
@ 2015-05-27 20:25 Laurent Navet
  2015-05-27 20:30 ` Joe Perches
  2015-05-27 20:46 ` Fabio Estevam
  0 siblings, 2 replies; 12+ messages in thread
From: Laurent Navet @ 2015-05-27 20:25 UTC (permalink / raw)
  To: gregkh; +Cc: benchan, devel, linux-kernel, Laurent Navet

The same code is executed regardless ret value, so this test can be
removed.

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
---
 drivers/staging/gdm72xx/usb_boot.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c
index 3ccc447..7f80553 100644
--- a/drivers/staging/gdm72xx/usb_boot.c
+++ b/drivers/staging/gdm72xx/usb_boot.c
@@ -255,8 +255,6 @@ static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
 
 	/*Wait for ACK*/
 	ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
-	if (ret < 0)
-		goto out;
 out:
 	return ret;
 }
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-27 20:25 [PATCH] staging: gdm72xx: remove unneeded test Laurent Navet
@ 2015-05-27 20:30 ` Joe Perches
  2015-05-28  5:43   ` Julia Lawall
  2015-05-28  7:14   ` Dan Carpenter
  2015-05-27 20:46 ` Fabio Estevam
  1 sibling, 2 replies; 12+ messages in thread
From: Joe Perches @ 2015-05-27 20:30 UTC (permalink / raw)
  To: Laurent Navet; +Cc: gregkh, benchan, devel, linux-kernel, Julia Lawall

On Wed, 2015-05-27 at 22:25 +0200, Laurent Navet wrote:
> The same code is executed regardless ret value, so this test can be
> removed.
[]
> diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c
[]
> @@ -255,8 +255,6 @@ static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
>  
>  	/*Wait for ACK*/
>  	ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
> -	if (ret < 0)
> -		goto out;
>  out:
>  	return ret;
>  }

Perhaps all of the uses like:

	goto <foo>;
<foo>:

could be modified.  There are ~150 in the kernel.

$ grep-2.5.4 -rP --include=*.[ch] -n "\bgoto\s+(\w+)\s*;\s*\1\s*:" * | \
  grep -P "^[\w/\.:]+\d+:"
arch/x86/xen/enlighten.c:1018:	case MSR_GS_BASE:		which = SEGBASE_GS_KERNEL; goto set;
arch/m68k/amiga/config.c:258:		goto Generic;
arch/s390/net/bpf_jit_comp.c:1078:		goto call_fn;
arch/sparc/kernel/pci_msi.c:67:	goto err_out;
drivers/gpu/drm/radeon/atombios_dp.c:882:		goto done;
drivers/gpu/drm/nouveau/nouveau_bo.c:1225:		goto out;
drivers/gpu/drm/nouveau/nv50_display.c:1476:		goto out;
drivers/gpu/drm/i915/intel_display.c:12678:		goto out;
drivers/isdn/mISDN/dsp_cmx.c:1572:	goto send_packet;
drivers/input/mouse/cyapa_gen5.c:1772:		goto resume_scanning;
drivers/input/mouse/cyapa_gen5.c:2340:		goto resume_scanning;
drivers/mmc/host/s3cmci.c:798:	goto irq_out;
drivers/mmc/host/ushc.c:313:		goto out;
drivers/mmc/card/mmc_test.c:2918:		goto err;
drivers/staging/lustre/lustre/mdc/mdc_request.c:1271:	goto out;
drivers/staging/lustre/lustre/mdc/mdc_request.c:1305:	goto out;
drivers/staging/lustre/lustre/mdc/mdc_request.c:1372:	goto out;
drivers/staging/lustre/lustre/mdc/mdc_request.c:1455:	goto out;
drivers/staging/lustre/lustre/mdc/mdc_request.c:1518:	goto out;
drivers/staging/lustre/lustre/mdc/mdc_request.c:1815:		goto out;
drivers/staging/lustre/lustre/llite/file.c:691:	goto out_och_free;
drivers/staging/lustre/lustre/llite/file.c:1161:	goto out;
drivers/staging/lustre/lustre/llite/file.c:1301:	goto out;
drivers/staging/lustre/lustre/llite/xattr_cache.c:452:	goto out_maybe_drop;
drivers/staging/lustre/lustre/llite/xattr_cache.c:532:	goto out;
drivers/staging/lustre/lustre/llite/dir.c:683:		goto err_exit;
drivers/staging/lustre/lustre/llite/dir.c:1941:	goto out;
drivers/staging/lustre/lustre/llite/namei.c:556:	goto out;
drivers/staging/lustre/lustre/llite/llite_lib.c:2115:		goto out_statfs;
drivers/staging/lustre/lustre/llite/rw.c:1204:	goto out;
drivers/staging/lustre/lustre/obdecho/echo_client.c:2130:	goto out;
drivers/staging/lustre/lustre/fld/fld_request.c:377:		goto out;
drivers/staging/lustre/lustre/obdclass/obd_mount.c:1225:	goto out;
drivers/staging/lustre/lustre/obdclass/dt_object.c:734:	goto out;
drivers/staging/lustre/lustre/obdclass/dt_object.c:934:	goto out;
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c:1857:	goto out;
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c:310:	goto out;
drivers/staging/iio/meter/ade7758_core.c:436:		goto error_ret;
drivers/staging/iio/meter/ade7854.c:430:		goto error_ret;
drivers/staging/iio/meter/ade7754.c:360:		goto error_ret;
drivers/staging/gdm72xx/usb_boot.c:259:		goto out;
drivers/staging/gdm72xx/usb_boot.c:324:		goto out;
drivers/target/target_core_spc.c:745:		goto out;
drivers/target/target_core_spc.c:884:		goto out;
drivers/uwb/reset.c:389:		goto out;
drivers/bluetooth/btrtl.c:314:		goto out;
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:568:		goto fifo_rate_fail;
drivers/iio/gyro/itg3200_buffer.c:96:		goto error_ret;
drivers/base/regmap/regmap.c:2587:		goto out;
drivers/base/core.c:1838:		goto out;
drivers/char/ipmi/ipmi_poweroff.c:434:		goto out;
drivers/char/xilinx_hwicap/xilinx_hwicap.c:581:		goto error;
drivers/nfc/st21nfcb/st21nfcb_se.c:558:		goto free_dest_params;
drivers/scsi/lpfc/lpfc_hbadisc.c:2416:	goto read_next_fcf;
drivers/scsi/qla2xxx/qla_bsg.c:399:	goto done_free_fcport;
drivers/scsi/qla4xxx/ql4_nx.c:1913:		goto exit_ipmdio_wr_reg;
drivers/scsi/bfa/bfad_bsg.c:1948:		goto out;
drivers/scsi/device_handler/scsi_dh_emc.c:556:		goto done;
drivers/scsi/device_handler/scsi_dh_alua.c:695:		goto out;
drivers/scsi/megaraid/megaraid_mm.c:295:		goto new_packet;
drivers/scsi/ufs/ufshcd.c:4377:		goto out;
drivers/net/ethernet/qlogic/qlge/qlge_mpi.c:85:		goto exit;
drivers/net/ethernet/intel/i40e/i40e_hmc.c:302:		goto exit;
drivers/net/ethernet/intel/i40e/i40e_hmc.c:356:		goto exit;
drivers/net/ethernet/mellanox/mlx4/mcg.c:1181:		goto out;
drivers/net/ethernet/rocker/rocker.c:584:		goto unmap;
drivers/net/wan/dscc4.c:983:	goto done;
drivers/net/wireless/cw1200/sta.c:89:		goto out;
drivers/net/wireless/b43legacy/debugfs.c:312:		goto out_freepage;
drivers/net/wireless/b43legacy/main.c:1676:	goto error;
drivers/net/wireless/ath/carl9170/debug.c:156:		goto out_unlock;
drivers/net/wireless/ath/carl9170/debug.c:747:		goto out;
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c:216:		goto err_out;
drivers/net/wireless/p54/p54usb.c:619:		goto err_upload_failed;
drivers/net/wireless/p54/p54pci.c:519:		goto out;
drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c:3847:	goto cleanup;
drivers/net/wireless/libertas/if_spi.c:828:		goto out;
drivers/net/wireless/libertas/if_spi.c:1091:		goto out;
drivers/net/wireless/ti/wl1251/boot.c:551:		goto out;
drivers/net/wireless/ti/wl1251/acx.c:57:		goto out;
drivers/net/wireless/ti/wl1251/main.c:1334:		goto out_sleep;
drivers/net/wireless/ti/wlcore/cmd.c:2057:		goto out;
drivers/net/wireless/ti/wlcore/testmode.c:203:		goto out_free;
drivers/net/wireless/ti/wlcore/testmode.c:352:		goto out;
drivers/net/wireless/ti/wlcore/boot.c:78:		goto out;
drivers/net/wireless/ti/wlcore/boot.c:165:		goto out_free;
drivers/net/wireless/ti/wlcore/debugfs.c:1028:		goto out_sleep;
drivers/net/wireless/ti/wlcore/debugfs.c:1094:		goto read_err;
drivers/net/wireless/ti/wlcore/debugfs.c:1098:		goto part_err;
drivers/net/wireless/ti/wlcore/debugfs.c:1177:		goto write_err;
drivers/net/wireless/ti/wlcore/debugfs.c:1181:		goto part_err;
drivers/net/wireless/ti/wlcore/main.c:192:		goto out_sleep;
drivers/net/wireless/ti/wlcore/main.c:1125:		goto out;
drivers/net/wireless/ti/wlcore/main.c:1710:		goto out;
drivers/net/wireless/ti/wlcore/main.c:1806:		goto out_sleep;
drivers/net/wireless/ti/wlcore/main.c:1906:		goto out_sleep;
drivers/net/wireless/ti/wlcore/main.c:4080:		goto out;
drivers/net/wireless/ti/wlcore/main.c:4891:		goto out_sleep;
drivers/net/wireless/ti/wl12xx/main.c:752:		goto out;
drivers/net/wireless/ti/wl12xx/main.c:1150:		goto out;
drivers/net/wireless/ti/wl18xx/main.c:810:		goto out;
drivers/net/wireless/b43/debugfs.c:605:		goto out_freepage;
drivers/net/wireless/b43/main.c:2545:	goto error;
drivers/net/wimax/i2400m/fw.c:295:		goto error_add;
drivers/s390/net/qeth_core_main.c:5090:		goto retriable;
drivers/hwmon/applesmc.c:732:		goto out;
drivers/infiniband/hw/qib/qib_iba6120.c:3340:		goto bail;
drivers/infiniband/hw/amso1100/c2_cm.c:282:		goto bail1;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:1888:		goto mbx_err;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:1968:		goto mbx_err;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:2631:		goto mbx_err;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:2648:		goto mbx_err;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:3059:		goto mbx_err;
drivers/infiniband/hw/mthca/mthca_provider.c:222:		goto out;
drivers/media/tuners/e4000.c:106:		goto err;
drivers/media/tuners/e4000.c:250:		goto err;
drivers/media/tuners/fc0013.c:221:		goto error_out;
drivers/media/usb/airspy/airspy.c:940:		goto err;
drivers/media/usb/msi2500/msi2500.c:819:		goto err;
drivers/ssb/pci.c:1185:		goto out;
fs/ocfs2/cluster/nodemanager.c:692:		goto out;
fs/ocfs2/cluster/tcp.c:876:		goto out;
fs/ocfs2/dlm/dlmdomain.c:1849:		goto bail;
fs/gfs2/inode.c:1536:		goto out_end_trans;
fs/xfs/xfs_ioctl.c:311:		goto out_kfree;
fs/ubifs/recovery.c:221:		goto out;
fs/pipe.c:937:	goto err;
fs/exofs/dir.c:142:	goto bad_entry;
fs/hfsplus/attributes.c:332:		goto out;
fs/btrfs/volumes.c:1538:		goto out;
fs/btrfs/send.c:2662:		goto out;
fs/aio.c:1418:		goto rw_common;
fs/nfs/nfs4idmap.c:500:		goto out;
ipc/kdbus/names.c:518:		goto exit_dec;
net/mac80211/tx.c:2637:		goto out;
net/ceph/messenger.c:1684:		goto out;
net/ipv6/raw.c:1334:		goto out;
net/ipv6/esp6.c:481:		goto error;
net/nfc/nci/hci.c:671:		goto exit;
net/ipv4/esp4.c:539:		goto error;
net/sched/sch_api.c:1794:		goto done;
net/llc/llc_proc.c:74:			goto out;
security/selinux/ss/services.c:359:				goto mls_ops;
sound/pci/hda/patch_ca0132.c:943:		goto exit;
sound/pci/hda/patch_ca0132.c:991:		goto exit;
sound/core/seq/seq_midi_emul.c:372:		goto notyet;
sound/spi/at73c213.c:1063:		goto out;
sound/usb/mixer_quirks.c:683:		goto err;
sound/usb/mixer_quirks.c:1592:		goto end;
tools/perf/util/python.c:330:		goto out;



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-27 20:25 [PATCH] staging: gdm72xx: remove unneeded test Laurent Navet
  2015-05-27 20:30 ` Joe Perches
@ 2015-05-27 20:46 ` Fabio Estevam
  2015-05-28  7:20   ` Dan Carpenter
  1 sibling, 1 reply; 12+ messages in thread
From: Fabio Estevam @ 2015-05-27 20:46 UTC (permalink / raw)
  To: Laurent Navet; +Cc: Greg Kroah-Hartman, devel, linux-kernel

On Wed, May 27, 2015 at 5:25 PM, Laurent Navet <laurent.navet@gmail.com> wrote:
> The same code is executed regardless ret value, so this test can be
> removed.
>
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  drivers/staging/gdm72xx/usb_boot.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c
> index 3ccc447..7f80553 100644
> --- a/drivers/staging/gdm72xx/usb_boot.c
> +++ b/drivers/staging/gdm72xx/usb_boot.c
> @@ -255,8 +255,6 @@ static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
>
>         /*Wait for ACK*/
>         ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
> -       if (ret < 0)
> -               goto out;
>  out:
>         return ret;
>  }

What about removing the 'out' label like this?

--- a/drivers/staging/gdm72xx/usb_boot.c
+++ b/drivers/staging/gdm72xx/usb_boot.c
@@ -250,15 +250,11 @@ static int em_wait_ack(struct usb_device *usbdev, int send
                /*Send ZLP*/
                ret = gdm_wibro_send(usbdev, NULL, 0);
                if (ret < 0)
-                       goto out;
+                       return ret;
        }

        /*Wait for ACK*/
-       ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
-       if (ret < 0)
-               goto out;
-out:
-       return ret;
+       return gdm_wibro_recv(usbdev, &ack, sizeof(ack));
 }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-27 20:30 ` Joe Perches
@ 2015-05-28  5:43   ` Julia Lawall
  2015-05-28  5:48     ` Joe Perches
  2015-05-28  7:14   ` Dan Carpenter
  1 sibling, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-05-28  5:43 UTC (permalink / raw)
  To: Joe Perches
  Cc: Laurent Navet, gregkh, benchan, devel, linux-kernel, Julia Lawall

On Wed, 27 May 2015, Joe Perches wrote:

> On Wed, 2015-05-27 at 22:25 +0200, Laurent Navet wrote:
> > The same code is executed regardless ret value, so this test can be
> > removed.
> []
> > diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c
> []
> > @@ -255,8 +255,6 @@ static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
> >  
> >  	/*Wait for ACK*/
> >  	ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
> > -	if (ret < 0)
> > -		goto out;
> >  out:
> >  	return ret;
> >  }
> 
> Perhaps all of the uses like:
> 
> 	goto <foo>;
> <foo>:
> 
> could be modified.  There are ~150 in the kernel.

I wrote a semantic patch recently for that as well...  Maybe I can take 
care of it.

julia

> 
> $ grep-2.5.4 -rP --include=*.[ch] -n "\bgoto\s+(\w+)\s*;\s*\1\s*:" * | \
>   grep -P "^[\w/\.:]+\d+:"
> arch/x86/xen/enlighten.c:1018:	case MSR_GS_BASE:		which = SEGBASE_GS_KERNEL; goto set;
> arch/m68k/amiga/config.c:258:		goto Generic;
> arch/s390/net/bpf_jit_comp.c:1078:		goto call_fn;
> arch/sparc/kernel/pci_msi.c:67:	goto err_out;
> drivers/gpu/drm/radeon/atombios_dp.c:882:		goto done;
> drivers/gpu/drm/nouveau/nouveau_bo.c:1225:		goto out;
> drivers/gpu/drm/nouveau/nv50_display.c:1476:		goto out;
> drivers/gpu/drm/i915/intel_display.c:12678:		goto out;
> drivers/isdn/mISDN/dsp_cmx.c:1572:	goto send_packet;
> drivers/input/mouse/cyapa_gen5.c:1772:		goto resume_scanning;
> drivers/input/mouse/cyapa_gen5.c:2340:		goto resume_scanning;
> drivers/mmc/host/s3cmci.c:798:	goto irq_out;
> drivers/mmc/host/ushc.c:313:		goto out;
> drivers/mmc/card/mmc_test.c:2918:		goto err;
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1271:	goto out;
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1305:	goto out;
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1372:	goto out;
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1455:	goto out;
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1518:	goto out;
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1815:		goto out;
> drivers/staging/lustre/lustre/llite/file.c:691:	goto out_och_free;
> drivers/staging/lustre/lustre/llite/file.c:1161:	goto out;
> drivers/staging/lustre/lustre/llite/file.c:1301:	goto out;
> drivers/staging/lustre/lustre/llite/xattr_cache.c:452:	goto out_maybe_drop;
> drivers/staging/lustre/lustre/llite/xattr_cache.c:532:	goto out;
> drivers/staging/lustre/lustre/llite/dir.c:683:		goto err_exit;
> drivers/staging/lustre/lustre/llite/dir.c:1941:	goto out;
> drivers/staging/lustre/lustre/llite/namei.c:556:	goto out;
> drivers/staging/lustre/lustre/llite/llite_lib.c:2115:		goto out_statfs;
> drivers/staging/lustre/lustre/llite/rw.c:1204:	goto out;
> drivers/staging/lustre/lustre/obdecho/echo_client.c:2130:	goto out;
> drivers/staging/lustre/lustre/fld/fld_request.c:377:		goto out;
> drivers/staging/lustre/lustre/obdclass/obd_mount.c:1225:	goto out;
> drivers/staging/lustre/lustre/obdclass/dt_object.c:734:	goto out;
> drivers/staging/lustre/lustre/obdclass/dt_object.c:934:	goto out;
> drivers/staging/lustre/lustre/ldlm/ldlm_lock.c:1857:	goto out;
> drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c:310:	goto out;
> drivers/staging/iio/meter/ade7758_core.c:436:		goto error_ret;
> drivers/staging/iio/meter/ade7854.c:430:		goto error_ret;
> drivers/staging/iio/meter/ade7754.c:360:		goto error_ret;
> drivers/staging/gdm72xx/usb_boot.c:259:		goto out;
> drivers/staging/gdm72xx/usb_boot.c:324:		goto out;
> drivers/target/target_core_spc.c:745:		goto out;
> drivers/target/target_core_spc.c:884:		goto out;
> drivers/uwb/reset.c:389:		goto out;
> drivers/bluetooth/btrtl.c:314:		goto out;
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:568:		goto fifo_rate_fail;
> drivers/iio/gyro/itg3200_buffer.c:96:		goto error_ret;
> drivers/base/regmap/regmap.c:2587:		goto out;
> drivers/base/core.c:1838:		goto out;
> drivers/char/ipmi/ipmi_poweroff.c:434:		goto out;
> drivers/char/xilinx_hwicap/xilinx_hwicap.c:581:		goto error;
> drivers/nfc/st21nfcb/st21nfcb_se.c:558:		goto free_dest_params;
> drivers/scsi/lpfc/lpfc_hbadisc.c:2416:	goto read_next_fcf;
> drivers/scsi/qla2xxx/qla_bsg.c:399:	goto done_free_fcport;
> drivers/scsi/qla4xxx/ql4_nx.c:1913:		goto exit_ipmdio_wr_reg;
> drivers/scsi/bfa/bfad_bsg.c:1948:		goto out;
> drivers/scsi/device_handler/scsi_dh_emc.c:556:		goto done;
> drivers/scsi/device_handler/scsi_dh_alua.c:695:		goto out;
> drivers/scsi/megaraid/megaraid_mm.c:295:		goto new_packet;
> drivers/scsi/ufs/ufshcd.c:4377:		goto out;
> drivers/net/ethernet/qlogic/qlge/qlge_mpi.c:85:		goto exit;
> drivers/net/ethernet/intel/i40e/i40e_hmc.c:302:		goto exit;
> drivers/net/ethernet/intel/i40e/i40e_hmc.c:356:		goto exit;
> drivers/net/ethernet/mellanox/mlx4/mcg.c:1181:		goto out;
> drivers/net/ethernet/rocker/rocker.c:584:		goto unmap;
> drivers/net/wan/dscc4.c:983:	goto done;
> drivers/net/wireless/cw1200/sta.c:89:		goto out;
> drivers/net/wireless/b43legacy/debugfs.c:312:		goto out_freepage;
> drivers/net/wireless/b43legacy/main.c:1676:	goto error;
> drivers/net/wireless/ath/carl9170/debug.c:156:		goto out_unlock;
> drivers/net/wireless/ath/carl9170/debug.c:747:		goto out;
> drivers/net/wireless/rtlwifi/rtl8192cu/trx.c:216:		goto err_out;
> drivers/net/wireless/p54/p54usb.c:619:		goto err_upload_failed;
> drivers/net/wireless/p54/p54pci.c:519:		goto out;
> drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c:3847:	goto cleanup;
> drivers/net/wireless/libertas/if_spi.c:828:		goto out;
> drivers/net/wireless/libertas/if_spi.c:1091:		goto out;
> drivers/net/wireless/ti/wl1251/boot.c:551:		goto out;
> drivers/net/wireless/ti/wl1251/acx.c:57:		goto out;
> drivers/net/wireless/ti/wl1251/main.c:1334:		goto out_sleep;
> drivers/net/wireless/ti/wlcore/cmd.c:2057:		goto out;
> drivers/net/wireless/ti/wlcore/testmode.c:203:		goto out_free;
> drivers/net/wireless/ti/wlcore/testmode.c:352:		goto out;
> drivers/net/wireless/ti/wlcore/boot.c:78:		goto out;
> drivers/net/wireless/ti/wlcore/boot.c:165:		goto out_free;
> drivers/net/wireless/ti/wlcore/debugfs.c:1028:		goto out_sleep;
> drivers/net/wireless/ti/wlcore/debugfs.c:1094:		goto read_err;
> drivers/net/wireless/ti/wlcore/debugfs.c:1098:		goto part_err;
> drivers/net/wireless/ti/wlcore/debugfs.c:1177:		goto write_err;
> drivers/net/wireless/ti/wlcore/debugfs.c:1181:		goto part_err;
> drivers/net/wireless/ti/wlcore/main.c:192:		goto out_sleep;
> drivers/net/wireless/ti/wlcore/main.c:1125:		goto out;
> drivers/net/wireless/ti/wlcore/main.c:1710:		goto out;
> drivers/net/wireless/ti/wlcore/main.c:1806:		goto out_sleep;
> drivers/net/wireless/ti/wlcore/main.c:1906:		goto out_sleep;
> drivers/net/wireless/ti/wlcore/main.c:4080:		goto out;
> drivers/net/wireless/ti/wlcore/main.c:4891:		goto out_sleep;
> drivers/net/wireless/ti/wl12xx/main.c:752:		goto out;
> drivers/net/wireless/ti/wl12xx/main.c:1150:		goto out;
> drivers/net/wireless/ti/wl18xx/main.c:810:		goto out;
> drivers/net/wireless/b43/debugfs.c:605:		goto out_freepage;
> drivers/net/wireless/b43/main.c:2545:	goto error;
> drivers/net/wimax/i2400m/fw.c:295:		goto error_add;
> drivers/s390/net/qeth_core_main.c:5090:		goto retriable;
> drivers/hwmon/applesmc.c:732:		goto out;
> drivers/infiniband/hw/qib/qib_iba6120.c:3340:		goto bail;
> drivers/infiniband/hw/amso1100/c2_cm.c:282:		goto bail1;
> drivers/infiniband/hw/ocrdma/ocrdma_hw.c:1888:		goto mbx_err;
> drivers/infiniband/hw/ocrdma/ocrdma_hw.c:1968:		goto mbx_err;
> drivers/infiniband/hw/ocrdma/ocrdma_hw.c:2631:		goto mbx_err;
> drivers/infiniband/hw/ocrdma/ocrdma_hw.c:2648:		goto mbx_err;
> drivers/infiniband/hw/ocrdma/ocrdma_hw.c:3059:		goto mbx_err;
> drivers/infiniband/hw/mthca/mthca_provider.c:222:		goto out;
> drivers/media/tuners/e4000.c:106:		goto err;
> drivers/media/tuners/e4000.c:250:		goto err;
> drivers/media/tuners/fc0013.c:221:		goto error_out;
> drivers/media/usb/airspy/airspy.c:940:		goto err;
> drivers/media/usb/msi2500/msi2500.c:819:		goto err;
> drivers/ssb/pci.c:1185:		goto out;
> fs/ocfs2/cluster/nodemanager.c:692:		goto out;
> fs/ocfs2/cluster/tcp.c:876:		goto out;
> fs/ocfs2/dlm/dlmdomain.c:1849:		goto bail;
> fs/gfs2/inode.c:1536:		goto out_end_trans;
> fs/xfs/xfs_ioctl.c:311:		goto out_kfree;
> fs/ubifs/recovery.c:221:		goto out;
> fs/pipe.c:937:	goto err;
> fs/exofs/dir.c:142:	goto bad_entry;
> fs/hfsplus/attributes.c:332:		goto out;
> fs/btrfs/volumes.c:1538:		goto out;
> fs/btrfs/send.c:2662:		goto out;
> fs/aio.c:1418:		goto rw_common;
> fs/nfs/nfs4idmap.c:500:		goto out;
> ipc/kdbus/names.c:518:		goto exit_dec;
> net/mac80211/tx.c:2637:		goto out;
> net/ceph/messenger.c:1684:		goto out;
> net/ipv6/raw.c:1334:		goto out;
> net/ipv6/esp6.c:481:		goto error;
> net/nfc/nci/hci.c:671:		goto exit;
> net/ipv4/esp4.c:539:		goto error;
> net/sched/sch_api.c:1794:		goto done;
> net/llc/llc_proc.c:74:			goto out;
> security/selinux/ss/services.c:359:				goto mls_ops;
> sound/pci/hda/patch_ca0132.c:943:		goto exit;
> sound/pci/hda/patch_ca0132.c:991:		goto exit;
> sound/core/seq/seq_midi_emul.c:372:		goto notyet;
> sound/spi/at73c213.c:1063:		goto out;
> sound/usb/mixer_quirks.c:683:		goto err;
> sound/usb/mixer_quirks.c:1592:		goto end;
> tools/perf/util/python.c:330:		goto out;
> 
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-28  5:43   ` Julia Lawall
@ 2015-05-28  5:48     ` Joe Perches
  2015-05-28 16:21       ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Joe Perches @ 2015-05-28  5:48 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Laurent Navet, gregkh, benchan, devel, linux-kernel

On Thu, 2015-05-28 at 07:43 +0200, Julia Lawall wrote:
> On Wed, 27 May 2015, Joe Perches wrote:
> > Perhaps all of the uses like:
> > 
> > 	goto <foo>;
> > <foo>:
> > 
> > could be modified.  There are ~150 in the kernel.
> 
> I wrote a semantic patch recently for that as well...  Maybe I can take 
> care of it.

Great.  Thanks Julia.

There may be some reorganization of code that is
possible for many of these than coccinelle may
not perform well though.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-27 20:30 ` Joe Perches
  2015-05-28  5:43   ` Julia Lawall
@ 2015-05-28  7:14   ` Dan Carpenter
  2015-05-28  8:06     ` Joe Perches
  1 sibling, 1 reply; 12+ messages in thread
From: Dan Carpenter @ 2015-05-28  7:14 UTC (permalink / raw)
  To: Joe Perches; +Cc: Laurent Navet, devel, gregkh, Julia Lawall, linux-kernel

On Wed, May 27, 2015 at 01:30:08PM -0700, Joe Perches wrote:
> On Wed, 2015-05-27 at 22:25 +0200, Laurent Navet wrote:
> > The same code is executed regardless ret value, so this test can be
> > removed.
> []
> > diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c
> []
> > @@ -255,8 +255,6 @@ static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
> >  
> >  	/*Wait for ACK*/
> >  	ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
> > -	if (ret < 0)
> > -		goto out;
> >  out:
> >  	return ret;
> >  }
> 
> Perhaps all of the uses like:
> 
> 	goto <foo>;
> <foo>:
> 
> could be modified.  There are ~150 in the kernel.

Joe, these are a kind of style.  You're just directing a newbie into a
hornets nest.  Laurant, don't do listen to Joe unless you like getting
flamed.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-27 20:46 ` Fabio Estevam
@ 2015-05-28  7:20   ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2015-05-28  7:20 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Laurent Navet, devel, Greg Kroah-Hartman, linux-kernel

Obviously, I endorse this idea.  :)  Every out label in this file is
a do-nothing label or a do-everything label, but with bugs.  usb_boot()
should look like:

free_tx_buf:
	kfree(tx_buf);
release_firm:
	release_firmware(firm);

	ret;

If we fail to allocate "tx_buf" then we should release the firmware.
em_download_image() has the same bug as well.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-28  7:14   ` Dan Carpenter
@ 2015-05-28  8:06     ` Joe Perches
  2015-05-28  8:33       ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Joe Perches @ 2015-05-28  8:06 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Laurent Navet, devel, gregkh, Julia Lawall, linux-kernel

On Thu, 2015-05-28 at 10:14 +0300, Dan Carpenter wrote:
> On Wed, May 27, 2015 at 01:30:08PM -0700, Joe Perches wrote:
> > Perhaps all of the uses like:
> > 	goto <foo>;
> > <foo>:
> > 
> > could be modified.  There are ~150 in the kernel.
> 
> Joe, these are a kind of style.  You're just directing a newbie into a
> hornets nest.  Laurant, don't do listen to Joe unless you like getting
> flamed.

Hey Dan.

I didn't direct anyone to do anything, but that's
why I added Julia to cc's.

Anyway, I think these are very equivalent style to
the repeated:

	ret = foo();
	if (ret < 0)
		return ret;
...
	ret = bar();
	if (ret < 0)
		return ret;

	return ret;

and people seem to prefer changing those.

cheers, Joe


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-28  8:06     ` Joe Perches
@ 2015-05-28  8:33       ` Julia Lawall
  2015-05-28  8:41         ` Joe Perches
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-05-28  8:33 UTC (permalink / raw)
  To: Joe Perches; +Cc: Dan Carpenter, Laurent Navet, devel, gregkh, linux-kernel

On Thu, 28 May 2015, Joe Perches wrote:

> On Thu, 2015-05-28 at 10:14 +0300, Dan Carpenter wrote:
> > On Wed, May 27, 2015 at 01:30:08PM -0700, Joe Perches wrote:
> > > Perhaps all of the uses like:
> > > 	goto <foo>;
> > > <foo>:
> > >
> > > could be modified.  There are ~150 in the kernel.
> >
> > Joe, these are a kind of style.  You're just directing a newbie into a
> > hornets nest.  Laurant, don't do listen to Joe unless you like getting
> > flamed.
>
> Hey Dan.
>
> I didn't direct anyone to do anything, but that's
> why I added Julia to cc's.
>
> Anyway, I think these are very equivalent style to
> the repeated:
>
> 	ret = foo();
> 	if (ret < 0)
> 		return ret;
> ...
> 	ret = bar();
> 	if (ret < 0)
> 		return ret;
>
> 	return ret;
>
> and people seem to prefer changing those.

Maybe if there is a whole sequence of them, it it is reasonable to keep
them.  But if there is just one, it seems complicated for nothing.  In the
big scheme of things, though, there are probably better things one could
do than changing all of them.

julia

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-28  8:33       ` Julia Lawall
@ 2015-05-28  8:41         ` Joe Perches
  0 siblings, 0 replies; 12+ messages in thread
From: Joe Perches @ 2015-05-28  8:41 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Dan Carpenter, Laurent Navet, devel, gregkh, linux-kernel

On Thu, 2015-05-28 at 10:33 +0200, Julia Lawall wrote:
> On Thu, 28 May 2015, Joe Perches wrote:
> I think these are very equivalent style to
> > the repeated:
> >
> > 	ret = foo();
> > 	if (ret < 0)
> > 		return ret;
> > ...
> > 	ret = bar();
> > 	if (ret < 0)
> > 		return ret;
> >
> > 	return ret;
> >
> > and people seem to prefer changing those.
> 
> Maybe if there is a whole sequence of them, it it is reasonable to keep
> them.  But if there is just one, it seems complicated for nothing.

Agree with that.
https://lkml.org/lkml/2015/1/2/321

> In the
> big scheme of things, though, there are probably better things one could
> do than changing all of them.

Agree with that too.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-28  5:48     ` Joe Perches
@ 2015-05-28 16:21       ` Julia Lawall
  2015-05-28 16:33         ` Joe Perches
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-05-28 16:21 UTC (permalink / raw)
  To: Joe Perches
  Cc: Julia Lawall, Laurent Navet, gregkh, benchan, devel, linux-kernel



On Wed, 27 May 2015, Joe Perches wrote:

> On Thu, 2015-05-28 at 07:43 +0200, Julia Lawall wrote:
> > On Wed, 27 May 2015, Joe Perches wrote:
> > > Perhaps all of the uses like:
> > >
> > > 	goto <foo>;
> > > <foo>:
> > >
> > > could be modified.  There are ~150 in the kernel.
> >
> > I wrote a semantic patch recently for that as well...  Maybe I can take
> > care of it.
>
> Great.  Thanks Julia.
>
> There may be some reorganization of code that is
> possible for many of these than coccinelle may
> not perform well though.

As what looks like an extreme example, wouldn't this function be better as
just return inet6_register_protosw(&rawv6_protosw); ?

int __init rawv6_init(void)
{
        int ret;

        ret = inet6_register_protosw(&rawv6_protosw);
        if (ret)
                goto out;
out:
        return ret;
}

julia

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] staging: gdm72xx: remove unneeded test
  2015-05-28 16:21       ` Julia Lawall
@ 2015-05-28 16:33         ` Joe Perches
  0 siblings, 0 replies; 12+ messages in thread
From: Joe Perches @ 2015-05-28 16:33 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Laurent Navet, gregkh, benchan, devel, linux-kernel

On Thu, 2015-05-28 at 18:21 +0200, Julia Lawall wrote:
> 
> On Wed, 27 May 2015, Joe Perches wrote:
> 
> > On Thu, 2015-05-28 at 07:43 +0200, Julia Lawall wrote:
> > > On Wed, 27 May 2015, Joe Perches wrote:
> > > > Perhaps all of the uses like:
> > > >
> > > > 	goto <foo>;
> > > > <foo>:
> > > >
> > > > could be modified.  There are ~150 in the kernel.
> > >
> > > I wrote a semantic patch recently for that as well...  Maybe I can take
> > > care of it.
> >
> > Great.  Thanks Julia.
> >
> > There may be some reorganization of code that is
> > possible for many of these than coccinelle may
> > not perform well though.
> 
> As what looks like an extreme example, wouldn't this function be better as
> just return inet6_register_protosw(&rawv6_protosw); ?
> 
> int __init rawv6_init(void)
> {
>         int ret;
> 
>         ret = inet6_register_protosw(&rawv6_protosw);
>         if (ret)
>                 goto out;
> out:
>         return ret;
> }

That style is exactly what I was thinking about.

Yes, I think this would indeed be much better as a
single line and might have been better still removed
altogether but for the rawv6_protosw hiding.

There are a couple others just like it in net/



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-05-28 16:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 20:25 [PATCH] staging: gdm72xx: remove unneeded test Laurent Navet
2015-05-27 20:30 ` Joe Perches
2015-05-28  5:43   ` Julia Lawall
2015-05-28  5:48     ` Joe Perches
2015-05-28 16:21       ` Julia Lawall
2015-05-28 16:33         ` Joe Perches
2015-05-28  7:14   ` Dan Carpenter
2015-05-28  8:06     ` Joe Perches
2015-05-28  8:33       ` Julia Lawall
2015-05-28  8:41         ` Joe Perches
2015-05-27 20:46 ` Fabio Estevam
2015-05-28  7:20   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).