Skip to contentSkip to conversation

staging: gdm72xx: remove unneeded test

PATCH In review Laurent Navet 5 participants 12 messages May 27, 2015 – May 28, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: gdm72xx: remove unneeded test

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

---
 drivers/staging/gdm72xx/usb_boot.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/gdm72xx/usb_boot.c +0 -2
index 3ccc447..7f80553 100644
@@ -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;
 }
Signature · 1 line
2.1.4
#1 lore raw
Quoted 2 lines · Laurent Navet

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

[]

drivers/staging/gdm72xx/usb_boot.c

Quoted 1 line
drivers/staging/gdm72xx/usb_boot.c +0 -0

[]

drivers/staging/gdm72xx/usb_boot.c static int em_wait_ack(struct usb_device *usbdev, int send_zlp) · line 260

Quoted 9 lines
drivers/staging/gdm72xx/usb_boot.c +0 -2
@@ -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;
#2 lore raw
Quoted 18 lines · Joe Perches
Quoted 2 lines · Laurent Navet

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

[]

drivers/staging/gdm72xx/usb_boot.c

Quoted 1 line
drivers/staging/gdm72xx/usb_boot.c +0 -0

[]

drivers/staging/gdm72xx/usb_boot.c static int em_wait_ack(struct usb_device *usbdev, int send_zlp) · line 260

Quoted 9 lines
drivers/staging/gdm72xx/usb_boot.c +0 -2
@@ -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:

Quoted 4 lines
	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

Quoted 156 lines
$ 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;
#3 lore raw
Quoted 10 lines · Julia Lawall
Quoted 6 lines · Joe Perches

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.

#4 lore raw
Quoted 9 lines · Joe Perches
Quoted 8 lines · Julia Lawall
Quoted 6 lines · Joe Perches

Perhaps all of the uses like:

	goto <foo>;

<foo>:

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

Quoted 8 lines
Quoted 2 lines

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

#5 lore raw
Quoted 25 lines · Julia Lawall
Quoted 9 lines · Joe Perches
Quoted 8 lines · Julia Lawall
Quoted 6 lines · Joe Perches

Perhaps all of the uses like:

	goto <foo>;

<foo>:

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

Quoted 8 lines
Quoted 2 lines

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)

Quoted 9 lines
{
        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/

#6 lore raw
In reply to Joe Perches
Quoted 18 lines · Joe Perches
Quoted 2 lines · Laurent Navet

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

[]

drivers/staging/gdm72xx/usb_boot.c

Quoted 1 line
drivers/staging/gdm72xx/usb_boot.c +0 -0

[]

drivers/staging/gdm72xx/usb_boot.c static int em_wait_ack(struct usb_device *usbdev, int send_zlp) · line 260

Quoted 9 lines
drivers/staging/gdm72xx/usb_boot.c +0 -2
@@ -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:

Quoted 4 lines
	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

#7 lore raw
Quoted 10 lines · Dan Carpenter
Quoted 5 lines · Joe Perches

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

#8 lore raw
Quoted 30 lines · Joe Perches
Quoted 10 lines · Dan Carpenter
Quoted 5 lines · Joe Perches

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;
Quoted 1 line

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

#9 lore raw
Quoted 12 lines · Julia Lawall

On Thu, 28 May 2015, Joe Perches wrote:
I think these are very equivalent style to

Quoted 10 lines

the repeated:

	ret = foo();
	if (ret < 0)
		return ret;
...
	ret = bar();
	if (ret < 0)
		return ret;
Quoted 6 lines
Quoted 3 lines
	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

Quoted 3 lines

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

Agree with that too.

#10 lore raw
In reply to Laurent Navet
Quoted 13 lines · Laurent Navet

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

---
 drivers/staging/gdm72xx/usb_boot.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/gdm72xx/usb_boot.c +0 -0
index 3ccc447..7f80553 100644

drivers/staging/gdm72xx/usb_boot.c static int em_wait_ack(struct usb_device *usbdev, int send_zlp) · line 260

Quoted 8 lines
drivers/staging/gdm72xx/usb_boot.c +0 -2
@@ -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?

drivers/staging/gdm72xx/usb_boot.c +2 -6
@@ -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));
 }
#11 lore raw

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