All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 00/59] trivial unneeded labels cleanup
@ 2020-01-06 18:23 Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates() Daniel Henrique Barboza
                   ` (61 more replies)
  0 siblings, 62 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza

Hello,

This is the type of cleanup I've contributed to Libvirt
during the last year. Figured QEMU also deserves the same
care.

The idea here is remove unneeded labels. By 'unneeded' I
mean labels that does nothing but a 'return' call. One
common case is something like this:

if ()
    goto cleanup;
[...]
 cleanup:
    return 0;

This code can be simplified to:

if ()
    return 0;


Which is cleaner and requires less brain cycles to wonder
whether the 'cleanup' label does anything special, such
as a heap memory cleanup.

Another common case uses a variable to set a return value,
generally an error, then return:

if () {
    ret = -ENOENT;
    goto out;
}
[..]
 out:
    return ret;

Likewise, it is clearer to just 'return -ENOENT' instead of
jumping to a label. There are other cases being handled in
these patches, but these are the most common.

There are still a handful of unneeded labels hanging around after
this series. There are cases in which the label name is
part of the code semantics and I judged not worth removing.
search_chunk() in block/dmg.c has an example of an unneeded
'err' label that I decided to not remove.

No functional change was made. If any of these patches changes
existing behavior it is unintended and an error from my
part.



Daniel Henrique Barboza (59):
  spapr.c: remove 'out' label in spapr_dt_cas_updates()
  ppc440_bamboo.c: remove label from bamboo_load_device_tree()
  kvm-all.c: remove unneeded labels
  paaudio.c: remove unneeded labels
  ram.c: remove unneeded labels
  mips-semi.c: remove 'uhi_done' label in helper_do_semihosting()
  unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2()
  chardev/char-mux.c: remove 'send_char' label
  chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init()
  chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
  exec.c: remove 'err' label in ram_block_discard_range()
  virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  block/vdi.c: remove 'fail' label in vdi_open()
  block/file-posix.c: remove unneeded labels
  block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open()
  block/gluster.c: remove unneeded 'exit' label
  block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block()
  qcow2-refcount.c: remove unneeded 'fail' label in
    qcow2_refcount_init()
  block/ssh.c: remove unneeded labels
  block/vpc.c: remove unneeded 'fail' label in create_dynamic_disk()
  block/backup.c remove unneeded 'out' label in backup_run()
  block/vmdk.c: remove unneeded labels
  block/vxhs.c: remove unneeded 'out' label in vxhs_iio_callback()
  block/vhdx-log.c: remove unneeded labels
  block/vhdx.c: remove unneeded 'exit' labels
  block/replication.c: remove unneeded label in replication_co_writev
  crypto/block-luks.c: remove unneeded label in
    qcrypto_block_luks_find_key
  qga/commands-win32.c: remove 'out' label in get_pci_info
  cryptodev-vhost.c: remove unneeded 'err' label in
    cryptodev_vhost_start
  util/module.c: remove unneeded label in module_load_file()
  util/aio-posix.c: remove unneeded 'out' label in aio_epoll
  qemu-img.c: remove 'out4' label in img_compare
  ipmi/ipmi_bmc_sim.c: remove unneeded labels
  ipmi/ipmi_bt.c: remove unneeded label in ipmi_bt_handle_event
  ipmi_bmc_extern.c: remove unneeded label in
    ipmi_bmc_extern_handle_command
  ipmi/ipmi_kcs.c: remove unneeded label in ipmi_kcs_handle_event
  s390x/event-facility.c: remove unneeded labels
  s390x/sclp.c: remove unneeded label in sclp_service_call()
  usb/dev-mtp.c: remove unneeded label in write_retry()
  hsb/hcd-ehci.c: remove unneeded labels
  intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
  i386/intel_iommu.c: remove unneeded labels
  i386/amd_iommu.c: remove unneeded label in amdvi_int_remap_msi()
  9p-local.c: remove unneeded label in local_unlinkat_common()
  9pfs/9p.c: remove unneeded labels
  alpha/typhoon.c: remove unneeded label in typhoon_translate_iommu()
  pvrdma_main.c: remove unneeded labels
  pvrdma_dev_ring.c: remove unneeded label in pvrdma_ring_init()
  rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd()
  rdma/rdma_backend.c: remove unneeded label in rdma_backend_init()
  virtio/vhost.c: remove unneeded labels
  net/vhost_net.c: remove unneeded labels
  net/net_tx_pkt.c: remove unneeded label in net_tx_pkt_get_gso_type()
  ivshmem-server/main.c: remove unneeded label in main()
  linux-user/flatload.c: remove unused 'out' label
  linux-user/signal.c: remove unneeded label in do_sigaltstack()
  linux-user/syscall.c: fix trailing whitespaces and style
  linux-user/syscall.c: remove unneeded labels
  linux-user/vm86.c: remove unneeded label in do_vm86()

 accel/kvm/kvm-all.c           | 30 +++++-------
 audio/paaudio.c               | 10 +---
 backends/cryptodev-vhost.c    |  4 +-
 block/backup.c                |  6 +--
 block/blkreplay.c             |  8 +---
 block/dmg.c                   | 10 +---
 block/file-posix.c            | 10 ++--
 block/gluster.c               |  3 +-
 block/qcow2-refcount.c        |  7 +--
 block/replication.c           |  9 ++--
 block/ssh.c                   | 61 ++++++++-----------------
 block/vdi.c                   | 40 ++++++----------
 block/vhdx-log.c              | 86 +++++++++++++----------------------
 block/vhdx.c                  | 10 ++--
 block/vmdk.c                  | 37 ++++++---------
 block/vpc.c                   | 12 ++---
 block/vxhs.c                  |  4 +-
 chardev/char-mux.c            |  3 +-
 chardev/char-pipe.c           | 13 ++----
 chardev/char-win.c            | 19 ++++----
 contrib/ivshmem-server/main.c |  9 ++--
 crypto/block-luks.c           |  3 +-
 exec.c                        | 13 +++---
 fsdev/virtfs-proxy-helper.c   |  4 +-
 hw/9pfs/9p-local.c            | 12 ++---
 hw/9pfs/9p.c                  |  9 ++--
 hw/alpha/typhoon.c            | 18 ++++----
 hw/i386/amd_iommu.c           | 13 ++----
 hw/i386/intel_iommu.c         |  8 ++--
 hw/intc/s390_flic_kvm.c       | 10 ++--
 hw/ipmi/ipmi_bmc_extern.c     |  5 +-
 hw/ipmi/ipmi_bmc_sim.c        |  9 +---
 hw/ipmi/ipmi_bt.c             |  8 ++--
 hw/ipmi/ipmi_kcs.c            |  4 +-
 hw/net/net_tx_pkt.c           | 11 ++---
 hw/net/vhost_net.c            |  7 ++-
 hw/ppc/ppc440_bamboo.c        |  8 +---
 hw/ppc/spapr.c                |  9 ++--
 hw/rdma/rdma_backend.c        |  4 +-
 hw/rdma/rdma_rm.c             | 11 ++---
 hw/rdma/vmw/pvrdma_dev_ring.c |  7 +--
 hw/rdma/vmw/pvrdma_main.c     | 10 ++--
 hw/s390x/event-facility.c     | 21 +++------
 hw/s390x/sclp.c               | 16 ++-----
 hw/usb/dev-mtp.c              | 13 ++----
 hw/usb/hcd-ehci.c             | 32 ++++---------
 hw/virtio/vhost.c             | 11 ++---
 linux-user/flatload.c         |  1 -
 linux-user/signal.c           | 20 +++-----
 linux-user/syscall.c          | 54 ++++++++++------------
 linux-user/vm86.c             |  7 +--
 migration/ram.c               | 18 ++------
 qemu-img.c                    |  7 +--
 qga/commands-win32.c          | 17 ++++---
 target/mips/mips-semi.c       | 15 +++---
 target/unicore32/softmmu.c    | 23 +++-------
 util/aio-posix.c              |  3 +-
 util/module.c                 | 11 ++---
 58 files changed, 293 insertions(+), 550 deletions(-)

-- 
2.24.1



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

* [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 23:44   ` David Gibson
  2020-01-06 18:23 ` [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree() Daniel Henrique Barboza
                   ` (60 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-ppc, David Gibson

'out' can be replaced by 'return' with the appropriate
return value.

CC: David Gibson <david@gibson.dropbear.id.au>
CC: qemu-ppc@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/spapr.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f11422fc41..1bfe47337c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -878,7 +878,7 @@ static int spapr_dt_cas_updates(SpaprMachineState *spapr, void *fdt,
         g_assert(smc->dr_lmb_enabled);
         ret = spapr_populate_drconf_memory(spapr, fdt);
         if (ret) {
-            goto out;
+            return ret;
         }
     }
 
@@ -889,11 +889,8 @@ static int spapr_dt_cas_updates(SpaprMachineState *spapr, void *fdt,
             return offset;
         }
     }
-    ret = spapr_ovec_populate_dt(fdt, offset, spapr->ov5_cas,
-                                 "ibm,architecture-vec-5");
-
-out:
-    return ret;
+    return spapr_ovec_populate_dt(fdt, offset, spapr->ov5_cas,
+                                  "ibm,architecture-vec-5");
 }
 
 static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)
-- 
2.24.1



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

* [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 23:45   ` David Gibson
  2020-01-06 18:23 ` [PATCH v1 03/59] kvm-all.c: remove unneeded labels Daniel Henrique Barboza
                   ` (59 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-ppc, David Gibson

'out' label can be replaced by 'return -1' in all cases.

CC: David Gibson <david@gibson.dropbear.id.au>
CC: qemu-ppc@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/ppc440_bamboo.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index 4d95c0f8a8..b782641b23 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -71,12 +71,12 @@ static int bamboo_load_device_tree(hwaddr addr,
 
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
     if (!filename) {
-        goto out;
+        return -1;
     }
     fdt = load_device_tree(filename, &fdt_size);
     g_free(filename);
     if (fdt == NULL) {
-        goto out;
+        return -1;
     }
 
     /* Manipulate device tree in memory. */
@@ -117,10 +117,6 @@ static int bamboo_load_device_tree(hwaddr addr,
     rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
     g_free(fdt);
     return 0;
-
-out:
-
-    return ret;
 }
 
 /* Create reset TLB entries for BookE, spanning the 32bit addr space.  */
-- 
2.24.1



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

* [PATCH v1 03/59] kvm-all.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates() Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 04/59] paaudio.c: " Daniel Henrique Barboza
                   ` (58 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Paolo Bonzini, Daniel Henrique Barboza

Labels 'err' and 'out' from kvm_destroy_vcpu(), kvm_init_vcpu()
and kvm_physical_sync_dirty_bitmap() can be replaced by
'return' with the appropriate return value.

CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 accel/kvm/kvm-all.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index b2f1a5bcb5..09ca99e082 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -329,26 +329,24 @@ int kvm_destroy_vcpu(CPUState *cpu)
 
     ret = kvm_arch_destroy_vcpu(cpu);
     if (ret < 0) {
-        goto err;
+        return ret;
     }
 
     mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
     if (mmap_size < 0) {
-        ret = mmap_size;
         DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");
-        goto err;
+        return mmap_size;
     }
 
     ret = munmap(cpu->kvm_run, mmap_size);
     if (ret < 0) {
-        goto err;
+        return ret;
     }
 
     vcpu = g_malloc0(sizeof(*vcpu));
     vcpu->vcpu_id = kvm_arch_vcpu_id(cpu);
     vcpu->kvm_fd = cpu->kvm_fd;
     QLIST_INSERT_HEAD(&kvm_state->kvm_parked_vcpus, vcpu, node);
-err:
     return ret;
 }
 
@@ -381,7 +379,7 @@ int kvm_init_vcpu(CPUState *cpu)
     ret = kvm_get_vcpu(s, kvm_arch_vcpu_id(cpu));
     if (ret < 0) {
         DPRINTF("kvm_create_vcpu failed\n");
-        goto err;
+        return ret;
     }
 
     cpu->kvm_fd = ret;
@@ -390,17 +388,15 @@ int kvm_init_vcpu(CPUState *cpu)
 
     mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
     if (mmap_size < 0) {
-        ret = mmap_size;
         DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");
-        goto err;
+        return mmap_size;
     }
 
     cpu->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
                         cpu->kvm_fd, 0);
     if (cpu->kvm_run == MAP_FAILED) {
-        ret = -errno;
         DPRINTF("mmap'ing vcpu state failed\n");
-        goto err;
+        return -errno;
     }
 
     if (s->coalesced_mmio && !s->coalesced_mmio_ring) {
@@ -408,9 +404,7 @@ int kvm_init_vcpu(CPUState *cpu)
             (void *)cpu->kvm_run + s->coalesced_mmio * PAGE_SIZE;
     }
 
-    ret = kvm_arch_init_vcpu(cpu);
-err:
-    return ret;
+    return kvm_arch_init_vcpu(cpu);
 }
 
 /*
@@ -565,7 +559,6 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
     KVMSlot *mem;
     hwaddr start_addr, size;
     hwaddr slot_size, slot_offset = 0;
-    int ret = 0;
 
     size = kvm_align_section(section, &start_addr);
     while (size) {
@@ -575,7 +568,7 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
         mem = kvm_lookup_matching_slot(kml, start_addr, slot_size);
         if (!mem) {
             /* We don't have a slot if we want to trap every access. */
-            goto out;
+            return 0;
         }
 
         if (!mem->dirty_bmap) {
@@ -587,8 +580,7 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
         d.slot = mem->slot | (kml->as_id << 16);
         if (kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) == -1) {
             DPRINTF("ioctl failed %d\n", errno);
-            ret = -1;
-            goto out;
+            return -1;
         }
 
         subsection.offset_within_region += slot_offset;
@@ -599,8 +591,8 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
         start_addr += slot_size;
         size -= slot_size;
     }
-out:
-    return ret;
+
+    return 0;
 }
 
 /* Alignment requirement for KVM_CLEAR_DIRTY_LOG - 64 pages */
-- 
2.24.1



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

* [PATCH v1 04/59] paaudio.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (2 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 03/59] kvm-all.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 05/59] ram.c: " Daniel Henrique Barboza
                   ` (57 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Gerd Hoffmann

Label 'fail1' in qpa_init_out() and qpa_init_in() can be replaced
by 'return -1'.

CC: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 audio/paaudio.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/audio/paaudio.c b/audio/paaudio.c
index 55a91f8980..8f42b2079c 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -470,7 +470,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
         );
     if (!pa->stream) {
         qpa_logerr (error, "pa_simple_new for playback failed\n");
-        goto fail1;
+        return -1;
     }
 
     audio_pcm_init_info (&hw->info, &obt_as);
@@ -479,9 +479,6 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
         &obt_as, ppdo->buffer_length);
 
     return 0;
-
- fail1:
-    return -1;
 }
 
 static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
@@ -518,7 +515,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
         );
     if (!pa->stream) {
         qpa_logerr (error, "pa_simple_new for capture failed\n");
-        goto fail1;
+        return -1;
     }
 
     audio_pcm_init_info (&hw->info, &obt_as);
@@ -527,9 +524,6 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
         &obt_as, ppdo->buffer_length);
 
     return 0;
-
- fail1:
-    return -1;
 }
 
 static void qpa_simple_disconnect(PAConnection *c, pa_stream *stream)
-- 
2.24.1



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

* [PATCH v1 05/59] ram.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (3 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 04/59] paaudio.c: " Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:57   ` Dr. David Alan Gilbert
                     ` (2 more replies)
  2020-01-06 18:23 ` [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting() Daniel Henrique Barboza
                   ` (56 subsequent siblings)
  61 siblings, 3 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Daniel Henrique Barboza, Dr . David Alan Gilbert,
	Juan Quintela

ram_save_queue_pages() has an 'err' label that can be replaced by
'return -1' instead.

Same thing with ram_discard_range(), and in this case we can also
get rid of the 'ret' variable and return either '-1' on error
or the result of ram_block_discard_range().

CC: Juan Quintela <quintela@redhat.com>
CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 migration/ram.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 96feb4062c..980cc644d7 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2434,7 +2434,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
              * it's the 1st request.
              */
             error_report("ram_save_queue_pages no previous block");
-            goto err;
+            return -1;
         }
     } else {
         ramblock = qemu_ram_block_by_name(rbname);
@@ -2442,7 +2442,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
         if (!ramblock) {
             /* We shouldn't be asked for a non-existent RAMBlock */
             error_report("ram_save_queue_pages no block '%s'", rbname);
-            goto err;
+            return -1;
         }
         rs->last_req_rb = ramblock;
     }
@@ -2451,7 +2451,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
         error_report("%s request overrun start=" RAM_ADDR_FMT " len="
                      RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT,
                      __func__, start, len, ramblock->used_length);
-        goto err;
+        return -1;
     }
 
     struct RAMSrcPageRequest *new_entry =
@@ -2467,9 +2467,6 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
     qemu_mutex_unlock(&rs->src_page_req_mutex);
 
     return 0;
-
-err:
-    return -1;
 }
 
 static bool save_page_use_compression(RAMState *rs)
@@ -3072,8 +3069,6 @@ int ram_postcopy_send_discard_bitmap(MigrationState *ms)
  */
 int ram_discard_range(const char *rbname, uint64_t start, size_t length)
 {
-    int ret = -1;
-
     trace_ram_discard_range(rbname, start, length);
 
     RCU_READ_LOCK_GUARD();
@@ -3081,7 +3076,7 @@ int ram_discard_range(const char *rbname, uint64_t start, size_t length)
 
     if (!rb) {
         error_report("ram_discard_range: Failed to find block '%s'", rbname);
-        goto err;
+        return -1;
     }
 
     /*
@@ -3093,10 +3088,7 @@ int ram_discard_range(const char *rbname, uint64_t start, size_t length)
                      length >> qemu_target_page_bits());
     }
 
-    ret = ram_block_discard_range(rb, start, length);
-
-err:
-    return ret;
+    return ram_block_discard_range(rb, start, length);
 }
 
 /*
-- 
2.24.1



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

* [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (4 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 05/59] ram.c: " Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-09 20:41   ` Aleksandar Markovic
  2020-01-24 17:22   ` Aleksandar Markovic
  2020-01-06 18:23 ` [PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2() Daniel Henrique Barboza
                   ` (55 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Aleksandar Rikalo, Daniel Henrique Barboza,
	Aleksandar Markovic, Aurelien Jarno

The label 'uhi_done' is a simple 'return' call and can
be removed for a bit more clarity in the code.

CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Aleksandar Markovic <amarkovic@wavecomp.com>
CC: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/mips/mips-semi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/target/mips/mips-semi.c b/target/mips/mips-semi.c
index 35bdfd7c77..10a710c1e8 100644
--- a/target/mips/mips-semi.c
+++ b/target/mips/mips-semi.c
@@ -218,7 +218,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num,
         if (!p) {                               \
             gpr[2] = -1;                        \
             gpr[3] = EFAULT;                    \
-            goto uhi_done;                      \
+            return;                             \
         }                                       \
     } while (0)
 
@@ -228,14 +228,14 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num,
         if (!p) {                                       \
             gpr[2] = -1;                                \
             gpr[3] = EFAULT;                            \
-            goto uhi_done;                              \
+            return;                                     \
         }                                               \
         p2 = lock_user_string(addr2);                   \
         if (!p2) {                                      \
             unlock_user(p, addr, 0);                    \
             gpr[2] = -1;                                \
             gpr[3] = EFAULT;                            \
-            goto uhi_done;                              \
+            return;                                     \
         }                                               \
     } while (0)
 
@@ -272,7 +272,7 @@ void helper_do_semihosting(CPUMIPSState *env)
         if (gpr[4] < 3) {
             /* ignore closing stdin/stdout/stderr */
             gpr[2] = 0;
-            goto uhi_done;
+            return;
         }
         gpr[2] = close(gpr[4]);
         gpr[3] = errno_mips(errno);
@@ -302,7 +302,7 @@ void helper_do_semihosting(CPUMIPSState *env)
             gpr[2] = fstat(gpr[4], &sbuf);
             gpr[3] = errno_mips(errno);
             if (gpr[2]) {
-                goto uhi_done;
+                return;
             }
             gpr[2] = copy_stat_to_target(env, &sbuf, gpr[5]);
             gpr[3] = errno_mips(errno);
@@ -314,14 +314,14 @@ void helper_do_semihosting(CPUMIPSState *env)
     case UHI_argnlen:
         if (gpr[4] >= semihosting_get_argc()) {
             gpr[2] = -1;
-            goto uhi_done;
+            return;
         }
         gpr[2] = strlen(semihosting_get_arg(gpr[4]));
         break;
     case UHI_argn:
         if (gpr[4] >= semihosting_get_argc()) {
             gpr[2] = -1;
-            goto uhi_done;
+            return;
         }
         gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]);
         break;
@@ -369,6 +369,5 @@ void helper_do_semihosting(CPUMIPSState *env)
         fprintf(stderr, "Unknown UHI operation %d\n", op);
         abort();
     }
-uhi_done:
     return;
 }
-- 
2.24.1



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

* [PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (5 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label Daniel Henrique Barboza
                   ` (54 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Guan Xuetao

'do_fault' is a label that executes 'return code'. The 'code'
variable is an integer that is set to zero, then in all instances
it is set to another value right before 'do_fault'.

We can get rid of both the label and the variable to make
the code a bit cleaner.

CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/unicore32/softmmu.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/target/unicore32/softmmu.c b/target/unicore32/softmmu.c
index cbdaa500b7..3373400cba 100644
--- a/target/unicore32/softmmu.c
+++ b/target/unicore32/softmmu.c
@@ -125,7 +125,6 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         target_ulong *page_size)
 {
     CPUState *cs = env_cpu(env);
-    int code;
     uint32_t table;
     uint32_t desc;
     uint32_t phys_addr;
@@ -135,13 +134,11 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
     table = env->cp0.c2_base & 0xfffff000;
     table |= (address >> 20) & 0xffc;
     desc = ldl_phys(cs->as, table);
-    code = 0;
     switch (PAGETABLE_TYPE(desc)) {
     case 3:
         /* Superpage  */
         if (!(desc & UC32_PAGETABLE_EXIST)) {
-            code = 0x0b; /* superpage miss */
-            goto do_fault;
+            return 0x0b; /* superpage miss */
         }
         phys_addr = (desc & 0xffc00000) | (address & 0x003fffff);
         *page_size = SUPERPAGE_SIZE;
@@ -152,8 +149,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
             DPRINTF("PGD address %x, desc %x\n", table, desc);
         }
         if (!(desc & UC32_PAGETABLE_EXIST)) {
-            code = 0x05; /* second pagetable miss */
-            goto do_fault;
+            return 0x05; /* second pagetable miss */
         }
         table = (desc & 0xfffff000) | ((address >> 10) & 0xffc);
         desc = ldl_phys(cs->as, table);
@@ -162,8 +158,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
             DPRINTF("PTE address %x, desc %x\n", table, desc);
         }
         if (!(desc & UC32_PAGETABLE_EXIST)) {
-            code = 0x08; /* page miss */
-            goto do_fault;
+            return 0x08; /* page miss */
         }
         switch (PAGETABLE_TYPE(desc)) {
         case 0:
@@ -185,8 +180,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         *prot |= PAGE_READ;
     } else {
         if (is_user && (access_type == 0)) {
-            code = 0x11; /* access unreadable area */
-            goto do_fault;
+            return 0x11; /* access unreadable area */
         }
     }
 
@@ -194,8 +188,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         *prot |= PAGE_WRITE;
     } else {
         if (is_user && (access_type == 1)) {
-            code = 0x12; /* access unwritable area */
-            goto do_fault;
+            return 0x12; /* access unwritable area */
         }
     }
 
@@ -203,13 +196,11 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         *prot |= PAGE_EXEC;
     } else {
         if (is_user && (access_type == 2)) {
-            code = 0x13; /* access unexecutable area */
-            goto do_fault;
+            return 0x13; /* access unexecutable area */
         }
     }
 
-do_fault:
-    return code;
+    return 0;
 }
 
 bool uc32_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
-- 
2.24.1



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

* [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (6 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 19:02   ` Marc-André Lureau
  2020-01-06 18:23 ` [PATCH v1 09/59] chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init() Daniel Henrique Barboza
                   ` (53 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Marc-André Lureau, Daniel Henrique Barboza,
	Paolo Bonzini

CC: Marc-André Lureau <marcandre.lureau@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 chardev/char-mux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index 200c62a0d0..edbaaf5cbf 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -140,7 +140,7 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
     if (d->term_got_escape) {
         d->term_got_escape = 0;
         if (ch == term_escape_char) {
-            goto send_char;
+            return 1;
         }
         switch (ch) {
         case '?':
@@ -174,7 +174,6 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
     } else if (ch == term_escape_char) {
         d->term_got_escape = 1;
     } else {
-    send_char:
         return 1;
     }
     return 0;
-- 
2.24.1



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

* [PATCH v1 09/59] chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (7 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 19:01   ` Marc-André Lureau
  2020-01-06 18:23 ` [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init() Daniel Henrique Barboza
                   ` (52 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Marc-André Lureau, Daniel Henrique Barboza,
	Paolo Bonzini

The 'fail' label is simply doing a 'return -1'.

CC: Marc-André Lureau <marcandre.lureau@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 chardev/char-pipe.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c
index 94d714ffcd..65d52beb0d 100644
--- a/chardev/char-pipe.c
+++ b/chardev/char-pipe.c
@@ -54,12 +54,12 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
     s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!s->hsend) {
         error_setg(errp, "Failed CreateEvent");
-        goto fail;
+        return -1;
     }
     s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!s->hrecv) {
         error_setg(errp, "Failed CreateEvent");
-        goto fail;
+        return -1;
     }
 
     openname = g_strdup_printf("\\\\.\\pipe\\%s", filename);
@@ -72,7 +72,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
     if (s->file == INVALID_HANDLE_VALUE) {
         error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError());
         s->file = NULL;
-        goto fail;
+        return -1;
     }
 
     ZeroMemory(&ov, sizeof(ov));
@@ -80,7 +80,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
     ret = ConnectNamedPipe(s->file, &ov);
     if (ret) {
         error_setg(errp, "Failed ConnectNamedPipe");
-        goto fail;
+        return -1;
     }
 
     ret = GetOverlappedResult(s->file, &ov, &size, TRUE);
@@ -90,7 +90,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
             CloseHandle(ov.hEvent);
             ov.hEvent = NULL;
         }
-        goto fail;
+        return -1;
     }
 
     if (ov.hEvent) {
@@ -99,9 +99,6 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
     }
     qemu_add_polling_cb(win_chr_pipe_poll, chr);
     return 0;
-
- fail:
-    return -1;
 }
 
 static void qemu_chr_open_pipe(Chardev *chr,
-- 
2.24.1



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

* [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (8 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 09/59] chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 19:01   ` Marc-André Lureau
  2020-01-07  6:52   ` Philippe Mathieu-Daudé
  2020-01-06 18:23 ` [PATCH v1 11/59] exec.c: remove 'err' label in ram_block_discard_range() Daniel Henrique Barboza
                   ` (51 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Marc-André Lureau, Daniel Henrique Barboza,
	Paolo Bonzini

The 'fail' label is a simply call to 'return -1' on error. Remove
it and do the return call instead.

CC: Marc-André Lureau <marcandre.lureau@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 chardev/char-win.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/chardev/char-win.c b/chardev/char-win.c
index 34825f683d..72c232e6d9 100644
--- a/chardev/char-win.c
+++ b/chardev/char-win.c
@@ -85,12 +85,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
     s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!s->hsend) {
         error_setg(errp, "Failed CreateEvent");
-        goto fail;
+        return -1;
     }
     s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!s->hrecv) {
         error_setg(errp, "Failed CreateEvent");
-        goto fail;
+        return -1;
     }
 
     s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
@@ -98,12 +98,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
     if (s->file == INVALID_HANDLE_VALUE) {
         error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
         s->file = NULL;
-        goto fail;
+        return -1;
     }
 
     if (!SetupComm(s->file, NRECVBUF, NSENDBUF)) {
         error_setg(errp, "Failed SetupComm");
-        goto fail;
+        return -1;
     }
 
     ZeroMemory(&comcfg, sizeof(COMMCONFIG));
@@ -114,29 +114,26 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
 
     if (!SetCommState(s->file, &comcfg.dcb)) {
         error_setg(errp, "Failed SetCommState");
-        goto fail;
+        return -1;
     }
 
     if (!SetCommMask(s->file, EV_ERR)) {
         error_setg(errp, "Failed SetCommMask");
-        goto fail;
+        return -1;
     }
 
     cto.ReadIntervalTimeout = MAXDWORD;
     if (!SetCommTimeouts(s->file, &cto)) {
         error_setg(errp, "Failed SetCommTimeouts");
-        goto fail;
+        return -1;
     }
 
     if (!ClearCommError(s->file, &err, &comstat)) {
         error_setg(errp, "Failed ClearCommError");
-        goto fail;
+        return -1;
     }
     qemu_add_polling_cb(win_chr_serial_poll, chr);
     return 0;
-
- fail:
-    return -1;
 }
 
 int win_chr_pipe_poll(void *opaque)
-- 
2.24.1



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

* [PATCH v1 11/59] exec.c: remove 'err' label in ram_block_discard_range()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (9 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid() Daniel Henrique Barboza
                   ` (50 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Paolo Bonzini, Daniel Henrique Barboza

'err' is a label that just executes 'return ret'. We can remove
the label and simply 'return ret' on error.

CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 exec.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/exec.c b/exec.c
index d4b769d0d4..7cfd80826e 100644
--- a/exec.c
+++ b/exec.c
@@ -3898,7 +3898,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
     if ((uintptr_t)host_startaddr & (rb->page_size - 1)) {
         error_report("ram_block_discard_range: Unaligned start address: %p",
                      host_startaddr);
-        goto err;
+        return ret;
     }
 
     if ((start + length) <= rb->used_length) {
@@ -3906,7 +3906,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
         if (length & (rb->page_size - 1)) {
             error_report("ram_block_discard_range: Unaligned length: %zx",
                          length);
-            goto err;
+            return ret;
         }
 
         errno = ENOTSUP; /* If we are missing MADVISE etc */
@@ -3930,14 +3930,14 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
                 error_report("ram_block_discard_range: Failed to fallocate "
                              "%s:%" PRIx64 " +%zx (%d)",
                              rb->idstr, start, length, ret);
-                goto err;
+                return ret;
             }
 #else
             ret = -ENOSYS;
             error_report("ram_block_discard_range: fallocate not available/file"
                          "%s:%" PRIx64 " +%zx (%d)",
                          rb->idstr, start, length, ret);
-            goto err;
+            return ret;
 #endif
         }
         if (need_madvise) {
@@ -3953,14 +3953,14 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
                 error_report("ram_block_discard_range: Failed to discard range "
                              "%s:%" PRIx64 " +%zx (%d)",
                              rb->idstr, start, length, ret);
-                goto err;
+                return ret;
             }
 #else
             ret = -ENOSYS;
             error_report("ram_block_discard_range: MADVISE not available"
                          "%s:%" PRIx64 " +%zx (%d)",
                          rb->idstr, start, length, ret);
-            goto err;
+            return ret;
 #endif
         }
         trace_ram_block_discard_range(rb->idstr, host_startaddr, length,
@@ -3971,7 +3971,6 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
                      rb->idstr, start, length, rb->used_length);
     }
 
-err:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (10 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 11/59] exec.c: remove 'err' label in ram_block_discard_range() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-07  9:51   ` Greg Kurz
  2020-01-06 18:23 ` [PATCH v1 13/59] block/vdi.c: remove 'fail' label in vdi_open() Daniel Henrique Barboza
                   ` (49 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Greg Kurz

'err_out' can be removed and be replaced by 'return -errno'
in its only instance in the function.

CC: Greg Kurz <groug@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 fsdev/virtfs-proxy-helper.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 0d4de49dcf..aa1ab2590d 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -287,8 +287,7 @@ static int setugid(int uid, int gid, int *suid, int *sgid)
     *sgid = getegid();
 
     if (setresgid(-1, gid, *sgid) == -1) {
-        retval = -errno;
-        goto err_out;
+        return -errno;
     }
 
     if (setresuid(-1, uid, *suid) == -1) {
@@ -322,7 +321,6 @@ err_sgid:
     if (setresgid(-1, *sgid, *sgid) == -1) {
         abort();
     }
-err_out:
     return retval;
 }
 
-- 
2.24.1



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

* [PATCH v1 13/59] block/vdi.c: remove 'fail' label in vdi_open()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (11 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 21:04   ` Stefan Weil
  2020-01-06 18:23 ` [PATCH v1 14/59] block/file-posix.c: remove unneeded labels Daniel Henrique Barboza
                   ` (48 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Daniel Henrique Barboza, qemu-block

The 'fail' label can be replaced by 'return ret' or by
a 'return' with the error code that was being set right
before the 'goto' call.

CC: Stefan Weil <sw@weilnetz.de>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/vdi.c | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 0142da7233..6d486ffed9 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -388,7 +388,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
 
     ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
     if (ret < 0) {
-        goto fail;
+        return ret;
     }
 
     vdi_header_to_cpu(&header);
@@ -400,8 +400,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
         error_setg(errp, "Unsupported VDI image size (size is 0x%" PRIx64
                           ", max supported is 0x%" PRIx64 ")",
                           header.disk_size, VDI_DISK_SIZE_MAX);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     }
 
     uuid_link = header.uuid_link;
@@ -418,58 +417,48 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
     if (header.signature != VDI_SIGNATURE) {
         error_setg(errp, "Image not in VDI format (bad signature %08" PRIx32
                    ")", header.signature);
-        ret = -EINVAL;
-        goto fail;
+        return -EINVAL;
     } else if (header.version != VDI_VERSION_1_1) {
         error_setg(errp, "unsupported VDI image (version %" PRIu32 ".%" PRIu32
                    ")", header.version >> 16, header.version & 0xffff);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (header.offset_bmap % SECTOR_SIZE != 0) {
         /* We only support block maps which start on a sector boundary. */
         error_setg(errp, "unsupported VDI image (unaligned block map offset "
                    "0x%" PRIx32 ")", header.offset_bmap);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (header.offset_data % SECTOR_SIZE != 0) {
         /* We only support data blocks which start on a sector boundary. */
         error_setg(errp, "unsupported VDI image (unaligned data offset 0x%"
                    PRIx32 ")", header.offset_data);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (header.sector_size != SECTOR_SIZE) {
         error_setg(errp, "unsupported VDI image (sector size %" PRIu32
                    " is not %u)", header.sector_size, SECTOR_SIZE);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
         error_setg(errp, "unsupported VDI image (block size %" PRIu32
                          " is not %" PRIu32 ")",
                    header.block_size, DEFAULT_CLUSTER_SIZE);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (header.disk_size >
                (uint64_t)header.blocks_in_image * header.block_size) {
         error_setg(errp, "unsupported VDI image (disk size %" PRIu64 ", "
                    "image bitmap has room for %" PRIu64 ")",
                    header.disk_size,
                    (uint64_t)header.blocks_in_image * header.block_size);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (!qemu_uuid_is_null(&uuid_link)) {
         error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (!qemu_uuid_is_null(&uuid_parent)) {
         error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     } else if (header.blocks_in_image > VDI_BLOCKS_IN_IMAGE_MAX) {
         error_setg(errp, "unsupported VDI image "
                          "(too many blocks %u, max is %u)",
                           header.blocks_in_image, VDI_BLOCKS_IN_IMAGE_MAX);
-        ret = -ENOTSUP;
-        goto fail;
+        return -ENOTSUP;
     }
 
     bs->total_sectors = header.disk_size / SECTOR_SIZE;
@@ -482,8 +471,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
     bmap_size = DIV_ROUND_UP(bmap_size, SECTOR_SIZE);
     s->bmap = qemu_try_blockalign(bs->file->bs, bmap_size * SECTOR_SIZE);
     if (s->bmap == NULL) {
-        ret = -ENOMEM;
-        goto fail;
+        return -ENOMEM;
     }
 
     ret = bdrv_pread(bs->file, header.offset_bmap, s->bmap,
@@ -509,8 +497,6 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
 
  fail_free_bmap:
     qemu_vfree(s->bmap);
-
- fail:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 14/59] block/file-posix.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (12 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 13/59] block/vdi.c: remove 'fail' label in vdi_open() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open() Daniel Henrique Barboza
                   ` (47 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Kevin Wolf, Daniel Henrique Barboza, qemu-block

'out' label from cdrom_probe_device() can be removed, and its
only instance replaced by 'return prio'.

In raw_co_create(), 'out' can be replaced by 'return -errno' in
the error condition it is being called.

CC: Kevin Wolf <kwolf@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/file-posix.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 1b805bd938..b1a6549806 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2265,9 +2265,8 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
     /* Create file */
     fd = qemu_open(file_opts->filename, O_RDWR | O_CREAT | O_BINARY, 0644);
     if (fd < 0) {
-        result = -errno;
-        error_setg_errno(errp, -result, "Could not create file");
-        goto out;
+        error_setg_errno(errp, errno, "Could not create file");
+        return -errno;
     }
 
     /* Take permissions: We want to discard everything, so we need
@@ -2342,7 +2341,7 @@ out_close:
         result = -errno;
         error_setg_errno(errp, -result, "Could not close the new file");
     }
-out:
+
     return result;
 }
 
@@ -3554,7 +3553,7 @@ static int cdrom_probe_device(const char *filename)
 
     fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
     if (fd < 0) {
-        goto out;
+        return prio;
     }
     ret = fstat(fd, &st);
     if (ret == -1 || !S_ISBLK(st.st_mode)) {
@@ -3568,7 +3567,6 @@ static int cdrom_probe_device(const char *filename)
 
 outc:
     qemu_close(fd);
-out:
     return prio;
 }
 
-- 
2.24.1



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

* [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (13 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 14/59] block/file-posix.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-10  6:07   ` Pavel Dovgalyuk
  2020-01-06 18:23 ` [PATCH v1 16/59] block/gluster.c: remove unneeded 'exit' label Daniel Henrique Barboza
                   ` (46 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Paolo Bonzini, Daniel Henrique Barboza, Pavel Dovgalyuk

Both the 'fail' label and the 'ret' variable can be removed.
Use 'return -EINVAL' in the error condition and 'return 0' in
the end of the function.

CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/blkreplay.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/block/blkreplay.c b/block/blkreplay.c
index c96ac8f4bc..d8c4c311f3 100644
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -24,23 +24,19 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
                           Error **errp)
 {
     Error *local_err = NULL;
-    int ret;
 
     /* Open the image file */
     bs->file = bdrv_open_child(NULL, options, "image",
                                bs, &child_file, false, &local_err);
     if (local_err) {
-        ret = -EINVAL;
         error_propagate(errp, local_err);
-        goto fail;
+        return -EINVAL;
     }
 
     bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
     bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
 
-    ret = 0;
-fail:
-    return ret;
+    return 0;
 }
 
 static int64_t blkreplay_getlength(BlockDriverState *bs)
-- 
2.24.1



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

* [PATCH v1 16/59] block/gluster.c: remove unneeded 'exit' label
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (14 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block() Daniel Henrique Barboza
                   ` (45 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-block

'exit' label in find_allocation() can be replaced by a
'return -ENOTSUP' call.

CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/gluster.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/gluster.c b/block/gluster.c
index 4fa4a77a47..43bf76eed7 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -1381,7 +1381,7 @@ static int find_allocation(BlockDriverState *bs, off_t start,
     BDRVGlusterState *s = bs->opaque;
 
     if (!s->supports_seek_data) {
-        goto exit;
+        return -ENOTSUP;
     }
 
 #if defined SEEK_HOLE && defined SEEK_DATA
@@ -1466,7 +1466,6 @@ static int find_allocation(BlockDriverState *bs, off_t start,
     return -EBUSY;
 #endif
 
-exit:
     return -ENOTSUP;
 }
 
-- 
2.24.1



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

* [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (15 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 16/59] block/gluster.c: remove unneeded 'exit' label Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-07 16:54   ` Stefan Hajnoczi
  2020-01-06 18:23 ` [PATCH v1 18/59] qcow2-refcount.c: remove unneeded 'fail' label in qcow2_refcount_init() Daniel Henrique Barboza
                   ` (44 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Daniel Henrique Barboza, qemu-block, Stefan Hajnoczi

Both the 'fail' label and 'ret' variable can be removed from the
function. Instead, call 'return -EINVAL' in the error conditions.

CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/dmg.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/block/dmg.c b/block/dmg.c
index 4a045f2b3e..ce39a87864 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -217,7 +217,6 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
                                uint8_t *buffer, uint32_t count)
 {
     uint32_t type, i;
-    int ret;
     size_t new_size;
     uint32_t chunk_count;
     int64_t offset = 0;
@@ -273,8 +272,7 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
             error_report("sector count %" PRIu64 " for chunk %" PRIu32
                          " is larger than max (%u)",
                          s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
-            ret = -EINVAL;
-            goto fail;
+            return -EINVAL;
         }
 
         /* offset in (compressed) data fork */
@@ -288,8 +286,7 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
             error_report("length %" PRIu64 " for chunk %" PRIu32
                          " is larger than max (%u)",
                          s->lengths[i], i, DMG_LENGTHS_MAX);
-            ret = -EINVAL;
-            goto fail;
+            return -EINVAL;
         }
 
         update_max_chunk_size(s, i, &ds->max_compressed_size,
@@ -298,9 +295,6 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
     }
     s->n_chunks += chunk_count;
     return 0;
-
-fail:
-    return ret;
 }
 
 static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds,
-- 
2.24.1



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

* [PATCH v1 18/59] qcow2-refcount.c: remove unneeded 'fail' label in qcow2_refcount_init()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (16 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 19/59] block/ssh.c: remove unneeded labels Daniel Henrique Barboza
                   ` (43 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Kevin Wolf, Daniel Henrique Barboza, qemu-block, Max Reitz

'fail' label can be replaced by 'return ret' and 'return -ENOMEM'
calls.

CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/qcow2-refcount.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index f67ac6b2d8..1fe66677d1 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -111,22 +111,19 @@ int qcow2_refcount_init(BlockDriverState *bs)
 
     if (s->refcount_table_size > 0) {
         if (s->refcount_table == NULL) {
-            ret = -ENOMEM;
-            goto fail;
+            return -ENOMEM;
         }
         BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
         ret = bdrv_pread(bs->file, s->refcount_table_offset,
                          s->refcount_table, refcount_table_size2);
         if (ret < 0) {
-            goto fail;
+            return ret;
         }
         for(i = 0; i < s->refcount_table_size; i++)
             be64_to_cpus(&s->refcount_table[i]);
         update_max_refcount_table_index(s);
     }
     return 0;
- fail:
-    return ret;
 }
 
 void qcow2_refcount_close(BlockDriverState *bs)
-- 
2.24.1



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

* [PATCH v1 19/59] block/ssh.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (17 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 18/59] qcow2-refcount.c: remove unneeded 'fail' label in qcow2_refcount_init() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:37   ` Richard W.M. Jones
  2020-01-06 18:23 ` [PATCH v1 20/59] block/vpc.c: remove unneeded 'fail' label in create_dynamic_disk() Daniel Henrique Barboza
                   ` (42 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Daniel Henrique Barboza, Richard W . M . Jones, qemu-block

The 'out' labels for check_host_key_knownhosts() and authenticate()
functions can be removed and, instead, call 'return' with the
appropriate return value. The 'ret' integer from both functions
could also be removed.

CC: Richard W.M. Jones <rjones@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/ssh.c | 61 +++++++++++++++++------------------------------------
 1 file changed, 19 insertions(+), 42 deletions(-)

diff --git a/block/ssh.c b/block/ssh.c
index b4375cf7d2..e0c56d002a 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -276,7 +276,6 @@ static void ssh_parse_filename(const char *filename, QDict *options,
 
 static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
 {
-    int ret;
 #ifdef HAVE_LIBSSH_0_8
     enum ssh_known_hosts_e state;
     int r;
@@ -295,7 +294,6 @@ static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
         trace_ssh_check_host_key_knownhosts();
         break;
     case SSH_KNOWN_HOSTS_CHANGED:
-        ret = -EINVAL;
         r = ssh_get_server_publickey(s->session, &pubkey);
         if (r == 0) {
             r = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256,
@@ -320,28 +318,23 @@ static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
                        "host key does not match the one in known_hosts; this "
                        "may be a possible attack");
         }
-        goto out;
+        return -EINVAL;
     case SSH_KNOWN_HOSTS_OTHER:
-        ret = -EINVAL;
         error_setg(errp,
                    "host key for this server not found, another type exists");
-        goto out;
+        return -EINVAL;
     case SSH_KNOWN_HOSTS_UNKNOWN:
-        ret = -EINVAL;
         error_setg(errp, "no host key was found in known_hosts");
-        goto out;
+        return -EINVAL;
     case SSH_KNOWN_HOSTS_NOT_FOUND:
-        ret = -ENOENT;
         error_setg(errp, "known_hosts file not found");
-        goto out;
+        return -ENOENT;
     case SSH_KNOWN_HOSTS_ERROR:
-        ret = -EINVAL;
         error_setg(errp, "error while checking the host");
-        goto out;
+        return -EINVAL;
     default:
-        ret = -EINVAL;
         error_setg(errp, "error while checking for known server (%d)", state);
-        goto out;
+        return -EINVAL;
     }
 #else /* !HAVE_LIBSSH_0_8 */
     int state;
@@ -355,40 +348,31 @@ static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
         trace_ssh_check_host_key_knownhosts();
         break;
     case SSH_SERVER_KNOWN_CHANGED:
-        ret = -EINVAL;
         error_setg(errp,
                    "host key does not match the one in known_hosts; this "
                    "may be a possible attack");
-        goto out;
+        return -EINVAL;
     case SSH_SERVER_FOUND_OTHER:
-        ret = -EINVAL;
         error_setg(errp,
                    "host key for this server not found, another type exists");
-        goto out;
+        return -EINVAL;
     case SSH_SERVER_FILE_NOT_FOUND:
-        ret = -ENOENT;
         error_setg(errp, "known_hosts file not found");
-        goto out;
+        return -ENOENT;
     case SSH_SERVER_NOT_KNOWN:
-        ret = -EINVAL;
         error_setg(errp, "no host key was found in known_hosts");
-        goto out;
+        return -EINVAL;
     case SSH_SERVER_ERROR:
-        ret = -EINVAL;
         error_setg(errp, "server error");
-        goto out;
+        return -EINVAL;
     default:
-        ret = -EINVAL;
         error_setg(errp, "error while checking for known server (%d)", state);
-        goto out;
+        return -EINVAL;
     }
 #endif /* !HAVE_LIBSSH_0_8 */
 
     /* known_hosts checking successful. */
-    ret = 0;
-
- out:
-    return ret;
+    return 0;
 }
 
 static unsigned hex2decimal(char ch)
@@ -501,20 +485,18 @@ static int check_host_key(BDRVSSHState *s, SshHostKeyCheck *hkc, Error **errp)
 
 static int authenticate(BDRVSSHState *s, Error **errp)
 {
-    int r, ret;
+    int r;
     int method;
 
     /* Try to authenticate with the "none" method. */
     r = ssh_userauth_none(s->session, NULL);
     if (r == SSH_AUTH_ERROR) {
-        ret = -EPERM;
         session_error_setg(errp, s, "failed to authenticate using none "
                                     "authentication");
-        goto out;
+        return -EPERM;
     } else if (r == SSH_AUTH_SUCCESS) {
         /* Authenticated! */
-        ret = 0;
-        goto out;
+        return 0;
     }
 
     method = ssh_userauth_list(s->session, NULL);
@@ -527,23 +509,18 @@ static int authenticate(BDRVSSHState *s, Error **errp)
     if (method & SSH_AUTH_METHOD_PUBLICKEY) {
         r = ssh_userauth_publickey_auto(s->session, NULL, NULL);
         if (r == SSH_AUTH_ERROR) {
-            ret = -EINVAL;
             session_error_setg(errp, s, "failed to authenticate using "
                                         "publickey authentication");
-            goto out;
+            return -EINVAL;
         } else if (r == SSH_AUTH_SUCCESS) {
             /* Authenticated! */
-            ret = 0;
-            goto out;
+            return 0;
         }
     }
 
-    ret = -EPERM;
     error_setg(errp, "failed to authenticate using publickey authentication "
                "and the identities held by your ssh-agent");
-
- out:
-    return ret;
+    return -EPERM;
 }
 
 static QemuOptsList ssh_runtime_opts = {
-- 
2.24.1



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

* [PATCH v1 20/59] block/vpc.c: remove unneeded 'fail' label in create_dynamic_disk()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (18 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 19/59] block/ssh.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 21/59] block/backup.c remove unneeded 'out' label in backup_run() Daniel Henrique Barboza
                   ` (41 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Kevin Wolf, Daniel Henrique Barboza, qemu-block

'fail' label can be replaced by 'return ret' on error and
'return 0' in the end of the function.

CC: Kevin Wolf <kwolf@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/vpc.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/block/vpc.c b/block/vpc.c
index a65550298e..2678b48dfd 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -839,13 +839,13 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
 
     ret = blk_pwrite(blk, offset, buf, HEADER_SIZE, 0);
     if (ret < 0) {
-        goto fail;
+        return ret;
     }
 
     offset = 1536 + ((num_bat_entries * 4 + 511) & ~511);
     ret = blk_pwrite(blk, offset, buf, HEADER_SIZE, 0);
     if (ret < 0) {
-        goto fail;
+        return ret;
     }
 
     /* Write the initial BAT */
@@ -855,7 +855,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
     for (i = 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) {
         ret = blk_pwrite(blk, offset, buf, 512, 0);
         if (ret < 0) {
-            goto fail;
+            return ret;
         }
         offset += 512;
     }
@@ -882,12 +882,10 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
 
     ret = blk_pwrite(blk, offset, buf, 1024, 0);
     if (ret < 0) {
-        goto fail;
+        return ret;
     }
 
-    ret = 0;
- fail:
-    return ret;
+    return 0;
 }
 
 static int create_fixed_disk(BlockBackend *blk, uint8_t *buf,
-- 
2.24.1



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

* [PATCH v1 21/59] block/backup.c remove unneeded 'out' label in backup_run()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (19 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 20/59] block/vpc.c: remove unneeded 'fail' label in create_dynamic_disk() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 22/59] block/vmdk.c: remove unneeded labels Daniel Henrique Barboza
                   ` (40 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, John Snow, qemu-block

'out' can be replaced by 'return ret' and 'return -ECANCELED'.

CC: John Snow <jsnow@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/backup.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/block/backup.c b/block/backup.c
index cf62b1a38c..e73294872c 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -254,13 +254,12 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
 
         for (offset = 0; offset < s->len; ) {
             if (yield_and_check(s)) {
-                ret = -ECANCELED;
-                goto out;
+                return -ECANCELED;
             }
 
             ret = block_copy_reset_unallocated(s->bcs, offset, &count);
             if (ret < 0) {
-                goto out;
+                return ret;
             }
 
             offset += count;
@@ -284,7 +283,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
         ret = backup_loop(s);
     }
 
- out:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 22/59] block/vmdk.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (20 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 21/59] block/backup.c remove unneeded 'out' label in backup_run() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 23/59] block/vxhs.c: remove unneeded 'out' label in vxhs_iio_callback() Daniel Henrique Barboza
                   ` (39 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Fam Zheng, Daniel Henrique Barboza, qemu-block

'exit' label from vmdk_open_desc_file() can be replaced by
'return' calls with the appropriate value. Same thing with
the 'out' label from vmdk_co_create().

CC: Fam Zheng <fam@euphon.net>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/vmdk.c | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 20e909d997..d1491486de 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1222,14 +1222,12 @@ out:
 static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
                                QDict *options, Error **errp)
 {
-    int ret;
     char ct[128];
     BDRVVmdkState *s = bs->opaque;
 
     if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {
         error_setg(errp, "invalid VMDK image descriptor");
-        ret = -EINVAL;
-        goto exit;
+        return -EINVAL;
     }
     if (strcmp(ct, "monolithicFlat") &&
         strcmp(ct, "vmfs") &&
@@ -1238,14 +1236,11 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
         strcmp(ct, "twoGbMaxExtentSparse") &&
         strcmp(ct, "twoGbMaxExtentFlat")) {
         error_setg(errp, "Unsupported image type '%s'", ct);
-        ret = -ENOTSUP;
-        goto exit;
+        return -ENOTSUP;
     }
     s->create_type = g_strdup(ct);
     s->desc_offset = 0;
-    ret = vmdk_parse_extents(buf, bs, options, errp);
-exit:
-    return ret;
+    return vmdk_parse_extents(buf, bs, options, errp);
 }
 
 static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
@@ -2738,7 +2733,6 @@ static BlockBackend *vmdk_co_create_cb(int64_t size, int idx,
 static int coroutine_fn vmdk_co_create(BlockdevCreateOptions *create_options,
                                        Error **errp)
 {
-    int ret;
     BlockdevCreateOptionsVmdk *opts;
 
     opts = &create_options->u.vmdk;
@@ -2746,23 +2740,18 @@ static int coroutine_fn vmdk_co_create(BlockdevCreateOptions *create_options,
     /* Validate options */
     if (!QEMU_IS_ALIGNED(opts->size, BDRV_SECTOR_SIZE)) {
         error_setg(errp, "Image size must be a multiple of 512 bytes");
-        ret = -EINVAL;
-        goto out;
+        return -EINVAL;
     }
 
-    ret = vmdk_co_do_create(opts->size,
-                            opts->subformat,
-                            opts->adapter_type,
-                            opts->backing_file,
-                            opts->hwversion,
-                            false,
-                            opts->zeroed_grain,
-                            vmdk_co_create_cb,
-                            opts, errp);
-    return ret;
-
-out:
-    return ret;
+    return vmdk_co_do_create(opts->size,
+                             opts->subformat,
+                             opts->adapter_type,
+                             opts->backing_file,
+                             opts->hwversion,
+                             false,
+                             opts->zeroed_grain,
+                             vmdk_co_create_cb,
+                             opts, errp);
 }
 
 static void vmdk_close(BlockDriverState *bs)
-- 
2.24.1



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

* [PATCH v1 23/59] block/vxhs.c: remove unneeded 'out' label in vxhs_iio_callback()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (21 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 22/59] block/vmdk.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 24/59] block/vhdx-log.c: remove unneeded labels Daniel Henrique Barboza
                   ` (38 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Kevin Wolf, Daniel Henrique Barboza, qemu-block

'out' is just a 'return' call.

CC: Kevin Wolf <kwolf@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/vxhs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/block/vxhs.c b/block/vxhs.c
index d79fc97df6..e3db367918 100644
--- a/block/vxhs.c
+++ b/block/vxhs.c
@@ -96,7 +96,7 @@ static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error)
             acb = ctx;
         } else {
             trace_vxhs_iio_callback(error);
-            goto out;
+            return;
         }
 
         if (error) {
@@ -122,8 +122,6 @@ static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error)
         }
         break;
     }
-out:
-    return;
 }
 
 static QemuOptsList runtime_opts = {
-- 
2.24.1



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

* [PATCH v1 24/59] block/vhdx-log.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (22 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 23/59] block/vxhs.c: remove unneeded 'out' label in vxhs_iio_callback() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 25/59] block/vhdx.c: remove unneeded 'exit' labels Daniel Henrique Barboza
                   ` (37 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Jeff Cody, Daniel Henrique Barboza, qemu-block

Removing some 'exit' labels used in some functions that are
unneeded, changing them for the adequate 'return' value
for the context.

CC: Jeff Cody <codyprime@gmail.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/vhdx-log.c | 86 ++++++++++++++++++------------------------------
 1 file changed, 32 insertions(+), 54 deletions(-)

diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 13a49c2a33..ba89f0adc6 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -64,8 +64,7 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLogEntries *log,
 
     /* peek is only supported on sector boundaries */
     if (log->read % VHDX_LOG_SECTOR_SIZE) {
-        ret = -EFAULT;
-        goto exit;
+        return -EFAULT;
     }
 
     read = log->read;
@@ -77,19 +76,17 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLogEntries *log,
     }
 
     if (read == log->write) {
-        ret = -EINVAL;
-        goto exit;
+        return -EINVAL;
     }
 
     offset = log->offset + read;
 
     ret = bdrv_pread(bs->file, offset, hdr, sizeof(VHDXLogEntryHeader));
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
     vhdx_log_entry_hdr_le_import(hdr);
 
-exit:
     return ret;
 }
 
@@ -179,7 +176,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs, VHDXLogEntries *log,
 
     ret = vhdx_user_visible_write(bs, s);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
 
     write = log->write;
@@ -196,7 +193,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs, VHDXLogEntries *log,
         ret = bdrv_pwrite(bs->file, offset, buffer_tmp,
                           VHDX_LOG_SECTOR_SIZE);
         if (ret < 0) {
-            goto exit;
+            return ret;
         }
         buffer_tmp += VHDX_LOG_SECTOR_SIZE;
 
@@ -205,7 +202,6 @@ static int vhdx_log_write_sectors(BlockDriverState *bs, VHDXLogEntries *log,
         num_sectors--;
     }
 
-exit:
     return ret;
 }
 
@@ -214,42 +210,37 @@ exit:
 static bool vhdx_log_hdr_is_valid(VHDXLogEntries *log, VHDXLogEntryHeader *hdr,
                                   BDRVVHDXState *s)
 {
-    int valid = false;
-
     if (hdr->signature != VHDX_LOG_SIGNATURE) {
-        goto exit;
+        return false;
     }
 
     /* if the individual entry length is larger than the whole log
      * buffer, that is obviously invalid */
     if (log->length < hdr->entry_length) {
-        goto exit;
+        return false;
     }
 
     /* length of entire entry must be in units of 4KB (log sector size) */
     if (hdr->entry_length % (VHDX_LOG_SECTOR_SIZE)) {
-        goto exit;
+        return false;
     }
 
     /* per spec, sequence # must be > 0 */
     if (hdr->sequence_number == 0) {
-        goto exit;
+        return false;
     }
 
     /* log entries are only valid if they match the file-wide log guid
      * found in the active header */
     if (!guid_eq(hdr->log_guid, s->headers[s->curr_header]->log_guid)) {
-        goto exit;
+        return false;
     }
 
     if (hdr->descriptor_count * sizeof(VHDXLogDescriptor) > hdr->entry_length) {
-        goto exit;
+        return false;
     }
 
-    valid = true;
-
-exit:
-    return valid;
+    return true;
 }
 
 /*
@@ -274,10 +265,10 @@ static bool vhdx_log_desc_is_valid(VHDXLogDescriptor *desc,
     bool ret = false;
 
     if (desc->sequence_number != hdr->sequence_number) {
-        goto exit;
+        return false;
     }
     if (desc->file_offset % VHDX_LOG_SECTOR_SIZE) {
-        goto exit;
+        return false;
     }
 
     if (desc->signature == VHDX_LOG_ZERO_SIGNATURE) {
@@ -290,7 +281,6 @@ static bool vhdx_log_desc_is_valid(VHDXLogDescriptor *desc,
             ret = true;
     }
 
-exit:
     return ret;
 }
 
@@ -347,20 +337,18 @@ static int vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s,
 
     ret = vhdx_log_peek_hdr(bs, log, &hdr);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
 
     if (vhdx_log_hdr_is_valid(log, &hdr, s) == false) {
-        ret = -EINVAL;
-        goto exit;
+        return -EINVAL;
     }
 
     desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);
     desc_entries = qemu_try_blockalign(bs->file->bs,
                                        desc_sectors * VHDX_LOG_SECTOR_SIZE);
     if (desc_entries == NULL) {
-        ret = -ENOMEM;
-        goto exit;
+        return -ENOMEM;
     }
 
     ret = vhdx_log_read_sectors(bs, log, &sectors_read, desc_entries,
@@ -390,11 +378,10 @@ static int vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s,
     }
 
     *buffer = desc_entries;
-    goto exit;
+    return ret;
 
 free_and_exit:
     qemu_vfree(desc_entries);
-exit:
     return ret;
 }
 
@@ -688,7 +675,7 @@ static int vhdx_log_search(BlockDriverState *bs, BDRVVHDXState *s,
         ret = vhdx_validate_log_entry(bs, s, &curr_log, curr_seq,
                                       &seq_valid, &hdr);
         if (ret < 0) {
-            goto exit;
+            return ret;
         }
 
         if (seq_valid) {
@@ -704,7 +691,7 @@ static int vhdx_log_search(BlockDriverState *bs, BDRVVHDXState *s,
                 ret = vhdx_validate_log_entry(bs, s, &curr_log, curr_seq,
                                               &seq_valid, &hdr);
                 if (ret < 0) {
-                    goto exit;
+                    return ret;
                 }
                 if (seq_valid == false) {
                     break;
@@ -735,8 +722,6 @@ static int vhdx_log_search(BlockDriverState *bs, BDRVVHDXState *s,
         s->log.sequence = candidate.hdr.sequence_number + 1;
     }
 
-
-exit:
     return ret;
 }
 
@@ -766,29 +751,26 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
 
     if (s->log.offset < VHDX_LOG_MIN_SIZE ||
         s->log.offset % VHDX_LOG_MIN_SIZE) {
-        ret = -EINVAL;
-        goto exit;
+        return -EINVAL;
     }
 
     /* per spec, only log version of 0 is supported */
     if (hdr->log_version != 0) {
-        ret = -EINVAL;
-        goto exit;
+        return -EINVAL;
     }
 
     /* If either the log guid, or log length is zero,
      * then a replay log is not present */
     if (guid_eq(hdr->log_guid, zero_guid)) {
-        goto exit;
+        return 0;
     }
 
     if (hdr->log_length == 0) {
-        goto exit;
+        return 0;
     }
 
     if (hdr->log_length % VHDX_LOG_MIN_SIZE) {
-        ret = -EINVAL;
-        goto exit;
+        return -EINVAL;
     }
 
 
@@ -797,13 +779,12 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
 
     ret = vhdx_log_search(bs, s, &logs);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
 
     if (logs.valid) {
         if (bs->read_only) {
             bdrv_refresh_filename(bs);
-            ret = -EPERM;
             error_setg(errp,
                        "VHDX image file '%s' opened read-only, but "
                        "contains a log that needs to be replayed",
@@ -811,18 +792,16 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
             error_append_hint(errp,  "To replay the log, run:\n"
                               "qemu-img check -r all '%s'\n",
                               bs->filename);
-            goto exit;
+            return -EPERM;
         }
         /* now flush the log */
         ret = vhdx_log_flush(bs, s, &logs);
         if (ret < 0) {
-            goto exit;
+            return ret;
         }
         *flushed = true;
     }
 
-
-exit:
     return ret;
 }
 
@@ -1048,29 +1027,28 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s,
      * on disk, before creating log entry */
     ret = bdrv_flush(bs);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
 
     ret = vhdx_log_write(bs, s, data, length, offset);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
     logs.log = s->log;
 
     /* Make sure log is stable on disk */
     ret = bdrv_flush(bs);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
 
     ret = vhdx_log_flush(bs, s, &logs);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
 
     s->log = logs.log;
 
-exit:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 25/59] block/vhdx.c: remove unneeded 'exit' labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (23 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 24/59] block/vhdx-log.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 26/59] block/replication.c: remove unneeded label in replication_co_writev Daniel Henrique Barboza
                   ` (36 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Jeff Cody, Daniel Henrique Barboza, qemu-block

'exit' label of vhdx_region_check() and vhdx_update_header()
can be replaced by 'return' statements.

CC: Jeff Cody <codyprime@gmail.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/vhdx.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/block/vhdx.c b/block/vhdx.c
index f02d2611be..7a1ea312ed 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -229,7 +229,6 @@ void vhdx_guid_generate(MSGUID *guid)
 /* Check for region overlaps inside the VHDX image */
 static int vhdx_region_check(BDRVVHDXState *s, uint64_t start, uint64_t length)
 {
-    int ret = 0;
     uint64_t end;
     VHDXRegionEntry *r;
 
@@ -239,13 +238,11 @@ static int vhdx_region_check(BDRVVHDXState *s, uint64_t start, uint64_t length)
             error_report("VHDX region %" PRIu64 "-%" PRIu64 " overlaps with "
                          "region %" PRIu64 "-%." PRIu64, start, end, r->start,
                          r->end);
-            ret = -EINVAL;
-            goto exit;
+            return -EINVAL;
         }
     }
 
-exit:
-    return ret;
+    return 0;
 }
 
 /* Register a region for future checks */
@@ -390,11 +387,10 @@ static int vhdx_update_header(BlockDriverState *bs, BDRVVHDXState *s,
 
     ret = vhdx_write_header(bs->file, inactive_header, header_offset, true);
     if (ret < 0) {
-        goto exit;
+        return ret;
     }
     s->curr_header = hdr_idx;
 
-exit:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 26/59] block/replication.c: remove unneeded label in replication_co_writev
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (24 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 25/59] block/vhdx.c: remove unneeded 'exit' labels Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 27/59] crypto/block-luks.c: remove unneeded label in qcrypto_block_luks_find_key Daniel Henrique Barboza
                   ` (35 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Wen Congyang, Xie Changlong, Daniel Henrique Barboza

The label 'out' in replication_co_writev() can be replaced by
'return ret'. The other label, 'out1', was renamed to 'out'
since the original 'out' label was removed.

CC: Wen Congyang <wencongyang2@huawei.com>
CC: Xie Changlong <xiechanglong.d@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 block/replication.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/block/replication.c b/block/replication.c
index 99532ce521..3d5eb64d41 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -258,7 +258,7 @@ static coroutine_fn int replication_co_writev(BlockDriverState *bs,
     assert(!flags);
     ret = replication_get_io_status(s);
     if (ret < 0) {
-        goto out;
+        return ret;
     }
 
     if (ret == 0) {
@@ -280,7 +280,7 @@ static coroutine_fn int replication_co_writev(BlockDriverState *bs,
                                       remaining_sectors * BDRV_SECTOR_SIZE,
                                       &count);
         if (ret < 0) {
-            goto out1;
+            goto out;
         }
 
         assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE));
@@ -292,7 +292,7 @@ static coroutine_fn int replication_co_writev(BlockDriverState *bs,
         ret = bdrv_co_pwritev(target, sector_num * BDRV_SECTOR_SIZE,
                               n * BDRV_SECTOR_SIZE, &hd_qiov, 0);
         if (ret < 0) {
-            goto out1;
+            goto out;
         }
 
         remaining_sectors -= n;
@@ -300,9 +300,8 @@ static coroutine_fn int replication_co_writev(BlockDriverState *bs,
         bytes_done += count;
     }
 
-out1:
-    qemu_iovec_destroy(&hd_qiov);
 out:
+    qemu_iovec_destroy(&hd_qiov);
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 27/59] crypto/block-luks.c: remove unneeded label in qcrypto_block_luks_find_key
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (25 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 26/59] block/replication.c: remove unneeded label in replication_co_writev Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 28/59] qga/commands-win32.c: remove 'out' label in get_pci_info Daniel Henrique Barboza
                   ` (34 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Kevin Wolf, Daniel Henrique Barboza, qemu-block, Max Reitz

'error' can be replaced by 'return -1' directly.

CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 crypto/block-luks.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index 4861db810c..9742d4bdd9 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -1057,7 +1057,7 @@ qcrypto_block_luks_find_key(QCryptoBlock *block,
                                          opaque,
                                          errp);
         if (rv < 0) {
-            goto error;
+            return -1;
         }
         if (rv == 1) {
             return 0;
@@ -1065,7 +1065,6 @@ qcrypto_block_luks_find_key(QCryptoBlock *block,
     }
 
     error_setg(errp, "Invalid password, cannot unlock any keyslot");
- error:
     return -1;
 }
 
-- 
2.24.1



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

* [PATCH v1 28/59] qga/commands-win32.c: remove 'out' label in get_pci_info
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (26 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 27/59] crypto/block-luks.c: remove unneeded label in qcrypto_block_luks_find_key Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start Daniel Henrique Barboza
                   ` (33 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Daniel Henrique Barboza

'out' can be replaced by 'return pci' instead.

CC: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 qga/commands-win32.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 2461fd19bf..c520a341df 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -513,7 +513,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
                                    DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
     if (dev_info == INVALID_HANDLE_VALUE) {
         error_setg_win32(errp, GetLastError(), "failed to get devices tree");
-        goto out;
+        return pci;
     }
 
     g_debug("enumerating devices");
@@ -584,7 +584,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
                 } else {
                     error_setg_win32(errp, GetLastError(),
                                      "failed to get device instance ID");
-                    goto out;
+                    return pci;
                 }
             }
 
@@ -598,14 +598,14 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
                 g_error("CM_Locate_DevInst failed with code %lx", cr);
                 error_setg_win32(errp, GetLastError(),
                                  "failed to get device instance");
-                goto out;
+                return pci;
             }
             cr = CM_Get_Parent(&parent_dev_inst, dev_inst, 0);
             if (cr != CR_SUCCESS) {
                 g_error("CM_Get_Parent failed with code %lx", cr);
                 error_setg_win32(errp, GetLastError(),
                                  "failed to get parent device instance");
-                goto out;
+                return pci;
             }
 
             cr = CM_Get_Device_ID_Size(&dev_id_size, parent_dev_inst, 0);
@@ -613,7 +613,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
                 g_error("CM_Get_Device_ID_Size failed with code %lx", cr);
                 error_setg_win32(errp, GetLastError(),
                                  "failed to get parent device ID length");
-                goto out;
+                return pci;
             }
 
             ++dev_id_size;
@@ -628,7 +628,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
                 g_error("CM_Get_Device_ID failed with code %lx", cr);
                 error_setg_win32(errp, GetLastError(),
                                  "failed to get parent device ID");
-                goto out;
+                return pci;
             }
         }
 
@@ -642,14 +642,14 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
         if (parent_dev_info == INVALID_HANDLE_VALUE) {
             error_setg_win32(errp, GetLastError(),
                              "failed to get parent device");
-            goto out;
+            return pci;
         }
 
         parent_dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
         if (!SetupDiEnumDeviceInfo(parent_dev_info, 0, &parent_dev_info_data)) {
             error_setg_win32(errp, GetLastError(),
                            "failed to get parent device data");
-            goto out;
+            return pci;
         }
 
         for (j = 0;
@@ -731,7 +731,6 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
 
 free_dev_info:
     SetupDiDestroyDeviceInfoList(dev_info);
-out:
     return pci;
 }
 
-- 
2.24.1



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

* [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (27 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 28/59] qga/commands-win32.c: remove 'out' label in get_pci_info Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-07  6:53   ` Philippe Mathieu-Daudé
  2020-01-07  8:18   ` Gonglei (Arei)
  2020-01-06 18:23 ` [PATCH v1 30/59] util/module.c: remove unneeded label in module_load_file() Daniel Henrique Barboza
                   ` (32 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Gonglei

'err' can be replaced by 'return r'.

CC: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 backends/cryptodev-vhost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c
index 8337c9a495..907ca21fa7 100644
--- a/backends/cryptodev-vhost.c
+++ b/backends/cryptodev-vhost.c
@@ -201,7 +201,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_queues)
     r = k->set_guest_notifiers(qbus->parent, total_queues, true);
     if (r < 0) {
         error_report("error binding guest notifier: %d", -r);
-        goto err;
+        return r;
     }
 
     for (i = 0; i < total_queues; i++) {
@@ -236,7 +236,7 @@ err_start:
     if (e < 0) {
         error_report("vhost guest notifier cleanup failed: %d", e);
     }
-err:
+
     return r;
 }
 
-- 
2.24.1



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

* [PATCH v1 30/59] util/module.c: remove unneeded label in module_load_file()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (28 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-07 11:26   ` Thomas Huth
  2020-01-06 18:23 ` [PATCH v1 31/59] util/aio-posix.c: remove unneeded 'out' label in aio_epoll Daniel Henrique Barboza
                   ` (31 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Paolo Bonzini, Daniel Henrique Barboza

'out' can be replaced by the apropriate return values set
in 'ret' for each case.

CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 util/module.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/util/module.c b/util/module.c
index e9fe3e5422..9b5453f878 100644
--- a/util/module.c
+++ b/util/module.c
@@ -111,12 +111,10 @@ static int module_load_file(const char *fname)
 
     if (len <= suf_len || strcmp(&fname[len - suf_len], dsosuf)) {
         /* wrong suffix */
-        ret = -EINVAL;
-        goto out;
+        return -EINVAL;
     }
     if (access(fname, F_OK)) {
-        ret = -ENOENT;
-        goto out;
+        return -ENOENT;
     }
 
     assert(QTAILQ_EMPTY(&dso_init_list));
@@ -125,8 +123,7 @@ static int module_load_file(const char *fname)
     if (!g_module) {
         fprintf(stderr, "Failed to open module: %s\n",
                 g_module_error());
-        ret = -EINVAL;
-        goto out;
+        return -EINVAL;
     }
     if (!g_module_symbol(g_module, DSO_STAMP_FUN_STR, (gpointer *)&sym)) {
         fprintf(stderr, "Failed to initialize module: %s\n",
@@ -151,7 +148,7 @@ static int module_load_file(const char *fname)
         QTAILQ_REMOVE(&dso_init_list, e, node);
         g_free(e);
     }
-out:
+
     return ret;
 }
 #endif
-- 
2.24.1



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

* [PATCH v1 31/59] util/aio-posix.c: remove unneeded 'out' label in aio_epoll
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (29 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 30/59] util/module.c: remove unneeded label in module_load_file() Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-07 13:34   ` Thomas Huth
  2020-01-06 18:23 ` [PATCH v1 32/59] qemu-img.c: remove 'out4' label in img_compare Daniel Henrique Barboza
                   ` (30 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Paolo Bonzini, Daniel Henrique Barboza

'out' can be replaced by 'return ret'.

CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 util/aio-posix.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/util/aio-posix.c b/util/aio-posix.c
index a4977f538e..7c4cfea8ce 100644
--- a/util/aio-posix.c
+++ b/util/aio-posix.c
@@ -121,7 +121,7 @@ static int aio_epoll(AioContext *ctx, GPollFD *pfds,
                          ARRAY_SIZE(events),
                          timeout);
         if (ret <= 0) {
-            goto out;
+            return ret;
         }
         for (i = 0; i < ret; i++) {
             int ev = events[i].events;
@@ -132,7 +132,6 @@ static int aio_epoll(AioContext *ctx, GPollFD *pfds,
                 (ev & EPOLLERR ? G_IO_ERR : 0);
         }
     }
-out:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 32/59] qemu-img.c: remove 'out4' label in img_compare
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (30 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 31/59] util/aio-posix.c: remove unneeded 'out' label in aio_epoll Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:23 ` [PATCH v1 33/59] ipmi/ipmi_bmc_sim.c: remove unneeded labels Daniel Henrique Barboza
                   ` (29 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Kevin Wolf, Daniel Henrique Barboza, qemu-block, Max Reitz

'out4' can be replaced by 'return 2'.

CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: qemu-block@nongnu.org
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 qemu-img.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 6233b8ca56..fc7b08e7ee 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1346,8 +1346,7 @@ static int img_compare(int argc, char **argv)
             opts = qemu_opts_parse_noisily(&qemu_object_opts,
                                            optarg, true);
             if (!opts) {
-                ret = 2;
-                goto out4;
+                return 2;
             }
         }   break;
         case OPTION_IMAGE_OPTS:
@@ -1371,8 +1370,7 @@ static int img_compare(int argc, char **argv)
     if (qemu_opts_foreach(&qemu_object_opts,
                           user_creatable_add_opts_foreach,
                           qemu_img_object_print_help, &error_fatal)) {
-        ret = 2;
-        goto out4;
+        return 2;
     }
 
     /* Initialize before goto out */
@@ -1559,7 +1557,6 @@ out2:
     blk_unref(blk1);
 out3:
     qemu_progress_end();
-out4:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 33/59] ipmi/ipmi_bmc_sim.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (31 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 32/59] qemu-img.c: remove 'out4' label in img_compare Daniel Henrique Barboza
@ 2020-01-06 18:23 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 34/59] ipmi/ipmi_bt.c: remove unneeded label in ipmi_bt_handle_event Daniel Henrique Barboza
                   ` (28 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Corey Minyard

Label 'out' from ipmi_bmc_gen_event() and gen_event() can
be replaced by 'return'.

CC: Corey Minyard <minyard@acm.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ipmi/ipmi_bmc_sim.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 6670cf039d..1e06fd1de9 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -461,14 +461,12 @@ void ipmi_bmc_gen_event(IPMIBmc *b, uint8_t *evt, bool log)
     }
 
     if (ibs->msg_flags & IPMI_BMC_MSG_FLAG_EVT_BUF_FULL) {
-        goto out;
+        return;
     }
 
     memcpy(ibs->evtbuf, evt, 16);
     ibs->msg_flags |= IPMI_BMC_MSG_FLAG_EVT_BUF_FULL;
     k->set_atn(s, 1, attn_irq_enabled(ibs));
- out:
-    return;
 }
 static void gen_event(IPMIBmcSim *ibs, unsigned int sens_num, uint8_t deassert,
                       uint8_t evd1, uint8_t evd2, uint8_t evd3)
@@ -978,7 +976,7 @@ static void get_msg(IPMIBmcSim *ibs,
 
     if (QTAILQ_EMPTY(&ibs->rcvbufs)) {
         rsp_buffer_set_error(rsp, 0x80); /* Queue empty */
-        goto out;
+        return;
     }
     rsp_buffer_push(rsp, 0); /* Channel 0 */
     msg = QTAILQ_FIRST(&ibs->rcvbufs);
@@ -993,9 +991,6 @@ static void get_msg(IPMIBmcSim *ibs,
         ibs->msg_flags &= ~IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
         k->set_atn(s, attn_set(ibs), attn_irq_enabled(ibs));
     }
-
-out:
-    return;
 }
 
 static unsigned char
-- 
2.24.1



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

* [PATCH v1 34/59] ipmi/ipmi_bt.c: remove unneeded label in ipmi_bt_handle_event
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (32 preceding siblings ...)
  2020-01-06 18:23 ` [PATCH v1 33/59] ipmi/ipmi_bmc_sim.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 35/59] ipmi_bmc_extern.c: remove unneeded label in ipmi_bmc_extern_handle_command Daniel Henrique Barboza
                   ` (27 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Corey Minyard

'out' can be replaced by 'return'.

CC: Corey Minyard <minyard@acm.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ipmi/ipmi_bt.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/hw/ipmi/ipmi_bt.c b/hw/ipmi/ipmi_bt.c
index 22f94fb98d..8173551d7d 100644
--- a/hw/ipmi/ipmi_bt.c
+++ b/hw/ipmi/ipmi_bt.c
@@ -98,14 +98,14 @@ static void ipmi_bt_handle_event(IPMIInterface *ii)
     IPMIBT *ib = iic->get_backend_data(ii);
 
     if (ib->inlen < 4) {
-        goto out;
+        return;
     }
     /* Note that overruns are handled by handle_command */
     if (ib->inmsg[0] != (ib->inlen - 1)) {
         /* Length mismatch, just ignore. */
         IPMI_BT_SET_BBUSY(ib->control_reg, 1);
         ib->inlen = 0;
-        goto out;
+        return;
     }
     if ((ib->inmsg[1] == (IPMI_NETFN_APP << 2)) &&
                         (ib->inmsg[3] == IPMI_CMD_GET_BT_INTF_CAP)) {
@@ -136,7 +136,7 @@ static void ipmi_bt_handle_event(IPMIInterface *ii)
             IPMI_BT_SET_B2H_IRQ(ib->mask_reg, 1);
             ipmi_bt_raise_irq(ib);
         }
-        goto out;
+        return;
     }
     ib->waiting_seq = ib->inmsg[2];
     ib->inmsg[2] = ib->inmsg[1];
@@ -145,8 +145,6 @@ static void ipmi_bt_handle_event(IPMIInterface *ii)
         bk->handle_command(ib->bmc, ib->inmsg + 2, ib->inlen - 2,
                            sizeof(ib->inmsg), ib->waiting_rsp);
     }
- out:
-    return;
 }
 
 static void ipmi_bt_handle_rsp(IPMIInterface *ii, uint8_t msg_id,
-- 
2.24.1



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

* [PATCH v1 35/59] ipmi_bmc_extern.c: remove unneeded label in ipmi_bmc_extern_handle_command
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (33 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 34/59] ipmi/ipmi_bt.c: remove unneeded label in ipmi_bt_handle_event Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 36/59] ipmi/ipmi_kcs.c: remove unneeded label in ipmi_kcs_handle_event Daniel Henrique Barboza
                   ` (26 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Corey Minyard

'out' label can be replaced by 'return'.

CC: Corey Minyard <minyard@acm.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ipmi/ipmi_bmc_extern.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index 87da9ff99c..16d9114725 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -217,7 +217,7 @@ static void ipmi_bmc_extern_handle_command(IPMIBmc *b,
         rsp[2] = err;
         ibe->waiting_rsp = false;
         k->handle_rsp(s, msg_id, rsp, 3);
-        goto out;
+        return;
     }
 
     addchar(ibe, msg_id);
@@ -232,9 +232,6 @@ static void ipmi_bmc_extern_handle_command(IPMIBmc *b,
 
     /* Start the transmit */
     continue_send(ibe);
-
- out:
-    return;
 }
 
 static void handle_hw_op(IPMIBmcExtern *ibe, unsigned char hw_op)
-- 
2.24.1



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

* [PATCH v1 36/59] ipmi/ipmi_kcs.c: remove unneeded label in ipmi_kcs_handle_event
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (34 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 35/59] ipmi_bmc_extern.c: remove unneeded label in ipmi_bmc_extern_handle_command Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels Daniel Henrique Barboza
                   ` (25 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Corey Minyard

'out_noibf' can be replaced by 'return'.

CC: Corey Minyard <minyard@acm.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ipmi/ipmi_kcs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c
index a77612946a..83009baddb 100644
--- a/hw/ipmi/ipmi_kcs.c
+++ b/hw/ipmi/ipmi_kcs.c
@@ -168,7 +168,7 @@ static void ipmi_kcs_handle_event(IPMIInterface *ii)
             ik->outpos = 0;
             bk->handle_command(ik->bmc, ik->inmsg, ik->inlen, sizeof(ik->inmsg),
                                ik->waiting_rsp);
-            goto out_noibf;
+            return;
         } else if (ik->cmd_reg == IPMI_KCS_WRITE_END_CMD) {
             ik->cmd_reg = -1;
             ik->write_end = 1;
@@ -197,8 +197,6 @@ static void ipmi_kcs_handle_event(IPMIInterface *ii)
     ik->cmd_reg = -1;
     ik->data_in_reg = -1;
     IPMI_KCS_SET_IBF(ik->status_reg, 0);
- out_noibf:
-    return;
 }
 
 static void ipmi_kcs_handle_rsp(IPMIInterface *ii, uint8_t msg_id,
-- 
2.24.1



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

* [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (35 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 36/59] ipmi/ipmi_kcs.c: remove unneeded label in ipmi_kcs_handle_event Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-07 13:36   ` Thomas Huth
  2020-01-08 12:46   ` Cornelia Huck
  2020-01-06 18:24 ` [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call() Daniel Henrique Barboza
                   ` (24 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Halil Pasic, Daniel Henrique Barboza,
	Christian Borntraeger, Cornelia Huck

'out' label from write_event_mask(), handle_sccb_read_events()
and write_event_data() can be replaced by 'return'.

CC: Cornelia Huck <cohuck@redhat.com>
CC: Halil Pasic <pasic@linux.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/s390x/event-facility.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 6afe278cad..f3b9661f32 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -182,11 +182,11 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb)
 {
     if (sccb->h.function_code != SCLP_FC_NORMAL_WRITE) {
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
-        goto out;
+        return;
     }
     if (be16_to_cpu(sccb->h.length) < 8) {
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
-        goto out;
+        return;
     }
     /* first do a sanity check of the write events */
     sccb->h.response_code = cpu_to_be16(write_event_length_check(sccb));
@@ -196,9 +196,6 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb)
         sccb->h.response_code =
                 cpu_to_be16(handle_sccb_write_events(ef, sccb));
     }
-
-out:
-    return;
 }
 
 static uint16_t handle_sccb_read_events(SCLPEventFacility *ef, SCCB *sccb,
@@ -262,7 +259,7 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
 
     if (be16_to_cpu(sccb->h.length) != SCCB_SIZE) {
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
-        goto out;
+        return;
     }
 
     sclp_cp_receive_mask = ef->receive_mask;
@@ -280,18 +277,15 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
             (sclp_active_selection_mask & ~sclp_cp_receive_mask)) {
             sccb->h.response_code =
                     cpu_to_be16(SCLP_RC_INVALID_SELECTION_MASK);
-            goto out;
+            return;
         }
         break;
     default:
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
-        goto out;
+        return;
     }
     sccb->h.response_code = cpu_to_be16(
             handle_sccb_read_events(ef, sccb, sclp_active_selection_mask));
-
-out:
-    return;
 }
 
 static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
@@ -303,7 +297,7 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
     if (!mask_length || (mask_length > SCLP_EVENT_MASK_LEN_MAX) ||
         ((mask_length != 4) && !ef->allow_all_mask_sizes)) {
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_MASK_LENGTH);
-        goto out;
+        return;
     }
 
     /*
@@ -328,9 +322,6 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
 
     sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_COMPLETION);
     ef->mask_length = mask_length;
-
-out:
-    return;
 }
 
 /* qemu object creation and initialization functions */
-- 
2.24.1



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

* [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (36 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-07 13:37   ` Thomas Huth
  2020-01-08 13:16   ` Cornelia Huck
  2020-01-06 18:24 ` [PATCH v1 39/59] usb/dev-mtp.c: remove unneeded label in write_retry() Daniel Henrique Barboza
                   ` (23 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Halil Pasic, Daniel Henrique Barboza,
	Christian Borntraeger, Cornelia Huck

'out' label can be replaced by 'return' with the appropriate
value. The 'r' integer, which is used solely to set the
return value for this label, can also be removed.

CC: Cornelia Huck <cohuck@redhat.com>
CC: Halil Pasic <pasic@linux.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/s390x/sclp.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index f57ce7b739..af0bfbc2ec 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -197,24 +197,20 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
 {
     SCLPDevice *sclp = get_sclp_device();
     SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
-    int r = 0;
     SCCB work_sccb;
 
     hwaddr sccb_len = sizeof(SCCB);
 
     /* first some basic checks on program checks */
     if (env->psw.mask & PSW_MASK_PSTATE) {
-        r = -PGM_PRIVILEGED;
-        goto out;
+        return -PGM_PRIVILEGED;
     }
     if (cpu_physical_memory_is_io(sccb)) {
-        r = -PGM_ADDRESSING;
-        goto out;
+        return -PGM_ADDRESSING;
     }
     if ((sccb & ~0x1fffUL) == 0 || (sccb & ~0x1fffUL) == env->psa
         || (sccb & ~0x7ffffff8UL) != 0) {
-        r = -PGM_SPECIFICATION;
-        goto out;
+        return -PGM_SPECIFICATION;
     }
 
     /*
@@ -226,8 +222,7 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
 
     /* Valid sccb sizes */
     if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader)) {
-        r = -PGM_SPECIFICATION;
-        goto out;
+        return -PGM_SPECIFICATION;
     }
 
     switch (code & SCLP_CMD_CODE_MASK) {
@@ -257,8 +252,7 @@ out_write:
 
     sclp_c->service_interrupt(sclp, sccb);
 
-out:
-    return r;
+    return 0;
 }
 
 static void service_interrupt(SCLPDevice *sclp, uint32_t sccb)
-- 
2.24.1



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

* [PATCH v1 39/59] usb/dev-mtp.c: remove unneeded label in write_retry()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (37 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 40/59] hsb/hcd-ehci.c: remove unneeded labels Daniel Henrique Barboza
                   ` (22 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Gerd Hoffmann

'done' can be replaced by 'return 0'. The 'ret' variable can
be removed since it's only set in qemu_write_full(), which
is now the returned value of the function.

write_retry() body also has an extra layer of identation. Let's
fix that to make it compliant with the other functions in the
file.

CC: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/usb/dev-mtp.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 7c07295519..818aa066c9 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1576,16 +1576,11 @@ static char *utf16_to_str(uint8_t len, uint8_t *str16)
 /* Wrapper around write, returns 0 on failure */
 static uint64_t write_retry(int fd, void *buf, uint64_t size, off_t offset)
 {
-        uint64_t ret = 0;
-
-        if (lseek(fd, offset, SEEK_SET) < 0) {
-            goto done;
-        }
-
-        ret = qemu_write_full(fd, buf, size);
+    if (lseek(fd, offset, SEEK_SET) < 0) {
+        return 0;
+    }
 
-done:
-        return ret;
+    return qemu_write_full(fd, buf, size);
 }
 
 static int usb_mtp_update_object(MTPObject *parent, char *name)
-- 
2.24.1



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

* [PATCH v1 40/59] hsb/hcd-ehci.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (38 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 39/59] usb/dev-mtp.c: remove unneeded label in write_retry() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-13 15:17   ` Markus Armbruster
  2020-01-06 18:24 ` [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() Daniel Henrique Barboza
                   ` (21 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Gerd Hoffmann

Label 'out' in ehci_state_fetchentry(), ehci_state_waitlisthead(),
ehci_state_fetchqh() and ehci_state_execute() can be replaced
by 'return' with the appropriate value.

CC: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/usb/hcd-ehci.c | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 56ab2f457f..d8103102d6 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1511,7 +1511,6 @@ static int ehci_state_waitlisthead(EHCIState *ehci,  int async)
 {
     EHCIqh qh;
     int i = 0;
-    int again = 0;
     uint32_t entry = ehci->asynclistaddr;
 
     /* set reclamation flag at start event (4.8.6) */
@@ -1536,8 +1535,7 @@ static int ehci_state_waitlisthead(EHCIState *ehci,  int async)
 
             ehci_set_fetch_addr(ehci, async, entry);
             ehci_set_state(ehci, async, EST_FETCHENTRY);
-            again = 1;
-            goto out;
+            return 1;
         }
 
         entry = qh.next;
@@ -1550,8 +1548,7 @@ static int ehci_state_waitlisthead(EHCIState *ehci,  int async)
 
     ehci_set_state(ehci, async, EST_ACTIVE);
 
-out:
-    return again;
+    return 0;
 }
 
 
@@ -1565,7 +1562,7 @@ static int ehci_state_fetchentry(EHCIState *ehci, int async)
 
     if (NLPTR_TBIT(entry)) {
         ehci_set_state(ehci, async, EST_ACTIVE);
-        goto out;
+        return 0;
     }
 
     /* section 4.8, only QH in async schedule */
@@ -1597,7 +1594,6 @@ static int ehci_state_fetchentry(EHCIState *ehci, int async)
         return -1;
     }
 
-out:
     return again;
 }
 
@@ -1617,14 +1613,12 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
     if (q->seen > 1) {
         /* we are going in circles -- stop processing */
         ehci_set_state(ehci, async, EST_ACTIVE);
-        q = NULL;
-        goto out;
+        return NULL;
     }
 
     if (get_dwords(ehci, NLPTR_GET(q->qhaddr),
                    (uint32_t *) &qh, sizeof(EHCIqh) >> 2) < 0) {
-        q = NULL;
-        goto out;
+        return NULL;
     }
     ehci_trace_qh(q, NLPTR_GET(q->qhaddr), &qh);
 
@@ -1658,8 +1652,7 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
             DPRINTF("FETCHQH:  QH 0x%08x. H-bit set, reclamation status reset"
                        " - done processing\n", q->qhaddr);
             ehci_set_state(ehci, async, EST_ACTIVE);
-            q = NULL;
-            goto out;
+            return NULL;
         }
     }
 
@@ -1688,7 +1681,6 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
         ehci_set_state(ehci, async, EST_ADVANCEQUEUE);
     }
 
-out:
     return q;
 }
 
@@ -1932,8 +1924,7 @@ static int ehci_state_execute(EHCIQueue *q)
     /* 4.10.3, bottom of page 82, go horizontal on transaction counter == 0 */
     if (!q->async && q->transact_ctr == 0) {
         ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
-        again = 1;
-        goto out;
+        return 1;
     }
 
     if (q->async) {
@@ -1942,7 +1933,7 @@ static int ehci_state_execute(EHCIQueue *q)
 
     again = ehci_execute(p, "process");
     if (again == -1) {
-        goto out;
+        return -1;
     }
     if (p->packet.status == USB_RET_ASYNC) {
         ehci_flush_qh(q);
@@ -1954,14 +1945,11 @@ static int ehci_state_execute(EHCIQueue *q)
         } else {
             again = 1;
         }
-        goto out;
+        return again;
     }
 
     ehci_set_state(q->ehci, q->async, EST_EXECUTING);
-    again = 1;
-
-out:
-    return again;
+    return 1;
 }
 
 static int ehci_state_executing(EHCIQueue *q)
-- 
2.24.1



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

* [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (39 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 40/59] hsb/hcd-ehci.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-08 13:00   ` Cornelia Huck
  2020-01-13 16:06   ` Thomas Huth
  2020-01-06 18:24 ` [PATCH v1 42/59] i386/intel_iommu.c: remove unneeded labels Daniel Henrique Barboza
                   ` (20 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza

'out' label can be replaced by 'return' with the apropriate
value that is set by 'r' right before the jump.

Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/intc/s390_flic_kvm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
index dddd33ea61..2e1e70c61d 100644
--- a/hw/intc/s390_flic_kvm.c
+++ b/hw/intc/s390_flic_kvm.c
@@ -439,17 +439,14 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
     count = qemu_get_be64(f);
     len = count * sizeof(struct kvm_s390_irq);
     if (count == FLIC_FAILED) {
-        r = -EINVAL;
-        goto out;
+        return -EINVAL;
     }
     if (count == 0) {
-        r = 0;
-        goto out;
+        return 0;
     }
     buf = g_try_malloc0(len);
     if (!buf) {
-        r = -ENOMEM;
-        goto out;
+        return -ENOMEM;
     }
 
     if (qemu_get_buffer(f, (uint8_t *) buf, len) != len) {
@@ -460,7 +457,6 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
 
 out_free:
     g_free(buf);
-out:
     return r;
 }
 
-- 
2.24.1



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

* [PATCH v1 42/59] i386/intel_iommu.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (40 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 43/59] i386/amd_iommu.c: remove unneeded label in amdvi_int_remap_msi() Daniel Henrique Barboza
                   ` (19 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Michael S . Tsirkin

'out' label in vtd_lookup_iotlb() and 'done' label in
vtd_process_device_iotlb_desc() can be replaced by
'return' with the apropriate value.

CC: Michael S. Tsirkin <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/i386/intel_iommu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 43c94b993b..e0dd987851 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -304,11 +304,10 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
                                 source_id, level);
         entry = g_hash_table_lookup(s->iotlb, &key);
         if (entry) {
-            goto out;
+            return entry;
         }
     }
 
-out:
     return entry;
 }
 
@@ -2380,12 +2379,12 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
 
     vtd_bus = vtd_find_as_from_bus_num(s, bus_num);
     if (!vtd_bus) {
-        goto done;
+        return true;
     }
 
     vtd_dev_as = vtd_bus->dev_as[devfn];
     if (!vtd_dev_as) {
-        goto done;
+        return true;
     }
 
     /* According to ATS spec table 2.4:
@@ -2410,7 +2409,6 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
     entry.translated_addr = 0;
     memory_region_notify_iommu(&vtd_dev_as->iommu, 0, entry);
 
-done:
     return true;
 }
 
-- 
2.24.1



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

* [PATCH v1 43/59] i386/amd_iommu.c: remove unneeded label in amdvi_int_remap_msi()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (41 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 42/59] i386/intel_iommu.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common() Daniel Henrique Barboza
                   ` (18 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Michael S . Tsirkin

'remap_fail' label can be replaced by 'return' with the
adequate error value.

CC: Michael S. Tsirkin <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/i386/amd_iommu.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index b1175e52c7..711e1f6e40 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1268,7 +1268,7 @@ static int amdvi_int_remap_msi(AMDVIState *iommu,
         trace_amdvi_ir_delivery_mode("fixed/arbitrated");
         ret = __amdvi_int_remap_msi(iommu, origin, translated, dte, &irq, sid);
         if (ret < 0) {
-            goto remap_fail;
+            return ret;
         } else {
             /* Translate IRQ to MSI messages */
             x86_iommu_irq_to_msi_message(&irq, translated);
@@ -1298,7 +1298,7 @@ static int amdvi_int_remap_msi(AMDVIState *iommu,
     }
 
     if (ret < 0) {
-        goto remap_fail;
+        return ret;
     }
 
     /*
@@ -1309,25 +1309,20 @@ static int amdvi_int_remap_msi(AMDVIState *iommu,
     dest_mode = (origin->address >> MSI_ADDR_DEST_MODE_SHIFT) & 1;
     if (dest_mode) {
         trace_amdvi_ir_err("invalid dest_mode");
-        ret = -AMDVI_IR_ERR;
-        goto remap_fail;
+        return -AMDVI_IR_ERR;
     }
 
     if (pass) {
         memcpy(translated, origin, sizeof(*origin));
     } else {
         trace_amdvi_ir_err("passthrough is not enabled");
-        ret = -AMDVI_IR_ERR;
-        goto remap_fail;
+        return -AMDVI_IR_ERR;
     }
 
 out:
     trace_amdvi_ir_remap_msi(origin->address, origin->data,
                              translated->address, translated->data);
     return 0;
-
-remap_fail:
-    return ret;
 }
 
 static int amdvi_int_remap(X86IOMMUState *iommu,
-- 
2.24.1



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

* [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (42 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 43/59] i386/amd_iommu.c: remove unneeded label in amdvi_int_remap_msi() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-07 12:04   ` Christian Schoenebeck
  2020-01-07 13:53   ` Greg Kurz
  2020-01-06 18:24 ` [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels Daniel Henrique Barboza
                   ` (17 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Greg Kurz

'err_out' can be replaced by 'return ret' in the error conditions
the jump was being made.

CC: Greg Kurz <groug@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/9pfs/9p-local.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index ca641390fb..f9bdd2ad7c 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1094,12 +1094,12 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
 
             fd = openat_dir(dirfd, name);
             if (fd == -1) {
-                goto err_out;
+                return ret;
             }
             ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
             close_preserve_errno(fd);
             if (ret < 0 && errno != ENOENT) {
-                goto err_out;
+                return ret;
             }
         }
         map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
@@ -1107,16 +1107,14 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
             ret = unlinkat(map_dirfd, name, 0);
             close_preserve_errno(map_dirfd);
             if (ret < 0 && errno != ENOENT) {
-                goto err_out;
+                return ret;
             }
         } else if (errno != ENOENT) {
-            goto err_out;
+            return ret;
         }
     }
 
-    ret = unlinkat(dirfd, name, flags);
-err_out:
-    return ret;
+    return unlinkat(dirfd, name, flags);
 }
 
 static int local_remove(FsContext *ctx, const char *path)
-- 
2.24.1



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

* [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (43 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-07 12:14   ` Christian Schoenebeck
  2020-01-06 18:24 ` [PATCH v1 46/59] alpha/typhoon.c: remove unneeded label in typhoon_translate_iommu() Daniel Henrique Barboza
                   ` (16 subsequent siblings)
  61 siblings, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Greg Kurz

'out' label in v9fs_xattr_write() and 'out_nofid' label in
v9fs_complete_rename() can be replaced by appropriate return
calls.

CC: Greg Kurz <groug@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/9pfs/9p.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 520177f40c..be2beba4cd 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -2464,8 +2464,7 @@ static int v9fs_xattr_write(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
 
 
     if (fidp->fs.xattr.len < off) {
-        err = -ENOSPC;
-        goto out;
+        return -ENOSPC;
     }
     write_count = fidp->fs.xattr.len - off;
     if (write_count > count) {
@@ -2491,7 +2490,7 @@ static int v9fs_xattr_write(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
         off += to_copy;
         write_count -= to_copy;
     }
-out:
+
     return err;
 }
 
@@ -3056,8 +3055,7 @@ static int coroutine_fn v9fs_complete_rename(V9fsPDU *pdu, V9fsFidState *fidp,
     if (newdirfid != -1) {
         dirfidp = get_fid(pdu, newdirfid);
         if (dirfidp == NULL) {
-            err = -ENOENT;
-            goto out_nofid;
+            return -ENOENT;
         }
         if (fidp->fid_type != P9_FID_NONE) {
             err = -EINVAL;
@@ -3100,7 +3098,6 @@ out:
         put_fid(pdu, dirfidp);
     }
     v9fs_path_free(&new_path);
-out_nofid:
     return err;
 }
 
-- 
2.24.1



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

* [PATCH v1 46/59] alpha/typhoon.c: remove unneeded label in typhoon_translate_iommu()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (44 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 47/59] pvrdma_main.c: remove unneeded labels Daniel Henrique Barboza
                   ` (15 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Richard Henderson

Label 'success' can be replaced by 'return ret'.

As a bonus, existing trailing whitespaces were automatically
deleted by the text editor while making this patch.

CC: Richard Henderson <rth@twiddle.net>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/alpha/typhoon.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
index 179e1f7658..af992883c7 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -34,7 +34,7 @@ typedef struct TyphoonWindow {
     uint64_t wsm;
     uint64_t tba;
 } TyphoonWindow;
- 
+
 typedef struct TyphoonPchip {
     MemoryRegion region;
     MemoryRegion reg_iack;
@@ -190,7 +190,7 @@ static MemTxResult cchip_read(void *opaque, hwaddr addr,
     case 0x0780:
         /* PWR: Power Management Control.   */
         break;
-    
+
     case 0x0c00: /* CMONCTLA */
     case 0x0c40: /* CMONCTLB */
     case 0x0c80: /* CMONCNT01 */
@@ -442,7 +442,7 @@ static MemTxResult cchip_write(void *opaque, hwaddr addr,
     case 0x0780:
         /* PWR: Power Management Control.   */
         break;
-    
+
     case 0x0c00: /* CMONCTLA */
     case 0x0c40: /* CMONCTLB */
     case 0x0c80: /* CMONCNT01 */
@@ -694,14 +694,14 @@ static IOMMUTLBEntry typhoon_translate_iommu(IOMMUMemoryRegion *iommu,
         /* Check the first three windows.  */
         for (i = 0; i < 3; ++i) {
             if (window_translate(&pchip->win[i], addr, &ret)) {
-                goto success;
+                return ret;
             }
         }
 
         /* Check the fourth window for DAC disable.  */
         if ((pchip->win[3].wba & 0x80000000000ull) == 0
             && window_translate(&pchip->win[3], addr, &ret)) {
-            goto success;
+            return ret;
         }
     } else {
         /* Double-address cycle.  */
@@ -711,7 +711,7 @@ static IOMMUTLBEntry typhoon_translate_iommu(IOMMUMemoryRegion *iommu,
             if (pchip->ctl & 0x40) {
                 /* See 10.1.4.4; in particular <39:35> is ignored.  */
                 make_iommu_tlbe(0, 0x007ffffffffull, &ret);
-                goto success;
+                return ret;
             }
         }
 
@@ -723,16 +723,14 @@ static IOMMUTLBEntry typhoon_translate_iommu(IOMMUMemoryRegion *iommu,
                 pte_addr  = pchip->win[3].tba & 0x7ffc00000ull;
                 pte_addr |= (addr & 0xffffe000u) >> 10;
                 if (pte_translate(pte_addr, &ret)) {
-                        goto success;
+                    return ret;
                 }
             }
         }
     }
 
  failure:
-    ret = (IOMMUTLBEntry) { .perm = IOMMU_NONE };
- success:
-    return ret;
+    return (IOMMUTLBEntry) { .perm = IOMMU_NONE };
 }
 
 static AddressSpace *typhoon_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn)
-- 
2.24.1



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

* [PATCH v1 47/59] pvrdma_main.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (45 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 46/59] alpha/typhoon.c: remove unneeded label in typhoon_translate_iommu() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 48/59] pvrdma_dev_ring.c: remove unneeded label in pvrdma_ring_init() Daniel Henrique Barboza
                   ` (14 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Yuval Shaia

Label 'out' from init_dev_ring() and load_dsr() can be
replaced by 'return' with the adequate value.

CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/rdma/vmw/pvrdma_main.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 6f0fc405c7..fcaf829e30 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -94,8 +94,7 @@ static int init_dev_ring(PvrdmaRing *ring, struct pvrdma_ring **ring_state,
     dir = rdma_pci_dma_map(pci_dev, dir_addr, TARGET_PAGE_SIZE);
     if (!dir) {
         rdma_error_report("Failed to map to page directory (ring %s)", name);
-        rc = -ENOMEM;
-        goto out;
+        return -ENOMEM;
     }
     tbl = rdma_pci_dma_map(pci_dev, dir[0], TARGET_PAGE_SIZE);
     if (!tbl) {
@@ -134,7 +133,6 @@ out_free_tbl:
 out_free_dir:
     rdma_pci_dma_unmap(pci_dev, dir, TARGET_PAGE_SIZE);
 
-out:
     return rc;
 }
 
@@ -177,8 +175,7 @@ static int load_dsr(PVRDMADev *dev)
                               sizeof(struct pvrdma_device_shared_region));
     if (!dev->dsr_info.dsr) {
         rdma_error_report("Failed to map to DSR");
-        rc = -ENOMEM;
-        goto out;
+        return -ENOMEM;
     }
 
     /* Shortcuts */
@@ -221,7 +218,7 @@ static int load_dsr(PVRDMADev *dev)
         goto out_free_rsp;
     }
 
-    goto out;
+    return rc;
 
 out_free_rsp:
     rdma_pci_dma_unmap(pci_dev, dsr_info->rsp, sizeof(union pvrdma_cmd_resp));
@@ -234,7 +231,6 @@ out_free_dsr:
                        sizeof(struct pvrdma_device_shared_region));
     dsr_info->dsr = NULL;
 
-out:
     return rc;
 }
 
-- 
2.24.1



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

* [PATCH v1 48/59] pvrdma_dev_ring.c: remove unneeded label in pvrdma_ring_init()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (46 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 47/59] pvrdma_main.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 49/59] rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd() Daniel Henrique Barboza
                   ` (13 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Yuval Shaia

'out' label can be replaced by 'return' with the right return
value. Since the 'rc' var was being used just to set -ENOMEM
in a single error condition, get rid of the var and set
the return value directly in the 'return' call.

CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/rdma/vmw/pvrdma_dev_ring.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma_dev_ring.c b/hw/rdma/vmw/pvrdma_dev_ring.c
index d7bc7f5ccc..c2ecce3b41 100644
--- a/hw/rdma/vmw/pvrdma_dev_ring.c
+++ b/hw/rdma/vmw/pvrdma_dev_ring.c
@@ -28,7 +28,6 @@ int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev,
                      size_t elem_sz, dma_addr_t *tbl, uint32_t npages)
 {
     int i;
-    int rc = 0;
 
     strncpy(ring->name, name, MAX_RING_NAME_SZ);
     ring->name[MAX_RING_NAME_SZ - 1] = 0;
@@ -51,14 +50,13 @@ int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev,
 
         ring->pages[i] = rdma_pci_dma_map(dev, tbl[i], TARGET_PAGE_SIZE);
         if (!ring->pages[i]) {
-            rc = -ENOMEM;
             rdma_error_report("Failed to map to page %d in ring %s", i, name);
             goto out_free;
         }
         memset(ring->pages[i], 0, TARGET_PAGE_SIZE);
     }
 
-    goto out;
+    return 0;
 
 out_free:
     while (i--) {
@@ -66,8 +64,7 @@ out_free:
     }
     g_free(ring->pages);
 
-out:
-    return rc;
+    return -ENOMEM;
 }
 
 void *pvrdma_ring_next_elem_read(PvrdmaRing *ring)
-- 
2.24.1



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

* [PATCH v1 49/59] rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (47 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 48/59] pvrdma_dev_ring.c: remove unneeded label in pvrdma_ring_init() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 50/59] rdma/rdma_backend.c: remove unneeded label in rdma_backend_init() Daniel Henrique Barboza
                   ` (12 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Yuval Shaia

'out' label can be replaced by 'return ret'. Since 'ret' will
be set to -ENOMEM in 'goto' time, we can replace it to
'return -ENOMEM'.

After this change, the 'ret' var is used to store the
result of rdma_backend_create_pd(), see if it's not zero,
then 'ret' is set to -EIO before the jump to out_tbl_dealloc.
-EIO is the only error being thrown by out_tbl_dealloc too.
This means we can go a step further in the code simplification
by also removing the 'ret' variable and making out_tbl_dealloc
return -EIO directly.

CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/rdma/rdma_rm.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c
index 1524dfaeaa..f049fda38a 100644
--- a/hw/rdma/rdma_rm.c
+++ b/hw/rdma/rdma_rm.c
@@ -161,16 +161,13 @@ int rdma_rm_alloc_pd(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
                      uint32_t *pd_handle, uint32_t ctx_handle)
 {
     RdmaRmPD *pd;
-    int ret = -ENOMEM;
 
     pd = rdma_res_tbl_alloc(&dev_res->pd_tbl, pd_handle);
     if (!pd) {
-        goto out;
+        return -ENOMEM;
     }
 
-    ret = rdma_backend_create_pd(backend_dev, &pd->backend_pd);
-    if (ret) {
-        ret = -EIO;
+    if (rdma_backend_create_pd(backend_dev, &pd->backend_pd)) {
         goto out_tbl_dealloc;
     }
 
@@ -180,9 +177,7 @@ int rdma_rm_alloc_pd(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
 
 out_tbl_dealloc:
     rdma_res_tbl_dealloc(&dev_res->pd_tbl, *pd_handle);
-
-out:
-    return ret;
+    return -EIO;
 }
 
 RdmaRmPD *rdma_rm_get_pd(RdmaDeviceResources *dev_res, uint32_t pd_handle)
-- 
2.24.1



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

* [PATCH v1 50/59] rdma/rdma_backend.c: remove unneeded label in rdma_backend_init()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (48 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 49/59] rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 51/59] virtio/vhost.c: remove unneeded labels Daniel Henrique Barboza
                   ` (11 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Yuval Shaia

'out' label can be replaced by 'return -EIO' in the single
goto jump.

CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/rdma/rdma_backend.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index c346407cd3..20c4c9fc3a 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -1335,8 +1335,7 @@ int rdma_backend_init(RdmaBackendDev *backend_dev, PCIDevice *pdev,
     if (!backend_dev->context) {
         rdma_error_report("Failed to open IB device %s",
                           ibv_get_device_name(backend_dev->ib_dev));
-        ret = -EIO;
-        goto out;
+        return -EIO;
     }
 
     backend_dev->channel = ibv_create_comp_channel(backend_dev->context);
@@ -1377,7 +1376,6 @@ out_close_device:
 out_free_dev_list:
     ibv_free_device_list(dev_list);
 
-out:
     return ret;
 }
 
-- 
2.24.1



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

* [PATCH v1 51/59] virtio/vhost.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (49 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 50/59] rdma/rdma_backend.c: remove unneeded label in rdma_backend_init() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 52/59] net/vhost_net.c: " Daniel Henrique Barboza
                   ` (10 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Michael S . Tsirkin

The label 'err_features' in vhost_dev_set_log(), 'out' in
vhost_device_iotlb_miss() and 'fail' in vhost_dev_enable_notifiers()
can be replaced by 'return' with the appropriate value.

CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/virtio/vhost.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 4da0d5a6c5..7b36839221 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -774,7 +774,7 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log)
     int r, i, idx;
     r = vhost_dev_set_features(dev, enable_log);
     if (r < 0) {
-        goto err_features;
+        return r;
     }
     for (i = 0; i < dev->nvqs; ++i) {
         idx = dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i);
@@ -792,7 +792,6 @@ err_vq:
                                  dev->log_enabled);
     }
     vhost_dev_set_features(dev, dev->log_enabled);
-err_features:
     return r;
 }
 
@@ -938,7 +937,7 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write)
             trace_vhost_iotlb_miss(dev, 3);
             error_report("Fail to lookup the translated address "
                          "%"PRIx64, iotlb.translated_addr);
-            goto out;
+            return ret;
         }
 
         len = MIN(iotlb.addr_mask + 1, len);
@@ -949,13 +948,12 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write)
         if (ret) {
             trace_vhost_iotlb_miss(dev, 4);
             error_report("Fail to update device iotlb");
-            goto out;
+            return ret;
         }
     }
 
     trace_vhost_iotlb_miss(dev, 2);
 
-out:
     return ret;
 }
 
@@ -1356,7 +1354,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
     r = virtio_device_grab_ioeventfd(vdev);
     if (r < 0) {
         error_report("binding does not support host notifiers");
-        goto fail;
+        return r;
     }
 
     for (i = 0; i < hdev->nvqs; ++i) {
@@ -1380,7 +1378,6 @@ fail_vq:
         virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i);
     }
     virtio_device_release_ioeventfd(vdev);
-fail:
     return r;
 }
 
-- 
2.24.1



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

* [PATCH v1 52/59] net/vhost_net.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (50 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 51/59] virtio/vhost.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 53/59] net/net_tx_pkt.c: remove unneeded label in net_tx_pkt_get_gso_type() Daniel Henrique Barboza
                   ` (9 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Michael S . Tsirkin

Label 'fail_notifiers' in vhost_net_start_one() and
'err' in vhost_net_start() can be replaced by 'return r'.

CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/net/vhost_net.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6b82803fa7..272519f970 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -230,7 +230,7 @@ static int vhost_net_start_one(struct vhost_net *net,
 
     r = vhost_dev_enable_notifiers(&net->dev, dev);
     if (r < 0) {
-        goto fail_notifiers;
+        return r;
     }
 
     r = vhost_dev_start(&net->dev, dev);
@@ -278,7 +278,6 @@ fail:
     vhost_dev_stop(&net->dev, dev);
 fail_start:
     vhost_dev_disable_notifiers(&net->dev, dev);
-fail_notifiers:
     return r;
 }
 
@@ -331,7 +330,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     r = k->set_guest_notifiers(qbus->parent, total_queues * 2, true);
     if (r < 0) {
         error_report("Error binding guest notifier: %d", -r);
-        goto err;
+        return r;
     }
 
     for (i = 0; i < total_queues; i++) {
@@ -362,7 +361,7 @@ err_start:
         fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", e);
         fflush(stderr);
     }
-err:
+
     return r;
 }
 
-- 
2.24.1



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

* [PATCH v1 53/59] net/net_tx_pkt.c: remove unneeded label in net_tx_pkt_get_gso_type()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (51 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 52/59] net/vhost_net.c: " Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 54/59] ivshmem-server/main.c: remove unneeded label in main() Daniel Henrique Barboza
                   ` (8 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza, Dmitry Fleytman

'func_exit' can be replaced by 'return' with the appropriate
return value. 'rc' also becomes unnecessary after this change,
thus let's remove it as well.

CC: Dmitry Fleytman <dmitry.fleytman@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/net/net_tx_pkt.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c
index 162f802dd7..3cd6aa1d0e 100644
--- a/hw/net/net_tx_pkt.c
+++ b/hw/net/net_tx_pkt.c
@@ -287,21 +287,18 @@ struct virtio_net_hdr *net_tx_pkt_get_vhdr(struct NetTxPkt *pkt)
 static uint8_t net_tx_pkt_get_gso_type(struct NetTxPkt *pkt,
                                           bool tso_enable)
 {
-    uint8_t rc = VIRTIO_NET_HDR_GSO_NONE;
     uint16_t l3_proto;
 
     l3_proto = eth_get_l3_proto(&pkt->vec[NET_TX_PKT_L2HDR_FRAG], 1,
         pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len);
 
     if (!tso_enable) {
-        goto func_exit;
+        return VIRTIO_NET_HDR_GSO_NONE;
     }
 
-    rc = eth_get_gso_type(l3_proto, pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
-                          pkt->l4proto);
-
-func_exit:
-    return rc;
+    return eth_get_gso_type(l3_proto,
+                            pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
+                            pkt->l4proto);
 }
 
 void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable,
-- 
2.24.1



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

* [PATCH v1 54/59] ivshmem-server/main.c: remove unneeded label in main()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (52 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 53/59] net/net_tx_pkt.c: remove unneeded label in net_tx_pkt_get_gso_type() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 55/59] linux-user/flatload.c: remove unused 'out' label Daniel Henrique Barboza
                   ` (7 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Daniel Henrique Barboza

'err' can be replaced by 'return 1'.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 contrib/ivshmem-server/main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c
index e4cd35f74c..b491e8237f 100644
--- a/contrib/ivshmem-server/main.c
+++ b/contrib/ivshmem-server/main.c
@@ -217,7 +217,7 @@ main(int argc, char *argv[])
     if (sigemptyset(&sa.sa_mask) == -1 ||
         sigaction(SIGPIPE, &sa, 0) == -1) {
         perror("failed to ignore SIGPIPE; sigaction");
-        goto err;
+        return 1;
     }
 
     sa_quit.sa_handler = ivshmem_server_quit_cb;
@@ -226,7 +226,7 @@ main(int argc, char *argv[])
         sigaction(SIGTERM, &sa_quit, 0) == -1 ||
         sigaction(SIGINT, &sa_quit, 0) == -1) {
         perror("failed to add signal handler; sigaction");
-        goto err;
+        return 1;
     }
 
     /* init the ivshms structure */
@@ -234,13 +234,13 @@ main(int argc, char *argv[])
                             args.shm_path, args.use_shm_open,
                             args.shm_size, args.n_vectors, args.verbose) < 0) {
         fprintf(stderr, "cannot init server\n");
-        goto err;
+        return 1;
     }
 
     /* start the ivshmem server (open shm & unix socket) */
     if (ivshmem_server_start(&server) < 0) {
         fprintf(stderr, "cannot bind\n");
-        goto err;
+        return 1;
     }
 
     /* daemonize if asked to */
@@ -269,6 +269,5 @@ main(int argc, char *argv[])
 
 err_close:
     ivshmem_server_close(&server);
-err:
     return ret;
 }
-- 
2.24.1



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

* [PATCH v1 55/59] linux-user/flatload.c: remove unused 'out' label
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (53 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 54/59] ivshmem-server/main.c: remove unneeded label in main() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 56/59] linux-user/signal.c: remove unneeded label in do_sigaltstack() Daniel Henrique Barboza
                   ` (6 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Riku Voipio, Daniel Henrique Barboza, Laurent Vivier

'out' label in out_free_buf() is not used at all.

CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 linux-user/flatload.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 0122ab3afe..3945c40ee1 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -247,7 +247,6 @@ out_free_buf:
 	kfree(buf);
 out_free:
 	kfree(strm.workspace);
-out:
 	return retval;
 }
 
-- 
2.24.1



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

* [PATCH v1 56/59] linux-user/signal.c: remove unneeded label in do_sigaltstack()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (54 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 55/59] linux-user/flatload.c: remove unused 'out' label Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style Daniel Henrique Barboza
                   ` (5 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Riku Voipio, Daniel Henrique Barboza, Laurent Vivier

'out' can be replaced by 'return ret'. Since 'ret' is used
just to set the return value, drop the 'ret' variable and
use 'return' with the appropriate value instead.

CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 linux-user/signal.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 5ca6d62b15..5efb1b79d9 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -708,7 +708,6 @@ static void host_signal_handler(int host_signum, siginfo_t *info,
 /* compare linux/kernel/signal.c:do_sigaltstack() */
 abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp)
 {
-    int ret;
     struct target_sigaltstack oss;
     TaskState *ts = (TaskState *)thread_cpu->opaque;
 
@@ -734,32 +733,28 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp)
         }
 #endif
 
-        ret = -TARGET_EFAULT;
         if (!lock_user_struct(VERIFY_READ, uss, uss_addr, 1)) {
-            goto out;
+            return -TARGET_EFAULT;
         }
         __get_user(ss.ss_sp, &uss->ss_sp);
         __get_user(ss.ss_size, &uss->ss_size);
         __get_user(ss.ss_flags, &uss->ss_flags);
         unlock_user_struct(uss, uss_addr, 0);
 
-        ret = -TARGET_EPERM;
         if (on_sig_stack(sp))
-            goto out;
+            return -TARGET_EPERM;
 
-        ret = -TARGET_EINVAL;
         if (ss.ss_flags != TARGET_SS_DISABLE
             && ss.ss_flags != TARGET_SS_ONSTACK
             && ss.ss_flags != 0)
-            goto out;
+            return -TARGET_EINVAL;
 
         if (ss.ss_flags == TARGET_SS_DISABLE) {
             ss.ss_size = 0;
             ss.ss_sp = 0;
         } else {
-            ret = -TARGET_ENOMEM;
             if (ss.ss_size < minstacksize) {
-                goto out;
+                return -TARGET_ENOMEM;
             }
         }
 
@@ -768,14 +763,11 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp)
     }
 
     if (uoss_addr) {
-        ret = -TARGET_EFAULT;
         if (copy_to_user(uoss_addr, &oss, sizeof(oss)))
-            goto out;
+            return -TARGET_EFAULT;
     }
 
-    ret = 0;
-out:
-    return ret;
+    return 0;
 }
 
 /* do_sigaction() return target values and host errnos */
-- 
2.24.1



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

* [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (55 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 56/59] linux-user/signal.c: remove unneeded label in do_sigaltstack() Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-07  6:57   ` Philippe Mathieu-Daudé
  2020-01-07 10:37   ` Peter Maydell
  2020-01-06 18:24 ` [PATCH v1 58/59] linux-user/syscall.c: remove unneeded labels Daniel Henrique Barboza
                   ` (4 subsequent siblings)
  61 siblings, 2 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Riku Voipio, Daniel Henrique Barboza, Laurent Vivier

There are trailing whitespaces in this file that, if removed
by a text editor that refuses to let the traiing whitespace
alone, which happens to be the editor I am using, will cause
checkpatch.pl to warn about styling problems in the resulting
patch. This happens because the trailing whitespace lines
are using a deprecated style.

To keep the intended change I wanted to do (remove unneeded
labels in do_ioctl_blkpg() and do_sendrecvmsg_locked())
trivial, this patch is another trivial change to fix the
trailing whitespaces and the code style errors that
checkpatch.pl warns about. Doing this change beforehand will
keep the next patch focused just on the label removal changes.

CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 linux-user/syscall.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 171c0caef3..49c6151c2d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1062,7 +1062,7 @@ static inline rlim_t target_to_host_rlim(abi_ulong target_rlim)
 {
     abi_ulong target_rlim_swap;
     rlim_t result;
-    
+
     target_rlim_swap = tswapal(target_rlim);
     if (target_rlim_swap == TARGET_RLIM_INFINITY)
         return RLIM_INFINITY;
@@ -1070,7 +1070,7 @@ static inline rlim_t target_to_host_rlim(abi_ulong target_rlim)
     result = target_rlim_swap;
     if (target_rlim_swap != (rlim_t)result)
         return RLIM_INFINITY;
-    
+
     return result;
 }
 
@@ -1078,13 +1078,13 @@ static inline abi_ulong host_to_target_rlim(rlim_t rlim)
 {
     abi_ulong target_rlim_swap;
     abi_ulong result;
-    
+
     if (rlim == RLIM_INFINITY || rlim != (abi_long)rlim)
         target_rlim_swap = TARGET_RLIM_INFINITY;
     else
         target_rlim_swap = rlim;
     result = tswapal(target_rlim_swap);
-    
+
     return result;
 }
 
@@ -1526,10 +1526,11 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
     abi_ulong target_cmsg_addr;
     struct target_cmsghdr *target_cmsg, *target_cmsg_start;
     socklen_t space = 0;
-    
+
     msg_controllen = tswapal(target_msgh->msg_controllen);
-    if (msg_controllen < sizeof (struct target_cmsghdr)) 
+    if (msg_controllen < sizeof(struct target_cmsghdr)) {
         goto the_end;
+    }
     target_cmsg_addr = tswapal(target_msgh->msg_control);
     target_cmsg = lock_user(VERIFY_READ, target_cmsg_addr, msg_controllen, 1);
     target_cmsg_start = target_cmsg;
@@ -1610,8 +1611,9 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
     socklen_t space = 0;
 
     msg_controllen = tswapal(target_msgh->msg_controllen);
-    if (msg_controllen < sizeof (struct target_cmsghdr)) 
+    if (msg_controllen < sizeof(struct target_cmsghdr)) {
         goto the_end;
+    }
     target_cmsg_addr = tswapal(target_msgh->msg_control);
     target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
     target_cmsg_start = target_cmsg;
@@ -5592,9 +5594,9 @@ abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr)
     }
     unlock_user_struct(target_ldt_info, ptr, 1);
 
-    if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN || 
+    if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN ||
         ldt_info.entry_number > TARGET_GDT_ENTRY_TLS_MAX)
-           return -TARGET_EINVAL;
+        return -TARGET_EINVAL;
     seg_32bit = ldt_info.flags & 1;
     contents = (ldt_info.flags >> 1) & 3;
     read_exec_only = (ldt_info.flags >> 3) & 1;
@@ -5670,7 +5672,7 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)
     lp = (uint32_t *)(gdt_table + idx);
     entry_1 = tswap32(lp[0]);
     entry_2 = tswap32(lp[1]);
-    
+
     read_exec_only = ((entry_2 >> 9) & 1) ^ 1;
     contents = (entry_2 >> 10) & 3;
     seg_not_present = ((entry_2 >> 15) & 1) ^ 1;
@@ -5686,8 +5688,8 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)
         (read_exec_only << 3) | (limit_in_pages << 4) |
         (seg_not_present << 5) | (useable << 6) | (lm << 7);
     limit = (entry_1 & 0xffff) | (entry_2  & 0xf0000);
-    base_addr = (entry_1 >> 16) | 
-        (entry_2 & 0xff000000) | 
+    base_addr = (entry_1 >> 16) |
+        (entry_2 & 0xff000000) |
         ((entry_2 & 0xff) << 16);
     target_ldt_info->base_addr = tswapal(base_addr);
     target_ldt_info->limit = tswap32(limit);
@@ -10554,8 +10556,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
 #if defined(TARGET_NR_fchownat)
     case TARGET_NR_fchownat:
-        if (!(p = lock_user_string(arg2))) 
+        p = lock_user_string(arg2);
+        if (!p) {
             return -TARGET_EFAULT;
+        }
         ret = get_errno(fchownat(arg1, p, low2highuid(arg3),
                                  low2highgid(arg4), arg5));
         unlock_user(p, arg2, 0);
-- 
2.24.1



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

* [PATCH v1 58/59] linux-user/syscall.c: remove unneeded labels
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (56 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 18:24 ` [PATCH v1 59/59] linux-user/vm86.c: remove unneeded label in do_vm86() Daniel Henrique Barboza
                   ` (3 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Riku Voipio, Daniel Henrique Barboza, Laurent Vivier

'out2' label in do_sendrecvmsg_locked() can be replaced by
'return' with the adequate exit value. Same thing with the
label 'out' in do_ioctl_blkpg(), and in that function we
can get rid of the 'ret' variable as well.

CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 linux-user/syscall.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 49c6151c2d..5db066921e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2941,7 +2941,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
              */
             msg.msg_name = (void *)-1;
         } else if (ret) {
-            goto out2;
+            return ret;
         }
     } else {
         msg.msg_name = NULL;
@@ -2960,15 +2960,13 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
         /* sendrcvmsg returns a different errno for this condition than
          * readv/writev, so we must catch it here before lock_iovec() does.
          */
-        ret = -TARGET_EMSGSIZE;
-        goto out2;
+        return -TARGET_EMSGSIZE;
     }
 
     vec = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE,
                      target_vec, count, send);
     if (vec == NULL) {
-        ret = -host_to_target_errno(errno);
-        goto out2;
+        return -host_to_target_errno(errno);
     }
     msg.msg_iovlen = count;
     msg.msg_iov = vec;
@@ -3020,7 +3018,6 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
 
 out:
     unlock_iovec(vec, target_vec, count, !send);
-out2:
     return ret;
 }
 
@@ -4952,7 +4949,6 @@ static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
     int target_size;
     const argtype *arg_type = ie->arg_type;
     const argtype part_arg_type[] = { MK_STRUCT(STRUCT_blkpg_partition) };
-    abi_long ret;
 
     struct blkpg_ioctl_arg *host_blkpg = (void*)buf_temp;
     struct blkpg_partition host_part;
@@ -4962,8 +4958,7 @@ static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
     target_size = thunk_type_size(arg_type, 0);
     argptr = lock_user(VERIFY_READ, arg, target_size, 1);
     if (!argptr) {
-        ret = -TARGET_EFAULT;
-        goto out;
+        return -TARGET_EFAULT;
     }
     thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
     unlock_user(argptr, arg, 0);
@@ -4975,8 +4970,7 @@ static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
         break;
     default:
         /* Unknown opcode */
-        ret = -TARGET_EINVAL;
-        goto out;
+        return -TARGET_EINVAL;
     }
 
     /* Read and convert blkpg->data */
@@ -4984,18 +4978,14 @@ static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
     target_size = thunk_type_size(part_arg_type, 0);
     argptr = lock_user(VERIFY_READ, arg, target_size, 1);
     if (!argptr) {
-        ret = -TARGET_EFAULT;
-        goto out;
+        return -TARGET_EFAULT;
     }
     thunk_convert(&host_part, argptr, part_arg_type, THUNK_HOST);
     unlock_user(argptr, arg, 0);
 
     /* Swizzle the data pointer to our local copy and call! */
     host_blkpg->data = &host_part;
-    ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg));
-
-out:
-    return ret;
+    return get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg));
 }
 
 static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp,
-- 
2.24.1



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

* [PATCH v1 59/59] linux-user/vm86.c: remove unneeded label in do_vm86()
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (57 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 58/59] linux-user/syscall.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:24 ` Daniel Henrique Barboza
  2020-01-06 19:54 ` [PATCH v1 00/59] trivial unneeded labels cleanup Corey Minyard
                   ` (2 subsequent siblings)
  61 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Riku Voipio, Daniel Henrique Barboza, Laurent Vivier

'out' can be replaced by 'return' calls with the adequate
return value.

CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 linux-user/vm86.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/linux-user/vm86.c b/linux-user/vm86.c
index 2fa7a89edc..eceddd05df 100644
--- a/linux-user/vm86.c
+++ b/linux-user/vm86.c
@@ -403,16 +403,14 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr)
     case TARGET_VM86_GET_IRQ_BITS:
     case TARGET_VM86_GET_AND_RESET_IRQ:
         gemu_log("qemu: unsupported vm86 subfunction (%ld)\n", subfunction);
-        ret = -TARGET_EINVAL;
-        goto out;
+        return -TARGET_EINVAL;
     case TARGET_VM86_PLUS_INSTALL_CHECK:
         /* NOTE: on old vm86 stuff this will return the error
            from verify_area(), because the subfunction is
            interpreted as (invalid) address to vm86_struct.
            So the installation check works.
             */
-        ret = 0;
-        goto out;
+        return 0;
     }
 
     /* save current CPU regs */
@@ -485,6 +483,5 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr)
     LOG_VM86("do_vm86: cs:ip=%04x:%04x\n",
              env->segs[R_CS].selector, env->eip);
     /* now the virtual CPU is ready for vm86 execution ! */
- out:
     return ret;
 }
-- 
2.24.1



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

* Re: [PATCH v1 19/59] block/ssh.c: remove unneeded labels
  2020-01-06 18:23 ` [PATCH v1 19/59] block/ssh.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-06 18:37   ` Richard W.M. Jones
  0 siblings, 0 replies; 113+ messages in thread
From: Richard W.M. Jones @ 2020-01-06 18:37 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, qemu-block

On Mon, Jan 06, 2020 at 03:23:45PM -0300, Daniel Henrique Barboza wrote:
> The 'out' labels for check_host_key_knownhosts() and authenticate()
> functions can be removed and, instead, call 'return' with the
> appropriate return value. The 'ret' integer from both functions
> could also be removed.
> 
> CC: Richard W.M. Jones <rjones@redhat.com>
> CC: qemu-block@nongnu.org
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  block/ssh.c | 61 +++++++++++++++++------------------------------------
>  1 file changed, 19 insertions(+), 42 deletions(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index b4375cf7d2..e0c56d002a 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -276,7 +276,6 @@ static void ssh_parse_filename(const char *filename, QDict *options,
>  
>  static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
>  {
> -    int ret;
>  #ifdef HAVE_LIBSSH_0_8
>      enum ssh_known_hosts_e state;
>      int r;
> @@ -295,7 +294,6 @@ static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
>          trace_ssh_check_host_key_knownhosts();
>          break;
>      case SSH_KNOWN_HOSTS_CHANGED:
> -        ret = -EINVAL;
>          r = ssh_get_server_publickey(s->session, &pubkey);
>          if (r == 0) {
>              r = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256,
> @@ -320,28 +318,23 @@ static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
>                         "host key does not match the one in known_hosts; this "
>                         "may be a possible attack");
>          }
> -        goto out;
> +        return -EINVAL;
>      case SSH_KNOWN_HOSTS_OTHER:
> -        ret = -EINVAL;
>          error_setg(errp,
>                     "host key for this server not found, another type exists");
> -        goto out;
> +        return -EINVAL;
>      case SSH_KNOWN_HOSTS_UNKNOWN:
> -        ret = -EINVAL;
>          error_setg(errp, "no host key was found in known_hosts");
> -        goto out;
> +        return -EINVAL;
>      case SSH_KNOWN_HOSTS_NOT_FOUND:
> -        ret = -ENOENT;
>          error_setg(errp, "known_hosts file not found");
> -        goto out;
> +        return -ENOENT;
>      case SSH_KNOWN_HOSTS_ERROR:
> -        ret = -EINVAL;
>          error_setg(errp, "error while checking the host");
> -        goto out;
> +        return -EINVAL;
>      default:
> -        ret = -EINVAL;
>          error_setg(errp, "error while checking for known server (%d)", state);
> -        goto out;
> +        return -EINVAL;
>      }
>  #else /* !HAVE_LIBSSH_0_8 */
>      int state;
> @@ -355,40 +348,31 @@ static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp)
>          trace_ssh_check_host_key_knownhosts();
>          break;
>      case SSH_SERVER_KNOWN_CHANGED:
> -        ret = -EINVAL;
>          error_setg(errp,
>                     "host key does not match the one in known_hosts; this "
>                     "may be a possible attack");
> -        goto out;
> +        return -EINVAL;
>      case SSH_SERVER_FOUND_OTHER:
> -        ret = -EINVAL;
>          error_setg(errp,
>                     "host key for this server not found, another type exists");
> -        goto out;
> +        return -EINVAL;
>      case SSH_SERVER_FILE_NOT_FOUND:
> -        ret = -ENOENT;
>          error_setg(errp, "known_hosts file not found");
> -        goto out;
> +        return -ENOENT;
>      case SSH_SERVER_NOT_KNOWN:
> -        ret = -EINVAL;
>          error_setg(errp, "no host key was found in known_hosts");
> -        goto out;
> +        return -EINVAL;
>      case SSH_SERVER_ERROR:
> -        ret = -EINVAL;
>          error_setg(errp, "server error");
> -        goto out;
> +        return -EINVAL;
>      default:
> -        ret = -EINVAL;
>          error_setg(errp, "error while checking for known server (%d)", state);
> -        goto out;
> +        return -EINVAL;
>      }
>  #endif /* !HAVE_LIBSSH_0_8 */
>  
>      /* known_hosts checking successful. */
> -    ret = 0;
> -
> - out:
> -    return ret;
> +    return 0;
>  }
>  
>  static unsigned hex2decimal(char ch)
> @@ -501,20 +485,18 @@ static int check_host_key(BDRVSSHState *s, SshHostKeyCheck *hkc, Error **errp)
>  
>  static int authenticate(BDRVSSHState *s, Error **errp)
>  {
> -    int r, ret;
> +    int r;
>      int method;
>  
>      /* Try to authenticate with the "none" method. */
>      r = ssh_userauth_none(s->session, NULL);
>      if (r == SSH_AUTH_ERROR) {
> -        ret = -EPERM;
>          session_error_setg(errp, s, "failed to authenticate using none "
>                                      "authentication");
> -        goto out;
> +        return -EPERM;
>      } else if (r == SSH_AUTH_SUCCESS) {
>          /* Authenticated! */
> -        ret = 0;
> -        goto out;
> +        return 0;
>      }
>  
>      method = ssh_userauth_list(s->session, NULL);
> @@ -527,23 +509,18 @@ static int authenticate(BDRVSSHState *s, Error **errp)
>      if (method & SSH_AUTH_METHOD_PUBLICKEY) {
>          r = ssh_userauth_publickey_auto(s->session, NULL, NULL);
>          if (r == SSH_AUTH_ERROR) {
> -            ret = -EINVAL;
>              session_error_setg(errp, s, "failed to authenticate using "
>                                          "publickey authentication");
> -            goto out;
> +            return -EINVAL;
>          } else if (r == SSH_AUTH_SUCCESS) {
>              /* Authenticated! */
> -            ret = 0;
> -            goto out;
> +            return 0;
>          }
>      }
>  
> -    ret = -EPERM;
>      error_setg(errp, "failed to authenticate using publickey authentication "
>                 "and the identities held by your ssh-agent");
> -
> - out:
> -    return ret;
> +    return -EPERM;
>  }
>  
>  static QemuOptsList ssh_runtime_opts = {

I agree that the code is functionality the same after this change.
Don't know whether or not one style or the other is preferred by qemu,
but in any case:

Reviewed-by: Richard W.M. Jones <rjones@redhat.com>

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top



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

* Re: [PATCH v1 05/59] ram.c: remove unneeded labels
  2020-01-06 18:23 ` [PATCH v1 05/59] ram.c: " Daniel Henrique Barboza
@ 2020-01-06 18:57   ` Dr. David Alan Gilbert
  2020-01-06 23:38   ` Juan Quintela
  2020-01-08 12:41   ` Juan Quintela
  2 siblings, 0 replies; 113+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-06 18:57 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, Juan Quintela

* Daniel Henrique Barboza (danielhb413@gmail.com) wrote:
> ram_save_queue_pages() has an 'err' label that can be replaced by
> 'return -1' instead.
> 
> Same thing with ram_discard_range(), and in this case we can also
> get rid of the 'ret' variable and return either '-1' on error
> or the result of ram_block_discard_range().
> 
> CC: Juan Quintela <quintela@redhat.com>
> CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/ram.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 96feb4062c..980cc644d7 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2434,7 +2434,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
>               * it's the 1st request.
>               */
>              error_report("ram_save_queue_pages no previous block");
> -            goto err;
> +            return -1;
>          }
>      } else {
>          ramblock = qemu_ram_block_by_name(rbname);
> @@ -2442,7 +2442,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
>          if (!ramblock) {
>              /* We shouldn't be asked for a non-existent RAMBlock */
>              error_report("ram_save_queue_pages no block '%s'", rbname);
> -            goto err;
> +            return -1;
>          }
>          rs->last_req_rb = ramblock;
>      }
> @@ -2451,7 +2451,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
>          error_report("%s request overrun start=" RAM_ADDR_FMT " len="
>                       RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT,
>                       __func__, start, len, ramblock->used_length);
> -        goto err;
> +        return -1;
>      }
>  
>      struct RAMSrcPageRequest *new_entry =
> @@ -2467,9 +2467,6 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
>      qemu_mutex_unlock(&rs->src_page_req_mutex);
>  
>      return 0;
> -
> -err:
> -    return -1;
>  }
>  
>  static bool save_page_use_compression(RAMState *rs)
> @@ -3072,8 +3069,6 @@ int ram_postcopy_send_discard_bitmap(MigrationState *ms)
>   */
>  int ram_discard_range(const char *rbname, uint64_t start, size_t length)
>  {
> -    int ret = -1;
> -
>      trace_ram_discard_range(rbname, start, length);
>  
>      RCU_READ_LOCK_GUARD();
> @@ -3081,7 +3076,7 @@ int ram_discard_range(const char *rbname, uint64_t start, size_t length)
>  
>      if (!rb) {
>          error_report("ram_discard_range: Failed to find block '%s'", rbname);
> -        goto err;
> +        return -1;
>      }
>  
>      /*
> @@ -3093,10 +3088,7 @@ int ram_discard_range(const char *rbname, uint64_t start, size_t length)
>                       length >> qemu_target_page_bits());
>      }
>  
> -    ret = ram_block_discard_range(rb, start, length);
> -
> -err:
> -    return ret;
> +    return ram_block_discard_range(rb, start, length);
>  }
>  
>  /*
> -- 
> 2.24.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



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

* Re: [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
  2020-01-06 18:23 ` [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init() Daniel Henrique Barboza
@ 2020-01-06 19:01   ` Marc-André Lureau
  2020-01-07  6:52   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 113+ messages in thread
From: Marc-André Lureau @ 2020-01-06 19:01 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, Paolo Bonzini, qemu-devel

On Mon, Jan 6, 2020 at 10:25 PM Daniel Henrique Barboza
<danielhb413@gmail.com> wrote:
>
> The 'fail' label is a simply call to 'return -1' on error. Remove
> it and do the return call instead.
>
> CC: Marc-André Lureau <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  chardev/char-win.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/chardev/char-win.c b/chardev/char-win.c
> index 34825f683d..72c232e6d9 100644
> --- a/chardev/char-win.c
> +++ b/chardev/char-win.c
> @@ -85,12 +85,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>      s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
>      if (!s->hsend) {
>          error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>      }
>      s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
>      if (!s->hrecv) {
>          error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>      }
>
>      s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
> @@ -98,12 +98,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>      if (s->file == INVALID_HANDLE_VALUE) {
>          error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
>          s->file = NULL;
> -        goto fail;
> +        return -1;
>      }
>
>      if (!SetupComm(s->file, NRECVBUF, NSENDBUF)) {
>          error_setg(errp, "Failed SetupComm");
> -        goto fail;
> +        return -1;
>      }
>
>      ZeroMemory(&comcfg, sizeof(COMMCONFIG));
> @@ -114,29 +114,26 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>
>      if (!SetCommState(s->file, &comcfg.dcb)) {
>          error_setg(errp, "Failed SetCommState");
> -        goto fail;
> +        return -1;
>      }
>
>      if (!SetCommMask(s->file, EV_ERR)) {
>          error_setg(errp, "Failed SetCommMask");
> -        goto fail;
> +        return -1;
>      }
>
>      cto.ReadIntervalTimeout = MAXDWORD;
>      if (!SetCommTimeouts(s->file, &cto)) {
>          error_setg(errp, "Failed SetCommTimeouts");
> -        goto fail;
> +        return -1;
>      }
>
>      if (!ClearCommError(s->file, &err, &comstat)) {
>          error_setg(errp, "Failed ClearCommError");
> -        goto fail;
> +        return -1;
>      }
>      qemu_add_polling_cb(win_chr_serial_poll, chr);
>      return 0;
> -
> - fail:
> -    return -1;
>  }
>
>  int win_chr_pipe_poll(void *opaque)
> --
> 2.24.1
>



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

* Re: [PATCH v1 09/59] chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init()
  2020-01-06 18:23 ` [PATCH v1 09/59] chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init() Daniel Henrique Barboza
@ 2020-01-06 19:01   ` Marc-André Lureau
  0 siblings, 0 replies; 113+ messages in thread
From: Marc-André Lureau @ 2020-01-06 19:01 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, Paolo Bonzini, qemu-devel

On Mon, Jan 6, 2020 at 10:25 PM Daniel Henrique Barboza
<danielhb413@gmail.com> wrote:
>
> The 'fail' label is simply doing a 'return -1'.
>
> CC: Marc-André Lureau <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  chardev/char-pipe.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c
> index 94d714ffcd..65d52beb0d 100644
> --- a/chardev/char-pipe.c
> +++ b/chardev/char-pipe.c
> @@ -54,12 +54,12 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
>      s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
>      if (!s->hsend) {
>          error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>      }
>      s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
>      if (!s->hrecv) {
>          error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>      }
>
>      openname = g_strdup_printf("\\\\.\\pipe\\%s", filename);
> @@ -72,7 +72,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
>      if (s->file == INVALID_HANDLE_VALUE) {
>          error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError());
>          s->file = NULL;
> -        goto fail;
> +        return -1;
>      }
>
>      ZeroMemory(&ov, sizeof(ov));
> @@ -80,7 +80,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
>      ret = ConnectNamedPipe(s->file, &ov);
>      if (ret) {
>          error_setg(errp, "Failed ConnectNamedPipe");
> -        goto fail;
> +        return -1;
>      }
>
>      ret = GetOverlappedResult(s->file, &ov, &size, TRUE);
> @@ -90,7 +90,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
>              CloseHandle(ov.hEvent);
>              ov.hEvent = NULL;
>          }
> -        goto fail;
> +        return -1;
>      }
>
>      if (ov.hEvent) {
> @@ -99,9 +99,6 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
>      }
>      qemu_add_polling_cb(win_chr_pipe_poll, chr);
>      return 0;
> -
> - fail:
> -    return -1;
>  }
>
>  static void qemu_chr_open_pipe(Chardev *chr,
> --
> 2.24.1
>



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

* Re: [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label
  2020-01-06 18:23 ` [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label Daniel Henrique Barboza
@ 2020-01-06 19:02   ` Marc-André Lureau
  0 siblings, 0 replies; 113+ messages in thread
From: Marc-André Lureau @ 2020-01-06 19:02 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, Paolo Bonzini, qemu-devel

On Mon, Jan 6, 2020 at 10:25 PM Daniel Henrique Barboza
<danielhb413@gmail.com> wrote:
>
> CC: Marc-André Lureau <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  chardev/char-mux.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/chardev/char-mux.c b/chardev/char-mux.c
> index 200c62a0d0..edbaaf5cbf 100644
> --- a/chardev/char-mux.c
> +++ b/chardev/char-mux.c
> @@ -140,7 +140,7 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
>      if (d->term_got_escape) {
>          d->term_got_escape = 0;
>          if (ch == term_escape_char) {
> -            goto send_char;
> +            return 1;
>          }
>          switch (ch) {
>          case '?':
> @@ -174,7 +174,6 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
>      } else if (ch == term_escape_char) {
>          d->term_got_escape = 1;
>      } else {
> -    send_char:
>          return 1;
>      }
>      return 0;
> --
> 2.24.1
>



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (58 preceding siblings ...)
  2020-01-06 18:24 ` [PATCH v1 59/59] linux-user/vm86.c: remove unneeded label in do_vm86() Daniel Henrique Barboza
@ 2020-01-06 19:54 ` Corey Minyard
  2020-01-06 20:35   ` Daniel Henrique Barboza
  2020-01-13 15:26   ` Markus Armbruster
  2020-01-07  9:43 ` Max Reitz
  2020-01-10 19:05 ` Eric Blake
  61 siblings, 2 replies; 113+ messages in thread
From: Corey Minyard @ 2020-01-06 19:54 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel

On Mon, Jan 06, 2020 at 03:23:26PM -0300, Daniel Henrique Barboza wrote:
> Hello,
> 
> This is the type of cleanup I've contributed to Libvirt
> during the last year. Figured QEMU also deserves the same
> care.
> 
> The idea here is remove unneeded labels. By 'unneeded' I
> mean labels that does nothing but a 'return' call. One
> common case is something like this:
> 
> if ()
>     goto cleanup;
> [...]
>  cleanup:
>     return 0;
> 
> This code can be simplified to:
> 
> if ()
>     return 0;
> 
> 
> Which is cleaner and requires less brain cycles to wonder
> whether the 'cleanup' label does anything special, such
> as a heap memory cleanup.

I would disagree with this analysis.  To me, I often wonder
when I have to add cleanup code to a routine whether there is
some hidden return in the middle of the function.  That's a lot
harder to spot than just looking for the cleanup label at the
end of the function to see what it does.  For non-trivial
functions I prefer to have one point of return at the end
(and maybe some minor checks with returns right at the beginning).
I'm not adamant about this, just my opinion.

But if we are going to fix things like this, it might be best to add
them to the coding style document and checkpatch script.  Otherwise
these sorts of things will just continue.

-corey

> 
> Another common case uses a variable to set a return value,
> generally an error, then return:
> 
> if () {
>     ret = -ENOENT;
>     goto out;
> }
> [..]
>  out:
>     return ret;
> 
> Likewise, it is clearer to just 'return -ENOENT' instead of
> jumping to a label. There are other cases being handled in
> these patches, but these are the most common.
> 
> There are still a handful of unneeded labels hanging around after
> this series. There are cases in which the label name is
> part of the code semantics and I judged not worth removing.
> search_chunk() in block/dmg.c has an example of an unneeded
> 'err' label that I decided to not remove.
> 
> No functional change was made. If any of these patches changes
> existing behavior it is unintended and an error from my
> part.
> 
> 
> 
> Daniel Henrique Barboza (59):
>   spapr.c: remove 'out' label in spapr_dt_cas_updates()
>   ppc440_bamboo.c: remove label from bamboo_load_device_tree()
>   kvm-all.c: remove unneeded labels
>   paaudio.c: remove unneeded labels
>   ram.c: remove unneeded labels
>   mips-semi.c: remove 'uhi_done' label in helper_do_semihosting()
>   unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2()
>   chardev/char-mux.c: remove 'send_char' label
>   chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init()
>   chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
>   exec.c: remove 'err' label in ram_block_discard_range()
>   virtfs-proxy-helper.c: remove 'err_out' label in setugid()
>   block/vdi.c: remove 'fail' label in vdi_open()
>   block/file-posix.c: remove unneeded labels
>   block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open()
>   block/gluster.c: remove unneeded 'exit' label
>   block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block()
>   qcow2-refcount.c: remove unneeded 'fail' label in
>     qcow2_refcount_init()
>   block/ssh.c: remove unneeded labels
>   block/vpc.c: remove unneeded 'fail' label in create_dynamic_disk()
>   block/backup.c remove unneeded 'out' label in backup_run()
>   block/vmdk.c: remove unneeded labels
>   block/vxhs.c: remove unneeded 'out' label in vxhs_iio_callback()
>   block/vhdx-log.c: remove unneeded labels
>   block/vhdx.c: remove unneeded 'exit' labels
>   block/replication.c: remove unneeded label in replication_co_writev
>   crypto/block-luks.c: remove unneeded label in
>     qcrypto_block_luks_find_key
>   qga/commands-win32.c: remove 'out' label in get_pci_info
>   cryptodev-vhost.c: remove unneeded 'err' label in
>     cryptodev_vhost_start
>   util/module.c: remove unneeded label in module_load_file()
>   util/aio-posix.c: remove unneeded 'out' label in aio_epoll
>   qemu-img.c: remove 'out4' label in img_compare
>   ipmi/ipmi_bmc_sim.c: remove unneeded labels
>   ipmi/ipmi_bt.c: remove unneeded label in ipmi_bt_handle_event
>   ipmi_bmc_extern.c: remove unneeded label in
>     ipmi_bmc_extern_handle_command
>   ipmi/ipmi_kcs.c: remove unneeded label in ipmi_kcs_handle_event
>   s390x/event-facility.c: remove unneeded labels
>   s390x/sclp.c: remove unneeded label in sclp_service_call()
>   usb/dev-mtp.c: remove unneeded label in write_retry()
>   hsb/hcd-ehci.c: remove unneeded labels
>   intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
>   i386/intel_iommu.c: remove unneeded labels
>   i386/amd_iommu.c: remove unneeded label in amdvi_int_remap_msi()
>   9p-local.c: remove unneeded label in local_unlinkat_common()
>   9pfs/9p.c: remove unneeded labels
>   alpha/typhoon.c: remove unneeded label in typhoon_translate_iommu()
>   pvrdma_main.c: remove unneeded labels
>   pvrdma_dev_ring.c: remove unneeded label in pvrdma_ring_init()
>   rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd()
>   rdma/rdma_backend.c: remove unneeded label in rdma_backend_init()
>   virtio/vhost.c: remove unneeded labels
>   net/vhost_net.c: remove unneeded labels
>   net/net_tx_pkt.c: remove unneeded label in net_tx_pkt_get_gso_type()
>   ivshmem-server/main.c: remove unneeded label in main()
>   linux-user/flatload.c: remove unused 'out' label
>   linux-user/signal.c: remove unneeded label in do_sigaltstack()
>   linux-user/syscall.c: fix trailing whitespaces and style
>   linux-user/syscall.c: remove unneeded labels
>   linux-user/vm86.c: remove unneeded label in do_vm86()
> 
>  accel/kvm/kvm-all.c           | 30 +++++-------
>  audio/paaudio.c               | 10 +---
>  backends/cryptodev-vhost.c    |  4 +-
>  block/backup.c                |  6 +--
>  block/blkreplay.c             |  8 +---
>  block/dmg.c                   | 10 +---
>  block/file-posix.c            | 10 ++--
>  block/gluster.c               |  3 +-
>  block/qcow2-refcount.c        |  7 +--
>  block/replication.c           |  9 ++--
>  block/ssh.c                   | 61 ++++++++-----------------
>  block/vdi.c                   | 40 ++++++----------
>  block/vhdx-log.c              | 86 +++++++++++++----------------------
>  block/vhdx.c                  | 10 ++--
>  block/vmdk.c                  | 37 ++++++---------
>  block/vpc.c                   | 12 ++---
>  block/vxhs.c                  |  4 +-
>  chardev/char-mux.c            |  3 +-
>  chardev/char-pipe.c           | 13 ++----
>  chardev/char-win.c            | 19 ++++----
>  contrib/ivshmem-server/main.c |  9 ++--
>  crypto/block-luks.c           |  3 +-
>  exec.c                        | 13 +++---
>  fsdev/virtfs-proxy-helper.c   |  4 +-
>  hw/9pfs/9p-local.c            | 12 ++---
>  hw/9pfs/9p.c                  |  9 ++--
>  hw/alpha/typhoon.c            | 18 ++++----
>  hw/i386/amd_iommu.c           | 13 ++----
>  hw/i386/intel_iommu.c         |  8 ++--
>  hw/intc/s390_flic_kvm.c       | 10 ++--
>  hw/ipmi/ipmi_bmc_extern.c     |  5 +-
>  hw/ipmi/ipmi_bmc_sim.c        |  9 +---
>  hw/ipmi/ipmi_bt.c             |  8 ++--
>  hw/ipmi/ipmi_kcs.c            |  4 +-
>  hw/net/net_tx_pkt.c           | 11 ++---
>  hw/net/vhost_net.c            |  7 ++-
>  hw/ppc/ppc440_bamboo.c        |  8 +---
>  hw/ppc/spapr.c                |  9 ++--
>  hw/rdma/rdma_backend.c        |  4 +-
>  hw/rdma/rdma_rm.c             | 11 ++---
>  hw/rdma/vmw/pvrdma_dev_ring.c |  7 +--
>  hw/rdma/vmw/pvrdma_main.c     | 10 ++--
>  hw/s390x/event-facility.c     | 21 +++------
>  hw/s390x/sclp.c               | 16 ++-----
>  hw/usb/dev-mtp.c              | 13 ++----
>  hw/usb/hcd-ehci.c             | 32 ++++---------
>  hw/virtio/vhost.c             | 11 ++---
>  linux-user/flatload.c         |  1 -
>  linux-user/signal.c           | 20 +++-----
>  linux-user/syscall.c          | 54 ++++++++++------------
>  linux-user/vm86.c             |  7 +--
>  migration/ram.c               | 18 ++------
>  qemu-img.c                    |  7 +--
>  qga/commands-win32.c          | 17 ++++---
>  target/mips/mips-semi.c       | 15 +++---
>  target/unicore32/softmmu.c    | 23 +++-------
>  util/aio-posix.c              |  3 +-
>  util/module.c                 | 11 ++---
>  58 files changed, 293 insertions(+), 550 deletions(-)
> 
> -- 
> 2.24.1
> 
> 


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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-06 19:54 ` [PATCH v1 00/59] trivial unneeded labels cleanup Corey Minyard
@ 2020-01-06 20:35   ` Daniel Henrique Barboza
  2020-01-07  6:16     ` Kevin Wolf
  2020-01-13 15:26   ` Markus Armbruster
  1 sibling, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-06 20:35 UTC (permalink / raw)
  To: minyard; +Cc: qemu-trivial, qemu-devel



On 1/6/20 4:54 PM, Corey Minyard wrote:
> On Mon, Jan 06, 2020 at 03:23:26PM -0300, Daniel Henrique Barboza wrote:
>> Hello,
[...]
>>
>> Which is cleaner and requires less brain cycles to wonder
>> whether the 'cleanup' label does anything special, such
>> as a heap memory cleanup.
> 
> I would disagree with this analysis.  To me, I often wonder
> when I have to add cleanup code to a routine whether there is
> some hidden return in the middle of the function.  That's a lot
> harder to spot than just looking for the cleanup label at the
> end of the function to see what it does.  For non-trivial
> functions I prefer to have one point of return at the end
> (and maybe some minor checks with returns right at the beginning).
> I'm not adamant about this, just my opinion.

I agree that what I'm doing here isn't a one rule fits all situation. This
is why I didn't purge all the 'unused' labels I found. The criteria used to
remove/spare labels will differ from person to person (although I believe that
cases such as patch 15 isn't too much of a debate), thus I'd rather leave to
each maintainer to accept/deny the changes based on the context of the code.

And for this same reason I don't think that a checkpatch rule is necessary.
The review process can take care of these situations and allow 'good unneeded
labels' to be in the code.


Thanks,


DHB



> 
> But if we are going to fix things like this, it might be best to add
> them to the coding style document and checkpatch script.  Otherwise
> these sorts of things will just continue.
> 
> -corey
> 


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

* Re: [PATCH v1 13/59] block/vdi.c: remove 'fail' label in vdi_open()
  2020-01-06 18:23 ` [PATCH v1 13/59] block/vdi.c: remove 'fail' label in vdi_open() Daniel Henrique Barboza
@ 2020-01-06 21:04   ` Stefan Weil
  0 siblings, 0 replies; 113+ messages in thread
From: Stefan Weil @ 2020-01-06 21:04 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial, qemu-block

Am 06.01.20 um 19:23 schrieb Daniel Henrique Barboza:

> The 'fail' label can be replaced by 'return ret' or by
> a 'return' with the error code that was being set right
> before the 'goto' call.
>
> CC: Stefan Weil <sw@weilnetz.de>
> CC: qemu-block@nongnu.org
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  block/vdi.c | 40 +++++++++++++---------------------------
>  1 file changed, 13 insertions(+), 27 deletions(-)
>
> diff --git a/block/vdi.c b/block/vdi.c
> index 0142da7233..6d486ffed9 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -388,7 +388,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>  
>      ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
>      if (ret < 0) {
> -        goto fail;
> +        return ret;
>      }
>  
>      vdi_header_to_cpu(&header);
> @@ -400,8 +400,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>          error_setg(errp, "Unsupported VDI image size (size is 0x%" PRIx64
>                            ", max supported is 0x%" PRIx64 ")",
>                            header.disk_size, VDI_DISK_SIZE_MAX);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      }
>  
>      uuid_link = header.uuid_link;
> @@ -418,58 +417,48 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>      if (header.signature != VDI_SIGNATURE) {
>          error_setg(errp, "Image not in VDI format (bad signature %08" PRIx32
>                     ")", header.signature);
> -        ret = -EINVAL;
> -        goto fail;
> +        return -EINVAL;
>      } else if (header.version != VDI_VERSION_1_1) {
>          error_setg(errp, "unsupported VDI image (version %" PRIu32 ".%" PRIu32
>                     ")", header.version >> 16, header.version & 0xffff);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (header.offset_bmap % SECTOR_SIZE != 0) {
>          /* We only support block maps which start on a sector boundary. */
>          error_setg(errp, "unsupported VDI image (unaligned block map offset "
>                     "0x%" PRIx32 ")", header.offset_bmap);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (header.offset_data % SECTOR_SIZE != 0) {
>          /* We only support data blocks which start on a sector boundary. */
>          error_setg(errp, "unsupported VDI image (unaligned data offset 0x%"
>                     PRIx32 ")", header.offset_data);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (header.sector_size != SECTOR_SIZE) {
>          error_setg(errp, "unsupported VDI image (sector size %" PRIu32
>                     " is not %u)", header.sector_size, SECTOR_SIZE);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
>          error_setg(errp, "unsupported VDI image (block size %" PRIu32
>                           " is not %" PRIu32 ")",
>                     header.block_size, DEFAULT_CLUSTER_SIZE);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (header.disk_size >
>                 (uint64_t)header.blocks_in_image * header.block_size) {
>          error_setg(errp, "unsupported VDI image (disk size %" PRIu64 ", "
>                     "image bitmap has room for %" PRIu64 ")",
>                     header.disk_size,
>                     (uint64_t)header.blocks_in_image * header.block_size);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (!qemu_uuid_is_null(&uuid_link)) {
>          error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (!qemu_uuid_is_null(&uuid_parent)) {
>          error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      } else if (header.blocks_in_image > VDI_BLOCKS_IN_IMAGE_MAX) {
>          error_setg(errp, "unsupported VDI image "
>                           "(too many blocks %u, max is %u)",
>                            header.blocks_in_image, VDI_BLOCKS_IN_IMAGE_MAX);
> -        ret = -ENOTSUP;
> -        goto fail;
> +        return -ENOTSUP;
>      }
>  
>      bs->total_sectors = header.disk_size / SECTOR_SIZE;
> @@ -482,8 +471,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>      bmap_size = DIV_ROUND_UP(bmap_size, SECTOR_SIZE);
>      s->bmap = qemu_try_blockalign(bs->file->bs, bmap_size * SECTOR_SIZE);
>      if (s->bmap == NULL) {
> -        ret = -ENOMEM;
> -        goto fail;
> +        return -ENOMEM;
>      }
>  
>      ret = bdrv_pread(bs->file, header.offset_bmap, s->bmap,
> @@ -509,8 +497,6 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>  
>   fail_free_bmap:
>      qemu_vfree(s->bmap);
> -
> - fail:
>      return ret;
>  }
>  


Technically these changes are fine. Personally I prefer functions having
a single return statement, even if that requires a goto statement. But
if there is a consense to change the code, that can be done of course.

Regards,
Stefan Weil





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

* Re: [PATCH v1 05/59] ram.c: remove unneeded labels
  2020-01-06 18:23 ` [PATCH v1 05/59] ram.c: " Daniel Henrique Barboza
  2020-01-06 18:57   ` Dr. David Alan Gilbert
@ 2020-01-06 23:38   ` Juan Quintela
  2020-01-08 12:41   ` Juan Quintela
  2 siblings, 0 replies; 113+ messages in thread
From: Juan Quintela @ 2020-01-06 23:38 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, Dr . David Alan Gilbert

Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
> ram_save_queue_pages() has an 'err' label that can be replaced by
> 'return -1' instead.
>
> Same thing with ram_discard_range(), and in this case we can also
> get rid of the 'ret' variable and return either '-1' on error
> or the result of ram_block_discard_range().
>
> CC: Juan Quintela <quintela@redhat.com>
> CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>



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

* Re: [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates()
  2020-01-06 18:23 ` [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates() Daniel Henrique Barboza
@ 2020-01-06 23:44   ` David Gibson
  0 siblings, 0 replies; 113+ messages in thread
From: David Gibson @ 2020-01-06 23:44 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]

On Mon, Jan 06, 2020 at 03:23:27PM -0300, Daniel Henrique Barboza wrote:
> 'out' can be replaced by 'return' with the appropriate
> return value.
> 
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: qemu-ppc@nongnu.org
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Applied to ppc-for-5.0.  I see this is part of a larged series which
might have a different merge plan, but it should be an easy conflict
to resolve if that happens.

> ---
>  hw/ppc/spapr.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f11422fc41..1bfe47337c 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -878,7 +878,7 @@ static int spapr_dt_cas_updates(SpaprMachineState *spapr, void *fdt,
>          g_assert(smc->dr_lmb_enabled);
>          ret = spapr_populate_drconf_memory(spapr, fdt);
>          if (ret) {
> -            goto out;
> +            return ret;
>          }
>      }
>  
> @@ -889,11 +889,8 @@ static int spapr_dt_cas_updates(SpaprMachineState *spapr, void *fdt,
>              return offset;
>          }
>      }
> -    ret = spapr_ovec_populate_dt(fdt, offset, spapr->ov5_cas,
> -                                 "ibm,architecture-vec-5");
> -
> -out:
> -    return ret;
> +    return spapr_ovec_populate_dt(fdt, offset, spapr->ov5_cas,
> +                                  "ibm,architecture-vec-5");
>  }
>  
>  static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree()
  2020-01-06 18:23 ` [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree() Daniel Henrique Barboza
@ 2020-01-06 23:45   ` David Gibson
  0 siblings, 0 replies; 113+ messages in thread
From: David Gibson @ 2020-01-06 23:45 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]

On Mon, Jan 06, 2020 at 03:23:28PM -0300, Daniel Henrique Barboza wrote:
> 'out' label can be replaced by 'return -1' in all cases.
> 
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: qemu-ppc@nongnu.org
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Applied to ppc-for-5.0.

> ---
>  hw/ppc/ppc440_bamboo.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
> index 4d95c0f8a8..b782641b23 100644
> --- a/hw/ppc/ppc440_bamboo.c
> +++ b/hw/ppc/ppc440_bamboo.c
> @@ -71,12 +71,12 @@ static int bamboo_load_device_tree(hwaddr addr,
>  
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
>      if (!filename) {
> -        goto out;
> +        return -1;
>      }
>      fdt = load_device_tree(filename, &fdt_size);
>      g_free(filename);
>      if (fdt == NULL) {
> -        goto out;
> +        return -1;
>      }
>  
>      /* Manipulate device tree in memory. */
> @@ -117,10 +117,6 @@ static int bamboo_load_device_tree(hwaddr addr,
>      rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
>      g_free(fdt);
>      return 0;
> -
> -out:
> -
> -    return ret;
>  }
>  
>  /* Create reset TLB entries for BookE, spanning the 32bit addr space.  */

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-06 20:35   ` Daniel Henrique Barboza
@ 2020-01-07  6:16     ` Kevin Wolf
  2020-01-07  7:06       ` Philippe Mathieu-Daudé
  2020-01-07 11:52       ` Daniel Henrique Barboza
  0 siblings, 2 replies; 113+ messages in thread
From: Kevin Wolf @ 2020-01-07  6:16 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, minyard

Am 06.01.2020 um 21:35 hat Daniel Henrique Barboza geschrieben:
> 
> 
> On 1/6/20 4:54 PM, Corey Minyard wrote:
> > On Mon, Jan 06, 2020 at 03:23:26PM -0300, Daniel Henrique Barboza wrote:
> > > Hello,
> [...]
> > > 
> > > Which is cleaner and requires less brain cycles to wonder
> > > whether the 'cleanup' label does anything special, such
> > > as a heap memory cleanup.
> > 
> > I would disagree with this analysis.  To me, I often wonder
> > when I have to add cleanup code to a routine whether there is
> > some hidden return in the middle of the function.  That's a lot
> > harder to spot than just looking for the cleanup label at the
> > end of the function to see what it does.  For non-trivial
> > functions I prefer to have one point of return at the end
> > (and maybe some minor checks with returns right at the beginning).
> > I'm not adamant about this, just my opinion.

It depends on the case, but yes, I had similar thoughts, at least when
we're talking about non-trivial parts of a function. (Very short
functions of just some initial checks returning directly are usually
fine.)

> I agree that what I'm doing here isn't a one rule fits all situation. This
> is why I didn't purge all the 'unused' labels I found. The criteria used to
> remove/spare labels will differ from person to person (although I believe that
> cases such as patch 15 isn't too much of a debate), thus I'd rather leave to
> each maintainer to accept/deny the changes based on the context of the code.

So what is your plan for getting the series merged? Should maintainers
just picks patches from the series, or do you want to collect Acked-by
tags and then merge it through a single tree? If the latter, which one?

Kevin



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

* Re: [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
  2020-01-06 18:23 ` [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init() Daniel Henrique Barboza
  2020-01-06 19:01   ` Marc-André Lureau
@ 2020-01-07  6:52   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 113+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-07  6:52 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel
  Cc: qemu-trivial, Marc-André Lureau, Paolo Bonzini

On 1/6/20 7:23 PM, Daniel Henrique Barboza wrote:
> The 'fail' label is a simply call to 'return -1' on error. Remove
> it and do the return call instead.
> 
> CC: Marc-André Lureau <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   chardev/char-win.c | 19 ++++++++-----------
>   1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/chardev/char-win.c b/chardev/char-win.c
> index 34825f683d..72c232e6d9 100644
> --- a/chardev/char-win.c
> +++ b/chardev/char-win.c
> @@ -85,12 +85,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>       s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
>       if (!s->hsend) {
>           error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>       }
>       s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
>       if (!s->hrecv) {
>           error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>       }
>   
>       s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
> @@ -98,12 +98,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>       if (s->file == INVALID_HANDLE_VALUE) {
>           error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
>           s->file = NULL;
> -        goto fail;
> +        return -1;
>       }
>   
>       if (!SetupComm(s->file, NRECVBUF, NSENDBUF)) {
>           error_setg(errp, "Failed SetupComm");
> -        goto fail;
> +        return -1;
>       }
>   
>       ZeroMemory(&comcfg, sizeof(COMMCONFIG));
> @@ -114,29 +114,26 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>   
>       if (!SetCommState(s->file, &comcfg.dcb)) {
>           error_setg(errp, "Failed SetCommState");
> -        goto fail;
> +        return -1;
>       }
>   
>       if (!SetCommMask(s->file, EV_ERR)) {
>           error_setg(errp, "Failed SetCommMask");
> -        goto fail;
> +        return -1;
>       }
>   
>       cto.ReadIntervalTimeout = MAXDWORD;
>       if (!SetCommTimeouts(s->file, &cto)) {
>           error_setg(errp, "Failed SetCommTimeouts");
> -        goto fail;
> +        return -1;
>       }
>   
>       if (!ClearCommError(s->file, &err, &comstat)) {
>           error_setg(errp, "Failed ClearCommError");
> -        goto fail;
> +        return -1;
>       }
>       qemu_add_polling_cb(win_chr_serial_poll, chr);
>       return 0;
> -
> - fail:
> -    return -1;
>   }
>   
>   int win_chr_pipe_poll(void *opaque)
> 



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

* Re: [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start
  2020-01-06 18:23 ` [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start Daniel Henrique Barboza
@ 2020-01-07  6:53   ` Philippe Mathieu-Daudé
  2020-01-07  8:18   ` Gonglei (Arei)
  1 sibling, 0 replies; 113+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-07  6:53 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial, Gonglei

On 1/6/20 7:23 PM, Daniel Henrique Barboza wrote:
> 'err' can be replaced by 'return r'.
> 
> CC: Gonglei <arei.gonglei@huawei.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   backends/cryptodev-vhost.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c
> index 8337c9a495..907ca21fa7 100644
> --- a/backends/cryptodev-vhost.c
> +++ b/backends/cryptodev-vhost.c
> @@ -201,7 +201,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_queues)
>       r = k->set_guest_notifiers(qbus->parent, total_queues, true);
>       if (r < 0) {
>           error_report("error binding guest notifier: %d", -r);
> -        goto err;
> +        return r;
>       }
>   
>       for (i = 0; i < total_queues; i++) {
> @@ -236,7 +236,7 @@ err_start:
>       if (e < 0) {
>           error_report("vhost guest notifier cleanup failed: %d", e);
>       }
> -err:
> +
>       return r;
>   }
>   
> 



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

* Re: [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style
  2020-01-06 18:24 ` [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style Daniel Henrique Barboza
@ 2020-01-07  6:57   ` Philippe Mathieu-Daudé
  2020-01-07 10:37   ` Peter Maydell
  1 sibling, 0 replies; 113+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-07  6:57 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel
  Cc: qemu-trivial, Riku Voipio, Laurent Vivier

On 1/6/20 7:24 PM, Daniel Henrique Barboza wrote:
> There are trailing whitespaces in this file that, if removed
> by a text editor that refuses to let the traiing whitespace

typo "trailing"

> alone, which happens to be the editor I am using, will cause
> checkpatch.pl to warn about styling problems in the resulting
> patch. This happens because the trailing whitespace lines
> are using a deprecated style.

Maybe you can use 'git add -p' to only add the lines with relevant changes.

> To keep the intended change I wanted to do (remove unneeded
> labels in do_ioctl_blkpg() and do_sendrecvmsg_locked())
> trivial, this patch is another trivial change to fix the
> trailing whitespaces and the code style errors that
> checkpatch.pl warns about. Doing this change beforehand will
> keep the next patch focused just on the label removal changes.
> 
> CC: Riku Voipio <riku.voipio@iki.fi>
> CC: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>   linux-user/syscall.c | 30 +++++++++++++++++-------------
>   1 file changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 171c0caef3..49c6151c2d 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1062,7 +1062,7 @@ static inline rlim_t target_to_host_rlim(abi_ulong target_rlim)
>   {
>       abi_ulong target_rlim_swap;
>       rlim_t result;
> -
> +
>       target_rlim_swap = tswapal(target_rlim);
>       if (target_rlim_swap == TARGET_RLIM_INFINITY)
>           return RLIM_INFINITY;
> @@ -1070,7 +1070,7 @@ static inline rlim_t target_to_host_rlim(abi_ulong target_rlim)
>       result = target_rlim_swap;
>       if (target_rlim_swap != (rlim_t)result)
>           return RLIM_INFINITY;
> -
> +
>       return result;
>   }
>   
> @@ -1078,13 +1078,13 @@ static inline abi_ulong host_to_target_rlim(rlim_t rlim)
>   {
>       abi_ulong target_rlim_swap;
>       abi_ulong result;
> -
> +
>       if (rlim == RLIM_INFINITY || rlim != (abi_long)rlim)
>           target_rlim_swap = TARGET_RLIM_INFINITY;
>       else
>           target_rlim_swap = rlim;
>       result = tswapal(target_rlim_swap);
> -
> +
>       return result;
>   }
>   
> @@ -1526,10 +1526,11 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
>       abi_ulong target_cmsg_addr;
>       struct target_cmsghdr *target_cmsg, *target_cmsg_start;
>       socklen_t space = 0;
> -
> +
>       msg_controllen = tswapal(target_msgh->msg_controllen);
> -    if (msg_controllen < sizeof (struct target_cmsghdr))
> +    if (msg_controllen < sizeof(struct target_cmsghdr)) {
>           goto the_end;
> +    }
>       target_cmsg_addr = tswapal(target_msgh->msg_control);
>       target_cmsg = lock_user(VERIFY_READ, target_cmsg_addr, msg_controllen, 1);
>       target_cmsg_start = target_cmsg;
> @@ -1610,8 +1611,9 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
>       socklen_t space = 0;
>   
>       msg_controllen = tswapal(target_msgh->msg_controllen);
> -    if (msg_controllen < sizeof (struct target_cmsghdr))
> +    if (msg_controllen < sizeof(struct target_cmsghdr)) {
>           goto the_end;
> +    }
>       target_cmsg_addr = tswapal(target_msgh->msg_control);
>       target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
>       target_cmsg_start = target_cmsg;
> @@ -5592,9 +5594,9 @@ abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr)
>       }
>       unlock_user_struct(target_ldt_info, ptr, 1);
>   
> -    if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN ||
> +    if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN ||
>           ldt_info.entry_number > TARGET_GDT_ENTRY_TLS_MAX)
> -           return -TARGET_EINVAL;
> +        return -TARGET_EINVAL;
>       seg_32bit = ldt_info.flags & 1;
>       contents = (ldt_info.flags >> 1) & 3;
>       read_exec_only = (ldt_info.flags >> 3) & 1;
> @@ -5670,7 +5672,7 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)
>       lp = (uint32_t *)(gdt_table + idx);
>       entry_1 = tswap32(lp[0]);
>       entry_2 = tswap32(lp[1]);
> -
> +
>       read_exec_only = ((entry_2 >> 9) & 1) ^ 1;
>       contents = (entry_2 >> 10) & 3;
>       seg_not_present = ((entry_2 >> 15) & 1) ^ 1;
> @@ -5686,8 +5688,8 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)
>           (read_exec_only << 3) | (limit_in_pages << 4) |
>           (seg_not_present << 5) | (useable << 6) | (lm << 7);
>       limit = (entry_1 & 0xffff) | (entry_2  & 0xf0000);
> -    base_addr = (entry_1 >> 16) |
> -        (entry_2 & 0xff000000) |
> +    base_addr = (entry_1 >> 16) |
> +        (entry_2 & 0xff000000) |
>           ((entry_2 & 0xff) << 16);
>       target_ldt_info->base_addr = tswapal(base_addr);
>       target_ldt_info->limit = tswap32(limit);
> @@ -10554,8 +10556,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>           return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
>   #if defined(TARGET_NR_fchownat)
>       case TARGET_NR_fchownat:
> -        if (!(p = lock_user_string(arg2)))
> +        p = lock_user_string(arg2);
> +        if (!p) {
>               return -TARGET_EFAULT;
> +        }
>           ret = get_errno(fchownat(arg1, p, low2highuid(arg3),
>                                    low2highgid(arg4), arg5));
>           unlock_user(p, arg2, 0);
> 



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-07  6:16     ` Kevin Wolf
@ 2020-01-07  7:06       ` Philippe Mathieu-Daudé
  2020-01-09 19:19         ` Daniel Henrique Barboza
  2020-01-07 11:52       ` Daniel Henrique Barboza
  1 sibling, 1 reply; 113+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-07  7:06 UTC (permalink / raw)
  To: Kevin Wolf, Daniel Henrique Barboza, minyard; +Cc: qemu-trivial, qemu-devel

On 1/7/20 7:16 AM, Kevin Wolf wrote:
> Am 06.01.2020 um 21:35 hat Daniel Henrique Barboza geschrieben:
>> On 1/6/20 4:54 PM, Corey Minyard wrote:
>>> On Mon, Jan 06, 2020 at 03:23:26PM -0300, Daniel Henrique Barboza wrote:
>>>> Hello,
>> [...]
>>>>
>>>> Which is cleaner and requires less brain cycles to wonder
>>>> whether the 'cleanup' label does anything special, such
>>>> as a heap memory cleanup.
>>>
>>> I would disagree with this analysis.  To me, I often wonder
>>> when I have to add cleanup code to a routine whether there is
>>> some hidden return in the middle of the function.  That's a lot
>>> harder to spot than just looking for the cleanup label at the
>>> end of the function to see what it does.  For non-trivial
>>> functions I prefer to have one point of return at the end
>>> (and maybe some minor checks with returns right at the beginning).
>>> I'm not adamant about this, just my opinion.
> 
> It depends on the case, but yes, I had similar thoughts, at least when
> we're talking about non-trivial parts of a function. (Very short
> functions of just some initial checks returning directly are usually
> fine.)

 From a debugging point of view, and when adding trace-events, it is 
easier to have a single function exit path.

In various functions modified by your patches, we can split big 
functions in smaller ones and avoid the goto label.



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

* RE: [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start
  2020-01-06 18:23 ` [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start Daniel Henrique Barboza
  2020-01-07  6:53   ` Philippe Mathieu-Daudé
@ 2020-01-07  8:18   ` Gonglei (Arei)
  1 sibling, 0 replies; 113+ messages in thread
From: Gonglei (Arei) @ 2020-01-07  8:18 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial


> -----Original Message-----
> From: Daniel Henrique Barboza [mailto:danielhb413@gmail.com]
> Sent: Tuesday, January 7, 2020 2:24 AM
> To: qemu-devel@nongnu.org
> Cc: qemu-trivial@nongnu.org; Daniel Henrique Barboza
> <danielhb413@gmail.com>; Gonglei (Arei) <arei.gonglei@huawei.com>
> Subject: [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in
> cryptodev_vhost_start
> 
> 'err' can be replaced by 'return r'.
> 
> CC: Gonglei <arei.gonglei@huawei.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  backends/cryptodev-vhost.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Gonglei <arei.gonglei@huawei.com>


> diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index
> 8337c9a495..907ca21fa7 100644
> --- a/backends/cryptodev-vhost.c
> +++ b/backends/cryptodev-vhost.c
> @@ -201,7 +201,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int
> total_queues)
>      r = k->set_guest_notifiers(qbus->parent, total_queues, true);
>      if (r < 0) {
>          error_report("error binding guest notifier: %d", -r);
> -        goto err;
> +        return r;
>      }
> 
>      for (i = 0; i < total_queues; i++) { @@ -236,7 +236,7 @@ err_start:
>      if (e < 0) {
>          error_report("vhost guest notifier cleanup failed: %d", e);
>      }
> -err:
> +
>      return r;
>  }
> 
> --
> 2.24.1



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (59 preceding siblings ...)
  2020-01-06 19:54 ` [PATCH v1 00/59] trivial unneeded labels cleanup Corey Minyard
@ 2020-01-07  9:43 ` Max Reitz
  2020-01-09 20:16   ` Daniel Henrique Barboza
  2020-01-10 19:05 ` Eric Blake
  61 siblings, 1 reply; 113+ messages in thread
From: Max Reitz @ 2020-01-07  9:43 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial


[-- Attachment #1.1: Type: text/plain, Size: 1890 bytes --]

On 06.01.20 19:23, Daniel Henrique Barboza wrote:
> Hello,
> 
> This is the type of cleanup I've contributed to Libvirt
> during the last year. Figured QEMU also deserves the same
> care.
> 
> The idea here is remove unneeded labels. By 'unneeded' I
> mean labels that does nothing but a 'return' call. One
> common case is something like this:
> 
> if ()
>     goto cleanup;
> [...]
>  cleanup:
>     return 0;
> 
> This code can be simplified to:
> 
> if ()
>     return 0;
> 
> 
> Which is cleaner and requires less brain cycles to wonder
> whether the 'cleanup' label does anything special, such
> as a heap memory cleanup.

For me, it doesn’t require any brain cycles, because I generally just
assume the cleanup label will do the right thing.  OTOH, a return
statement may make me invest some some brain cycles, because maybe there
is something to be cleaned up and it isn’t done here.

> Another common case uses a variable to set a return value,
> generally an error, then return:
> 
> if () {
>     ret = -ENOENT;
>     goto out;
> }
> [..]
>  out:
>     return ret;
> 
> Likewise, it is clearer to just 'return -ENOENT' instead of
> jumping to a label. There are other cases being handled in
> these patches, but these are the most common.

I find it clearer from the perspective of “less LoC”, but I find it less
clear from the perspective of “Is this the right way to clean up?”.

Even on patch 15 (which you say isn’t too much of a debate), I don’t
find the change to make things any clearer.  Just less verbose.

I suppose none of this would matter if we used __attribute__((cleanup))
everywhere and simply never had to clean up anything manually.  But as
long as we don’t and require cleanup paths in many places, I disagree
that they require more brain cycles than plain return statements.

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  2020-01-06 18:23 ` [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid() Daniel Henrique Barboza
@ 2020-01-07  9:51   ` Greg Kurz
  2020-01-13 15:15     ` Markus Armbruster
  0 siblings, 1 reply; 113+ messages in thread
From: Greg Kurz @ 2020-01-07  9:51 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel

On Mon,  6 Jan 2020 15:23:38 -0300
Daniel Henrique Barboza <danielhb413@gmail.com> wrote:

> 'err_out' can be removed and be replaced by 'return -errno'
> in its only instance in the function.
> 
> CC: Greg Kurz <groug@kaod.org>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---

I don't really mind, but I confirm this doesn't change behavior.

Acked-by: Greg Kurz <groug@kaod.org>

What's the plan to get this and the other 9p related patches merged ?
Through the trivial tree or each subsystem tree ?

>  fsdev/virtfs-proxy-helper.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
> index 0d4de49dcf..aa1ab2590d 100644
> --- a/fsdev/virtfs-proxy-helper.c
> +++ b/fsdev/virtfs-proxy-helper.c
> @@ -287,8 +287,7 @@ static int setugid(int uid, int gid, int *suid, int *sgid)
>      *sgid = getegid();
>  
>      if (setresgid(-1, gid, *sgid) == -1) {
> -        retval = -errno;
> -        goto err_out;
> +        return -errno;
>      }
>  
>      if (setresuid(-1, uid, *suid) == -1) {
> @@ -322,7 +321,6 @@ err_sgid:
>      if (setresgid(-1, *sgid, *sgid) == -1) {
>          abort();
>      }
> -err_out:
>      return retval;
>  }
>  



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

* Re: [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style
  2020-01-06 18:24 ` [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style Daniel Henrique Barboza
  2020-01-07  6:57   ` Philippe Mathieu-Daudé
@ 2020-01-07 10:37   ` Peter Maydell
  1 sibling, 0 replies; 113+ messages in thread
From: Peter Maydell @ 2020-01-07 10:37 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: QEMU Trivial, Riku Voipio, QEMU Developers, Laurent Vivier

On Mon, 6 Jan 2020 at 19:19, Daniel Henrique Barboza
<danielhb413@gmail.com> wrote:
>
> There are trailing whitespaces in this file that, if removed
> by a text editor that refuses to let the traiing whitespace
> alone, which happens to be the editor I am using, will cause
> checkpatch.pl to warn about styling problems in the resulting
> patch. This happens because the trailing whitespace lines
> are using a deprecated style.

You should fix your editor to not do this kind of uncommanded edit
(otherwise you'll be spending forever trying to sort out
unasked for changes from patches you write) but the style cleanup
here is reasonable.

> To keep the intended change I wanted to do (remove unneeded
> labels in do_ioctl_blkpg() and do_sendrecvmsg_locked())
> trivial, this patch is another trivial change to fix the
> trailing whitespaces and the code style errors that
> checkpatch.pl warns about. Doing this change beforehand will
> keep the next patch focused just on the label removal changes.

> @@ -1526,10 +1526,11 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
>      abi_ulong target_cmsg_addr;
>      struct target_cmsghdr *target_cmsg, *target_cmsg_start;
>      socklen_t space = 0;
> -
> +
>      msg_controllen = tswapal(target_msgh->msg_controllen);
> -    if (msg_controllen < sizeof (struct target_cmsghdr))
> +    if (msg_controllen < sizeof(struct target_cmsghdr)) {
>          goto the_end;
> +    }
>      target_cmsg_addr = tswapal(target_msgh->msg_control);
>      target_cmsg = lock_user(VERIFY_READ, target_cmsg_addr, msg_controllen, 1);
>      target_cmsg_start = target_cmsg;
> @@ -1610,8 +1611,9 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
>      socklen_t space = 0;
>
>      msg_controllen = tswapal(target_msgh->msg_controllen);
> -    if (msg_controllen < sizeof (struct target_cmsghdr))
> +    if (msg_controllen < sizeof(struct target_cmsghdr)) {
>          goto the_end;
> +    }
>      target_cmsg_addr = tswapal(target_msgh->msg_control);
>      target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
>      target_cmsg_start = target_cmsg;
> @@ -5592,9 +5594,9 @@ abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr)
>      }
>      unlock_user_struct(target_ldt_info, ptr, 1);
>
> -    if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN ||
> +    if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN ||
>          ldt_info.entry_number > TARGET_GDT_ENTRY_TLS_MAX)
> -           return -TARGET_EINVAL;
> +        return -TARGET_EINVAL;
>      seg_32bit = ldt_info.flags & 1;
>      contents = (ldt_info.flags >> 1) & 3;
>      read_exec_only = (ldt_info.flags >> 3) & 1;

Doesn't checkpatch complain about not having braces on this if ?

Either way
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM


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

* Re: [PATCH v1 30/59] util/module.c: remove unneeded label in module_load_file()
  2020-01-06 18:23 ` [PATCH v1 30/59] util/module.c: remove unneeded label in module_load_file() Daniel Henrique Barboza
@ 2020-01-07 11:26   ` Thomas Huth
  0 siblings, 0 replies; 113+ messages in thread
From: Thomas Huth @ 2020-01-07 11:26 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial, Paolo Bonzini

On 06/01/2020 19.23, Daniel Henrique Barboza wrote:
> 'out' can be replaced by the apropriate return values set
> in 'ret' for each case.
> 
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  util/module.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/util/module.c b/util/module.c
> index e9fe3e5422..9b5453f878 100644
> --- a/util/module.c
> +++ b/util/module.c
> @@ -111,12 +111,10 @@ static int module_load_file(const char *fname)
>  
>      if (len <= suf_len || strcmp(&fname[len - suf_len], dsosuf)) {
>          /* wrong suffix */
> -        ret = -EINVAL;
> -        goto out;
> +        return -EINVAL;
>      }
>      if (access(fname, F_OK)) {
> -        ret = -ENOENT;
> -        goto out;
> +        return -ENOENT;
>      }
>  
>      assert(QTAILQ_EMPTY(&dso_init_list));
> @@ -125,8 +123,7 @@ static int module_load_file(const char *fname)
>      if (!g_module) {
>          fprintf(stderr, "Failed to open module: %s\n",
>                  g_module_error());
> -        ret = -EINVAL;
> -        goto out;
> +        return -EINVAL;
>      }
>      if (!g_module_symbol(g_module, DSO_STAMP_FUN_STR, (gpointer *)&sym)) {
>          fprintf(stderr, "Failed to initialize module: %s\n",
> @@ -151,7 +148,7 @@ static int module_load_file(const char *fname)
>          QTAILQ_REMOVE(&dso_init_list, e, node);
>          g_free(e);
>      }
> -out:
> +
>      return ret;
>  }
>  #endif
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-07  6:16     ` Kevin Wolf
  2020-01-07  7:06       ` Philippe Mathieu-Daudé
@ 2020-01-07 11:52       ` Daniel Henrique Barboza
  2020-01-07 12:21         ` Kevin Wolf
  1 sibling, 1 reply; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-07 11:52 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-trivial, qemu-devel, minyard, Laurent Vivier



On 1/7/20 3:16 AM, Kevin Wolf wrote:
> Am 06.01.2020 um 21:35 hat Daniel Henrique Barboza geschrieben:
>>

[...]

> 
> So what is your plan for getting the series merged? Should maintainers
> just picks patches from the series, or do you want to collect Acked-by
> tags and then merge it through a single tree? If the latter, which one?

The idea I had in mind was for each maintainer to pick up the patches and push
through their own trees, like David did in patches 1 and 2.

 From qemu-trivial archives I notice that Laurent creates qemu-trivial pull
requests often, thus I believe this might also be an option. If we decide
to go this route I'll ask David to remove patches 1 and 2 from his ppc
tree to avoid unnecessary conflicts.



Thanks,


DHB


> 
> Kevin
> 


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

* Re: [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common()
  2020-01-06 18:24 ` [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common() Daniel Henrique Barboza
@ 2020-01-07 12:04   ` Christian Schoenebeck
  2020-01-07 13:58     ` Greg Kurz
  2020-01-07 13:53   ` Greg Kurz
  1 sibling, 1 reply; 113+ messages in thread
From: Christian Schoenebeck @ 2020-01-07 12:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel Henrique Barboza, qemu-trivial, Greg Kurz

On Montag, 6. Januar 2020 19:24:10 CET Daniel Henrique Barboza wrote:
> 'err_out' can be replaced by 'return ret' in the error conditions
> the jump was being made.
> 
> CC: Greg Kurz <groug@kaod.org>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/9pfs/9p-local.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index ca641390fb..f9bdd2ad7c 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -1094,12 +1094,12 @@ static int local_unlinkat_common(FsContext *ctx, int
> dirfd, const char *name,
> 
>              fd = openat_dir(dirfd, name);
>              if (fd == -1) {
> -                goto err_out;
> +                return ret;
>              }
>              ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
>              close_preserve_errno(fd);
>              if (ret < 0 && errno != ENOENT) {
> -                goto err_out;
> +                return ret;
>              }
>          }
>          map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
> @@ -1107,16 +1107,14 @@ static int local_unlinkat_common(FsContext *ctx, int
> dirfd, const char *name, ret = unlinkat(map_dirfd, name, 0);
>              close_preserve_errno(map_dirfd);
>              if (ret < 0 && errno != ENOENT) {
> -                goto err_out;
> +                return ret;
>              }
>          } else if (errno != ENOENT) {
> -            goto err_out;
> +            return ret;
>          }
>      }
> 
> -    ret = unlinkat(dirfd, name, flags);
> -err_out:
> -    return ret;
> +    return unlinkat(dirfd, name, flags);
>  }
> 
>  static int local_remove(FsContext *ctx, const char *path)

Well, personally I don't see any improvement by these changes. It probably 
makes the code slightly more elegant, but IMO not more readable. And return 
constructed functions vs. jump to label constructed functions are more likely 
to gather missing-cleanup bugs.

At least this patch does not cause any behaviour change, so I leave that up to 
you Greg to decide. ;-)

Best regards,
Christian Schoenebeck




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

* Re: [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels
  2020-01-06 18:24 ` [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-07 12:14   ` Christian Schoenebeck
  2020-01-08 14:08     ` Greg Kurz
  0 siblings, 1 reply; 113+ messages in thread
From: Christian Schoenebeck @ 2020-01-07 12:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel Henrique Barboza, qemu-trivial, Greg Kurz

On Montag, 6. Januar 2020 19:24:11 CET Daniel Henrique Barboza wrote:
> 'out' label in v9fs_xattr_write() and 'out_nofid' label in
> v9fs_complete_rename() can be replaced by appropriate return
> calls.
> 
> CC: Greg Kurz <groug@kaod.org>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/9pfs/9p.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index 520177f40c..be2beba4cd 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -2464,8 +2464,7 @@ static int v9fs_xattr_write(V9fsState *s, V9fsPDU
> *pdu, V9fsFidState *fidp,
> 
> 
>      if (fidp->fs.xattr.len < off) {
> -        err = -ENOSPC;
> -        goto out;
> +        return -ENOSPC;
>      }
>      write_count = fidp->fs.xattr.len - off;
>      if (write_count > count) {
> @@ -2491,7 +2490,7 @@ static int v9fs_xattr_write(V9fsState *s, V9fsPDU
> *pdu, V9fsFidState *fidp, off += to_copy;
>          write_count -= to_copy;
>      }
> -out:
> +
>      return err;
>  }
> 
> @@ -3056,8 +3055,7 @@ static int coroutine_fn v9fs_complete_rename(V9fsPDU
> *pdu, V9fsFidState *fidp, if (newdirfid != -1) {
>          dirfidp = get_fid(pdu, newdirfid);
>          if (dirfidp == NULL) {
> -            err = -ENOENT;
> -            goto out_nofid;
> +            return -ENOENT;
>          }
>          if (fidp->fid_type != P9_FID_NONE) {
>              err = -EINVAL;
> @@ -3100,7 +3098,6 @@ out:
>          put_fid(pdu, dirfidp);
>      }
>      v9fs_path_free(&new_path);
> -out_nofid:
>      return err;
>  }

Same as with patch 44: IMO not any improvement, but also not any behaviour 
change at least. So it's up to you Greg.

Best regards,
Christian Schoenebeck




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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-07 11:52       ` Daniel Henrique Barboza
@ 2020-01-07 12:21         ` Kevin Wolf
  0 siblings, 0 replies; 113+ messages in thread
From: Kevin Wolf @ 2020-01-07 12:21 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, minyard, Laurent Vivier

Am 07.01.2020 um 12:52 hat Daniel Henrique Barboza geschrieben:
> > So what is your plan for getting the series merged? Should maintainers
> > just picks patches from the series, or do you want to collect Acked-by
> > tags and then merge it through a single tree? If the latter, which one?
> 
> The idea I had in mind was for each maintainer to pick up the patches and push
> through their own trees, like David did in patches 1 and 2.

Okay, thanks.

> From qemu-trivial archives I notice that Laurent creates qemu-trivial pull
> requests often, thus I believe this might also be an option. If we decide
> to go this route I'll ask David to remove patches 1 and 2 from his ppc
> tree to avoid unnecessary conflicts.

Two trees picking up the same patch doesn't result in a conflict, git
can resolve this just fine. It only gets problematic if different
versions of a patch are picked up.

Kevin



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

* Re: [PATCH v1 31/59] util/aio-posix.c: remove unneeded 'out' label in aio_epoll
  2020-01-06 18:23 ` [PATCH v1 31/59] util/aio-posix.c: remove unneeded 'out' label in aio_epoll Daniel Henrique Barboza
@ 2020-01-07 13:34   ` Thomas Huth
  0 siblings, 0 replies; 113+ messages in thread
From: Thomas Huth @ 2020-01-07 13:34 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial, Paolo Bonzini

On 06/01/2020 19.23, Daniel Henrique Barboza wrote:
> 'out' can be replaced by 'return ret'.
> 
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  util/aio-posix.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/util/aio-posix.c b/util/aio-posix.c
> index a4977f538e..7c4cfea8ce 100644
> --- a/util/aio-posix.c
> +++ b/util/aio-posix.c
> @@ -121,7 +121,7 @@ static int aio_epoll(AioContext *ctx, GPollFD *pfds,
>                           ARRAY_SIZE(events),
>                           timeout);
>          if (ret <= 0) {
> -            goto out;
> +            return ret;
>          }
>          for (i = 0; i < ret; i++) {
>              int ev = events[i].events;
> @@ -132,7 +132,6 @@ static int aio_epoll(AioContext *ctx, GPollFD *pfds,
>                  (ev & EPOLLERR ? G_IO_ERR : 0);
>          }
>      }
> -out:
>      return ret;
>  }

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels
  2020-01-06 18:24 ` [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-07 13:36   ` Thomas Huth
  2020-01-08 12:46   ` Cornelia Huck
  1 sibling, 0 replies; 113+ messages in thread
From: Thomas Huth @ 2020-01-07 13:36 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, Cornelia Huck,
	Christian Borntraeger

On 06/01/2020 19.24, Daniel Henrique Barboza wrote:
> 'out' label from write_event_mask(), handle_sccb_read_events()
> and write_event_data() can be replaced by 'return'.
> 
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/s390x/event-facility.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index 6afe278cad..f3b9661f32 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -182,11 +182,11 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb)
>  {
>      if (sccb->h.function_code != SCLP_FC_NORMAL_WRITE) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
> -        goto out;
> +        return;
>      }
>      if (be16_to_cpu(sccb->h.length) < 8) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
> -        goto out;
> +        return;
>      }
>      /* first do a sanity check of the write events */
>      sccb->h.response_code = cpu_to_be16(write_event_length_check(sccb));
> @@ -196,9 +196,6 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb)
>          sccb->h.response_code =
>                  cpu_to_be16(handle_sccb_write_events(ef, sccb));
>      }
> -
> -out:
> -    return;
>  }
>  
>  static uint16_t handle_sccb_read_events(SCLPEventFacility *ef, SCCB *sccb,
> @@ -262,7 +259,7 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
>  
>      if (be16_to_cpu(sccb->h.length) != SCCB_SIZE) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
> -        goto out;
> +        return;
>      }
>  
>      sclp_cp_receive_mask = ef->receive_mask;
> @@ -280,18 +277,15 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
>              (sclp_active_selection_mask & ~sclp_cp_receive_mask)) {
>              sccb->h.response_code =
>                      cpu_to_be16(SCLP_RC_INVALID_SELECTION_MASK);
> -            goto out;
> +            return;
>          }
>          break;
>      default:
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
> -        goto out;
> +        return;
>      }
>      sccb->h.response_code = cpu_to_be16(
>              handle_sccb_read_events(ef, sccb, sclp_active_selection_mask));
> -
> -out:
> -    return;
>  }
>  
>  static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
> @@ -303,7 +297,7 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
>      if (!mask_length || (mask_length > SCLP_EVENT_MASK_LEN_MAX) ||
>          ((mask_length != 4) && !ef->allow_all_mask_sizes)) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_MASK_LENGTH);
> -        goto out;
> +        return;
>      }
>  
>      /*
> @@ -328,9 +322,6 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
>  
>      sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_COMPLETION);
>      ef->mask_length = mask_length;
> -
> -out:
> -    return;
>  }
>  
>  /* qemu object creation and initialization functions */
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call()
  2020-01-06 18:24 ` [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call() Daniel Henrique Barboza
@ 2020-01-07 13:37   ` Thomas Huth
  2020-01-08 13:16   ` Cornelia Huck
  1 sibling, 0 replies; 113+ messages in thread
From: Thomas Huth @ 2020-01-07 13:37 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel, Cornelia Huck
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, Christian Borntraeger

On 06/01/2020 19.24, Daniel Henrique Barboza wrote:
> 'out' label can be replaced by 'return' with the appropriate
> value. The 'r' integer, which is used solely to set the
> return value for this label, can also be removed.
> 
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/s390x/sclp.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index f57ce7b739..af0bfbc2ec 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -197,24 +197,20 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
>  {
>      SCLPDevice *sclp = get_sclp_device();
>      SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
> -    int r = 0;
>      SCCB work_sccb;
>  
>      hwaddr sccb_len = sizeof(SCCB);
>  
>      /* first some basic checks on program checks */
>      if (env->psw.mask & PSW_MASK_PSTATE) {
> -        r = -PGM_PRIVILEGED;
> -        goto out;
> +        return -PGM_PRIVILEGED;
>      }
>      if (cpu_physical_memory_is_io(sccb)) {
> -        r = -PGM_ADDRESSING;
> -        goto out;
> +        return -PGM_ADDRESSING;
>      }
>      if ((sccb & ~0x1fffUL) == 0 || (sccb & ~0x1fffUL) == env->psa
>          || (sccb & ~0x7ffffff8UL) != 0) {
> -        r = -PGM_SPECIFICATION;
> -        goto out;
> +        return -PGM_SPECIFICATION;
>      }
>  
>      /*
> @@ -226,8 +222,7 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
>  
>      /* Valid sccb sizes */
>      if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader)) {
> -        r = -PGM_SPECIFICATION;
> -        goto out;
> +        return -PGM_SPECIFICATION;
>      }
>  
>      switch (code & SCLP_CMD_CODE_MASK) {
> @@ -257,8 +252,7 @@ out_write:
>  
>      sclp_c->service_interrupt(sclp, sccb);
>  
> -out:
> -    return r;
> +    return 0;
>  }
>  
>  static void service_interrupt(SCLPDevice *sclp, uint32_t sccb)
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common()
  2020-01-06 18:24 ` [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common() Daniel Henrique Barboza
  2020-01-07 12:04   ` Christian Schoenebeck
@ 2020-01-07 13:53   ` Greg Kurz
  2020-01-07 14:16     ` Daniel Henrique Barboza
  1 sibling, 1 reply; 113+ messages in thread
From: Greg Kurz @ 2020-01-07 13:53 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel

On Mon,  6 Jan 2020 15:24:10 -0300
Daniel Henrique Barboza <danielhb413@gmail.com> wrote:

> 'err_out' can be replaced by 'return ret' in the error conditions
> the jump was being made.
> 
> CC: Greg Kurz <groug@kaod.org>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/9pfs/9p-local.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index ca641390fb..f9bdd2ad7c 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -1094,12 +1094,12 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
>  
>              fd = openat_dir(dirfd, name);
>              if (fd == -1) {
> -                goto err_out;
> +                return ret;
>              }
>              ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
>              close_preserve_errno(fd);
>              if (ret < 0 && errno != ENOENT) {
> -                goto err_out;
> +                return ret;
>              }
>          }
>          map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
> @@ -1107,16 +1107,14 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
>              ret = unlinkat(map_dirfd, name, 0);
>              close_preserve_errno(map_dirfd);
>              if (ret < 0 && errno != ENOENT) {
> -                goto err_out;
> +                return ret;
>              }
>          } else if (errno != ENOENT) {
> -            goto err_out;
> +            return ret;

Ouch... I now realize we can get there with ret == 0 when unlinking a
directory in mapped-file mode. The function will wrongly return success
despite the failure.... Since this function is supposed to return -1
on error, I suggest to do that instead of return ret, and to drop the
initialization of ret to -1, which wouldn't be needed anymore.

Since this would fix a bug it makes sense to post it separately from
this series. Rewrite the title/changelog accordingly and I'll merge
it via the 9p tree.

>          }
>      }
>  
> -    ret = unlinkat(dirfd, name, flags);
> -err_out:
> -    return ret;
> +    return unlinkat(dirfd, name, flags);
>  }
>  
>  static int local_remove(FsContext *ctx, const char *path)



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

* Re: [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common()
  2020-01-07 12:04   ` Christian Schoenebeck
@ 2020-01-07 13:58     ` Greg Kurz
  0 siblings, 0 replies; 113+ messages in thread
From: Greg Kurz @ 2020-01-07 13:58 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-devel

On Tue, 07 Jan 2020 13:04:20 +0100
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> On Montag, 6. Januar 2020 19:24:10 CET Daniel Henrique Barboza wrote:
> > 'err_out' can be replaced by 'return ret' in the error conditions
> > the jump was being made.
> > 
> > CC: Greg Kurz <groug@kaod.org>
> > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> > ---
> >  hw/9pfs/9p-local.c | 12 +++++-------
> >  1 file changed, 5 insertions(+), 7 deletions(-)
> > 
> > diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> > index ca641390fb..f9bdd2ad7c 100644
> > --- a/hw/9pfs/9p-local.c
> > +++ b/hw/9pfs/9p-local.c
> > @@ -1094,12 +1094,12 @@ static int local_unlinkat_common(FsContext *ctx, int
> > dirfd, const char *name,
> > 
> >              fd = openat_dir(dirfd, name);
> >              if (fd == -1) {
> > -                goto err_out;
> > +                return ret;
> >              }
> >              ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
> >              close_preserve_errno(fd);
> >              if (ret < 0 && errno != ENOENT) {
> > -                goto err_out;
> > +                return ret;
> >              }
> >          }
> >          map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
> > @@ -1107,16 +1107,14 @@ static int local_unlinkat_common(FsContext *ctx, int
> > dirfd, const char *name, ret = unlinkat(map_dirfd, name, 0);
> >              close_preserve_errno(map_dirfd);
> >              if (ret < 0 && errno != ENOENT) {
> > -                goto err_out;
> > +                return ret;
> >              }
> >          } else if (errno != ENOENT) {
> > -            goto err_out;
> > +            return ret;
> >          }
> >      }
> > 
> > -    ret = unlinkat(dirfd, name, flags);
> > -err_out:
> > -    return ret;
> > +    return unlinkat(dirfd, name, flags);
> >  }
> > 
> >  static int local_remove(FsContext *ctx, const char *path)
> 
> Well, personally I don't see any improvement by these changes. It probably 
> makes the code slightly more elegant, but IMO not more readable. And return 
> constructed functions vs. jump to label constructed functions are more likely 
> to gather missing-cleanup bugs.
> 
> At least this patch does not cause any behaviour change, so I leave that up to 
> you Greg to decide. ;-)
> 

I don't care that much but in the present case, the function has a bug that
can be fixed with a variant of this patch if 'goto err_out' is turned into
'return -1'. I've hence asked Daniel to move this patch out of the series and
to turn it into a real fix that I'll merge directly.

> Best regards,
> Christian Schoenebeck
> 
> 



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

* Re: [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common()
  2020-01-07 13:53   ` Greg Kurz
@ 2020-01-07 14:16     ` Daniel Henrique Barboza
  0 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-07 14:16 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-trivial, qemu-devel



On 1/7/20 10:53 AM, Greg Kurz wrote:
> On Mon,  6 Jan 2020 15:24:10 -0300
> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
> 
>> 'err_out' can be replaced by 'return ret' in the error conditions
>> the jump was being made.
>>
>> CC: Greg Kurz <groug@kaod.org>
>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>> ---
>>   hw/9pfs/9p-local.c | 12 +++++-------
>>   1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
>> index ca641390fb..f9bdd2ad7c 100644
>> --- a/hw/9pfs/9p-local.c
>> +++ b/hw/9pfs/9p-local.c
>> @@ -1094,12 +1094,12 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
>>   
>>               fd = openat_dir(dirfd, name);
>>               if (fd == -1) {
>> -                goto err_out;
>> +                return ret;
>>               }
>>               ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
>>               close_preserve_errno(fd);
>>               if (ret < 0 && errno != ENOENT) {
>> -                goto err_out;
>> +                return ret;
>>               }
>>           }
>>           map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
>> @@ -1107,16 +1107,14 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
>>               ret = unlinkat(map_dirfd, name, 0);
>>               close_preserve_errno(map_dirfd);
>>               if (ret < 0 && errno != ENOENT) {
>> -                goto err_out;
>> +                return ret;
>>               }
>>           } else if (errno != ENOENT) {
>> -            goto err_out;
>> +            return ret;
> 
> Ouch... I now realize we can get there with ret == 0 when unlinking a
> directory in mapped-file mode. The function will wrongly return success
> despite the failure.... Since this function is supposed to return -1
> on error, I suggest to do that instead of return ret, and to drop the
> initialization of ret to -1, which wouldn't be needed anymore.
> 
> Since this would fix a bug it makes sense to post it separately from
> this series. Rewrite the title/changelog accordingly and I'll merge
> it via the 9p tree.


Got it. I'll repost it separately with an updated title and commit msg.


Thanks,


Daniel

> 
>>           }
>>       }
>>   
>> -    ret = unlinkat(dirfd, name, flags);
>> -err_out:
>> -    return ret;
>> +    return unlinkat(dirfd, name, flags);
>>   }
>>   
>>   static int local_remove(FsContext *ctx, const char *path)
> 


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

* Re: [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block()
  2020-01-06 18:23 ` [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block() Daniel Henrique Barboza
@ 2020-01-07 16:54   ` Stefan Hajnoczi
  0 siblings, 0 replies; 113+ messages in thread
From: Stefan Hajnoczi @ 2020-01-07 16:54 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, qemu-block

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

On Mon, Jan 06, 2020 at 03:23:43PM -0300, Daniel Henrique Barboza wrote:
> Both the 'fail' label and 'ret' variable can be removed from the
> function. Instead, call 'return -EINVAL' in the error conditions.
> 
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: qemu-block@nongnu.org
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  block/dmg.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v1 05/59] ram.c: remove unneeded labels
  2020-01-06 18:23 ` [PATCH v1 05/59] ram.c: " Daniel Henrique Barboza
  2020-01-06 18:57   ` Dr. David Alan Gilbert
  2020-01-06 23:38   ` Juan Quintela
@ 2020-01-08 12:41   ` Juan Quintela
  2 siblings, 0 replies; 113+ messages in thread
From: Juan Quintela @ 2020-01-08 12:41 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, Dr . David Alan Gilbert

Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
> ram_save_queue_pages() has an 'err' label that can be replaced by
> 'return -1' instead.
>
> Same thing with ram_discard_range(), and in this case we can also
> get rid of the 'ret' variable and return either '-1' on error
> or the result of ram_block_discard_range().
>
> CC: Juan Quintela <quintela@redhat.com>
> CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

queued



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

* Re: [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels
  2020-01-06 18:24 ` [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels Daniel Henrique Barboza
  2020-01-07 13:36   ` Thomas Huth
@ 2020-01-08 12:46   ` Cornelia Huck
  2020-01-08 14:15     ` Daniel Henrique Barboza
  1 sibling, 1 reply; 113+ messages in thread
From: Cornelia Huck @ 2020-01-08 12:46 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, qemu-devel, Christian Borntraeger

On Mon,  6 Jan 2020 15:24:03 -0300
Daniel Henrique Barboza <danielhb413@gmail.com> wrote:

> 'out' label from write_event_mask(), handle_sccb_read_events()
> and write_event_data() can be replaced by 'return'.
> 
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/s390x/event-facility.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index 6afe278cad..f3b9661f32 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -182,11 +182,11 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb)
>  {
>      if (sccb->h.function_code != SCLP_FC_NORMAL_WRITE) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
> -        goto out;
> +        return;
>      }
>      if (be16_to_cpu(sccb->h.length) < 8) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
> -        goto out;
> +        return;
>      }
>      /* first do a sanity check of the write events */
>      sccb->h.response_code = cpu_to_be16(write_event_length_check(sccb));
> @@ -196,9 +196,6 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb)
>          sccb->h.response_code =
>                  cpu_to_be16(handle_sccb_write_events(ef, sccb));
>      }
> -
> -out:
> -    return;
>  }

I'm fine with the changes to write_event_data().

>  
>  static uint16_t handle_sccb_read_events(SCLPEventFacility *ef, SCCB *sccb,
> @@ -262,7 +259,7 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
>  
>      if (be16_to_cpu(sccb->h.length) != SCCB_SIZE) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
> -        goto out;
> +        return;
>      }
>  
>      sclp_cp_receive_mask = ef->receive_mask;
> @@ -280,18 +277,15 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
>              (sclp_active_selection_mask & ~sclp_cp_receive_mask)) {
>              sccb->h.response_code =
>                      cpu_to_be16(SCLP_RC_INVALID_SELECTION_MASK);
> -            goto out;
> +            return;
>          }
>          break;
>      default:
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
> -        goto out;
> +        return;
>      }
>      sccb->h.response_code = cpu_to_be16(
>              handle_sccb_read_events(ef, sccb, sclp_active_selection_mask));
> -
> -out:
> -    return;
>  }

I think read_event_data() is still a bit confusing, even if we get rid
of the 'out:' label, as the flow remains the same. How about something
like the following, which makes it clear that we handle the sccb events
for unconditional read and for a selective read with a valid mask:

diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 6afe278cad15..877721d6601e 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -262,17 +262,17 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
 
     if (be16_to_cpu(sccb->h.length) != SCCB_SIZE) {
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LENGTH);
-        goto out;
+        return;
     }
 
-    sclp_cp_receive_mask = ef->receive_mask;
-
-    /* get active selection mask */
     switch (sccb->h.function_code) {
     case SCLP_UNCONDITIONAL_READ:
-        sclp_active_selection_mask = sclp_cp_receive_mask;
+        sccb->h.response_code = cpu_to_be16(
+            handle_sccb_read_events(ef, sccb, ef->receive_mask));
         break;
     case SCLP_SELECTIVE_READ:
+        sclp_cp_receive_mask = ef->receive_mask;
+        /* get active selection mask */
         copy_mask((uint8_t *)&sclp_active_selection_mask, (uint8_t *)&red->mask,
                   sizeof(sclp_active_selection_mask), ef->mask_length);
         sclp_active_selection_mask = be64_to_cpu(sclp_active_selection_mask);
@@ -280,18 +280,14 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)
             (sclp_active_selection_mask & ~sclp_cp_receive_mask)) {
             sccb->h.response_code =
                     cpu_to_be16(SCLP_RC_INVALID_SELECTION_MASK);
-            goto out;
+        } else {
+            sccb->h.response_code = cpu_to_be16(
+                handle_sccb_read_events(ef, sccb, sclp_active_selection_mask));
         }
         break;
     default:
         sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_FUNCTION);
-        goto out;
     }
-    sccb->h.response_code = cpu_to_be16(
-            handle_sccb_read_events(ef, sccb, sclp_active_selection_mask));
-
-out:
-    return;
 }
 
 static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)


>  
>  static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
> @@ -303,7 +297,7 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
>      if (!mask_length || (mask_length > SCLP_EVENT_MASK_LEN_MAX) ||
>          ((mask_length != 4) && !ef->allow_all_mask_sizes)) {
>          sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_MASK_LENGTH);
> -        goto out;
> +        return;
>      }
>  
>      /*
> @@ -328,9 +322,6 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)
>  
>      sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_COMPLETION);
>      ef->mask_length = mask_length;
> -
> -out:
> -    return;
>  }
>  
>  /* qemu object creation and initialization functions */

The changes to write_event_mask() look fine to me as well.



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

* Re: [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
  2020-01-06 18:24 ` [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() Daniel Henrique Barboza
@ 2020-01-08 13:00   ` Cornelia Huck
  2020-01-13 16:51     ` Cornelia Huck
  2020-01-13 16:06   ` Thomas Huth
  1 sibling, 1 reply; 113+ messages in thread
From: Cornelia Huck @ 2020-01-08 13:00 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, qemu-devel, Christian Borntraeger

On Mon,  6 Jan 2020 15:24:07 -0300
Daniel Henrique Barboza <danielhb413@gmail.com> wrote:

> 'out' label can be replaced by 'return' with the apropriate
> value that is set by 'r' right before the jump.
> 
> Christian Borntraeger <borntraeger@de.ibm.com>

I think something went wrong here; adding some cc:s.

> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/intc/s390_flic_kvm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
> index dddd33ea61..2e1e70c61d 100644
> --- a/hw/intc/s390_flic_kvm.c
> +++ b/hw/intc/s390_flic_kvm.c
> @@ -439,17 +439,14 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
>      count = qemu_get_be64(f);
>      len = count * sizeof(struct kvm_s390_irq);
>      if (count == FLIC_FAILED) {
> -        r = -EINVAL;
> -        goto out;
> +        return -EINVAL;
>      }
>      if (count == 0) {
> -        r = 0;
> -        goto out;
> +        return 0;
>      }
>      buf = g_try_malloc0(len);
>      if (!buf) {
> -        r = -ENOMEM;
> -        goto out;
> +        return -ENOMEM;
>      }
>  
>      if (qemu_get_buffer(f, (uint8_t *) buf, len) != len) {
> @@ -460,7 +457,6 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
>  
>  out_free:
>      g_free(buf);
> -out:
>      return r;
>  }
>  

Looks fine to me; will apply unless someone sees an issue.



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

* Re: [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call()
  2020-01-06 18:24 ` [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call() Daniel Henrique Barboza
  2020-01-07 13:37   ` Thomas Huth
@ 2020-01-08 13:16   ` Cornelia Huck
  1 sibling, 0 replies; 113+ messages in thread
From: Cornelia Huck @ 2020-01-08 13:16 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, qemu-devel, Christian Borntraeger

On Mon,  6 Jan 2020 15:24:04 -0300
Daniel Henrique Barboza <danielhb413@gmail.com> wrote:

> 'out' label can be replaced by 'return' with the appropriate
> value. The 'r' integer, which is used solely to set the
> return value for this label, can also be removed.
> 
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/s390x/sclp.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)

Thanks, applied.



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

* Re: [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels
  2020-01-07 12:14   ` Christian Schoenebeck
@ 2020-01-08 14:08     ` Greg Kurz
  0 siblings, 0 replies; 113+ messages in thread
From: Greg Kurz @ 2020-01-08 14:08 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-devel

On Tue, 07 Jan 2020 13:14:20 +0100
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> On Montag, 6. Januar 2020 19:24:11 CET Daniel Henrique Barboza wrote:
> > 'out' label in v9fs_xattr_write() and 'out_nofid' label in
> > v9fs_complete_rename() can be replaced by appropriate return
> > calls.
> > 
> > CC: Greg Kurz <groug@kaod.org>
> > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> > ---
> >  hw/9pfs/9p.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index 520177f40c..be2beba4cd 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -2464,8 +2464,7 @@ static int v9fs_xattr_write(V9fsState *s, V9fsPDU
> > *pdu, V9fsFidState *fidp,
> > 
> > 
> >      if (fidp->fs.xattr.len < off) {
> > -        err = -ENOSPC;
> > -        goto out;
> > +        return -ENOSPC;
> >      }
> >      write_count = fidp->fs.xattr.len - off;
> >      if (write_count > count) {
> > @@ -2491,7 +2490,7 @@ static int v9fs_xattr_write(V9fsState *s, V9fsPDU
> > *pdu, V9fsFidState *fidp, off += to_copy;
> >          write_count -= to_copy;
> >      }
> > -out:
> > +
> >      return err;
> >  }
> > 
> > @@ -3056,8 +3055,7 @@ static int coroutine_fn v9fs_complete_rename(V9fsPDU
> > *pdu, V9fsFidState *fidp, if (newdirfid != -1) {
> >          dirfidp = get_fid(pdu, newdirfid);
> >          if (dirfidp == NULL) {
> > -            err = -ENOENT;
> > -            goto out_nofid;
> > +            return -ENOENT;
> >          }
> >          if (fidp->fid_type != P9_FID_NONE) {
> >              err = -EINVAL;
> > @@ -3100,7 +3098,6 @@ out:
> >          put_fid(pdu, dirfidp);
> >      }
> >      v9fs_path_free(&new_path);
> > -out_nofid:
> >      return err;
> >  }
> 
> Same as with patch 44: IMO not any improvement, but also not any behaviour 
> change at least. So it's up to you Greg.
> 

I don't really care either but as you say it doesn't change behaviour, and
and the diffstat is nice :)

Acked-by: Greg Kurz <groug@kaod.org>

> Best regards,
> Christian Schoenebeck
> 
> 



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

* Re: [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels
  2020-01-08 12:46   ` Cornelia Huck
@ 2020-01-08 14:15     ` Daniel Henrique Barboza
  0 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-08 14:15 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, qemu-devel, Christian Borntraeger



On 1/8/20 9:46 AM, Cornelia Huck wrote:
> On Mon,  6 Jan 2020 15:24:03 -0300
> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
> 

[..]

> I think read_event_data() is still a bit confusing, even if we get rid
> of the 'out:' label, as the flow remains the same. How about something
> like the following, which makes it clear that we handle the sccb events
> for unconditional read and for a selective read with a valid mask:

The code reading is better with your suggestion indeed.

I'll re-send this patch with this new read_event_data() flow.


Thanks,


DHB


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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-07  7:06       ` Philippe Mathieu-Daudé
@ 2020-01-09 19:19         ` Daniel Henrique Barboza
  0 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-09 19:19 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Kevin Wolf, minyard; +Cc: qemu-trivial, qemu-devel



On 1/7/20 4:06 AM, Philippe Mathieu-Daudé wrote:
> On 1/7/20 7:16 AM, Kevin Wolf wrote:
>> Am 06.01.2020 um 21:35 hat Daniel Henrique Barboza geschrieben:
>>> On 1/6/20 4:54 PM, Corey Minyard wrote:
>>>> On Mon, Jan 06, 2020 at 03:23:26PM -0300, Daniel Henrique Barboza wrote:
>>>>> Hello,
>>> [...]
>>>>>
>>>>> Which is cleaner and requires less brain cycles to wonder
>>>>> whether the 'cleanup' label does anything special, such
>>>>> as a heap memory cleanup.
>>>>
>>>> I would disagree with this analysis.  To me, I often wonder
>>>> when I have to add cleanup code to a routine whether there is
>>>> some hidden return in the middle of the function.  That's a lot
>>>> harder to spot than just looking for the cleanup label at the
>>>> end of the function to see what it does.  For non-trivial
>>>> functions I prefer to have one point of return at the end
>>>> (and maybe some minor checks with returns right at the beginning).
>>>> I'm not adamant about this, just my opinion.
>>
>> It depends on the case, but yes, I had similar thoughts, at least when
>> we're talking about non-trivial parts of a function. (Very short
>> functions of just some initial checks returning directly are usually
>> fine.)
> 
>  From a debugging point of view, and when adding trace-events, it is easier to have a single function exit path.
> 
> In various functions modified by your patches, we can split big functions in smaller ones and avoid the goto label.
> 

Splitting and refactoring big funcitons wasn't the initial idea of this
work, but I see no problems in doing it. Care to point out where did you
see such cases?


Thanks,


DHB


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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-07  9:43 ` Max Reitz
@ 2020-01-09 20:16   ` Daniel Henrique Barboza
  0 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-09 20:16 UTC (permalink / raw)
  To: Max Reitz, qemu-devel; +Cc: qemu-trivial



On 1/7/20 6:43 AM, Max Reitz wrote:
> On 06.01.20 19:23, Daniel Henrique Barboza wrote:

[...]

  
> For me, it doesn’t require any brain cycles, because I generally just
> assume the cleanup label will do the right thing.  OTOH, a return
> statement may make me invest some some brain cycles, because maybe there
> is something to be cleaned up and it isn’t done here.
> 
>> Another common case uses a variable to set a return value,
>> generally an error, then return:
>>
>> if () {
>>      ret = -ENOENT;
>>      goto out;
>> }
>> [..]
>>   out:
>>      return ret;
>>
>> Likewise, it is clearer to just 'return -ENOENT' instead of
>> jumping to a label. There are other cases being handled in
>> these patches, but these are the most common.
> 
> I find it clearer from the perspective of “less LoC”, but I find it less
> clear from the perspective of “Is this the right way to clean up?”.
> 
> Even on patch 15 (which you say isn’t too much of a debate), I don’t
> find the change to make things any clearer.  Just less verbose.

Fair enough. As I said in the cover, all this patches makes no functional
changes, just a clean up aiming for less LoC (and more clarity, at least
in my opinion).

I am aware all the good sides of keeping the code as is, such as being
easier to debug (although I would argue that an explicit trace_event
call is better than keeping verbose code 'just in case'), or goto usage
to keep just one return statement per function.

I am also aware that the existing QEMU code base has a mesh of styles.
What I'm proposing here isn't a 'my way is better' case by any means,
but it's not something unprecedented in the existing code base either.
Since there's no QEMU code guideline imposing that a function should
have only one 'return' statement regardless of how many 'goto' calls
are needed, or a guideline that discourages 'goto' calls regardless of
how many 'return' calls are needed, in the end it's a matter of seeing
what fits the function/code better. In the maintainers opinion, of
course.


Thanks,


DHB


> 
> I suppose none of this would matter if we used __attribute__((cleanup))
> everywhere and simply never had to clean up anything manually.  But as
> long as we don’t and require cleanup paths in many places, I disagree
> that they require more brain cycles than plain return statements.
> 
> Max
> 


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

* Re: [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting()
  2020-01-06 18:23 ` [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting() Daniel Henrique Barboza
@ 2020-01-09 20:41   ` Aleksandar Markovic
  2020-01-24 17:22   ` Aleksandar Markovic
  1 sibling, 0 replies; 113+ messages in thread
From: Aleksandar Markovic @ 2020-01-09 20:41 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: qemu-trivial, Aurelien Jarno, Aleksandar Rikalo, qemu-devel,
	Aleksandar Markovic

[-- Attachment #1: Type: text/plain, Size: 3598 bytes --]

On Monday, January 6, 2020, Daniel Henrique Barboza <danielhb413@gmail.com>
wrote:

> The label 'uhi_done' is a simple 'return' call and can
> be removed for a bit more clarity in the code.
>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  target/mips/mips-semi.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
>
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>


> diff --git a/target/mips/mips-semi.c b/target/mips/mips-semi.c
> index 35bdfd7c77..10a710c1e8 100644
> --- a/target/mips/mips-semi.c
> +++ b/target/mips/mips-semi.c
> @@ -218,7 +218,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int
> arg_num,
>          if (!p) {                               \
>              gpr[2] = -1;                        \
>              gpr[3] = EFAULT;                    \
> -            goto uhi_done;                      \
> +            return;                             \
>          }                                       \
>      } while (0)
>
> @@ -228,14 +228,14 @@ static int copy_argn_to_target(CPUMIPSState *env,
> int arg_num,
>          if (!p) {                                       \
>              gpr[2] = -1;                                \
>              gpr[3] = EFAULT;                            \
> -            goto uhi_done;                              \
> +            return;                                     \
>          }                                               \
>          p2 = lock_user_string(addr2);                   \
>          if (!p2) {                                      \
>              unlock_user(p, addr, 0);                    \
>              gpr[2] = -1;                                \
>              gpr[3] = EFAULT;                            \
> -            goto uhi_done;                              \
> +            return;                                     \
>          }                                               \
>      } while (0)
>
> @@ -272,7 +272,7 @@ void helper_do_semihosting(CPUMIPSState *env)
>          if (gpr[4] < 3) {
>              /* ignore closing stdin/stdout/stderr */
>              gpr[2] = 0;
> -            goto uhi_done;
> +            return;
>          }
>          gpr[2] = close(gpr[4]);
>          gpr[3] = errno_mips(errno);
> @@ -302,7 +302,7 @@ void helper_do_semihosting(CPUMIPSState *env)
>              gpr[2] = fstat(gpr[4], &sbuf);
>              gpr[3] = errno_mips(errno);
>              if (gpr[2]) {
> -                goto uhi_done;
> +                return;
>              }
>              gpr[2] = copy_stat_to_target(env, &sbuf, gpr[5]);
>              gpr[3] = errno_mips(errno);
> @@ -314,14 +314,14 @@ void helper_do_semihosting(CPUMIPSState *env)
>      case UHI_argnlen:
>          if (gpr[4] >= semihosting_get_argc()) {
>              gpr[2] = -1;
> -            goto uhi_done;
> +            return;
>          }
>          gpr[2] = strlen(semihosting_get_arg(gpr[4]));
>          break;
>      case UHI_argn:
>          if (gpr[4] >= semihosting_get_argc()) {
>              gpr[2] = -1;
> -            goto uhi_done;
> +            return;
>          }
>          gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]);
>          break;
> @@ -369,6 +369,5 @@ void helper_do_semihosting(CPUMIPSState *env)
>          fprintf(stderr, "Unknown UHI operation %d\n", op);
>          abort();
>      }
> -uhi_done:
>      return;
>  }
> --
> 2.24.1
>
>
>

[-- Attachment #2: Type: text/html, Size: 5396 bytes --]

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

* RE: [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open()
  2020-01-06 18:23 ` [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open() Daniel Henrique Barboza
@ 2020-01-10  6:07   ` Pavel Dovgalyuk
  0 siblings, 0 replies; 113+ messages in thread
From: Pavel Dovgalyuk @ 2020-01-10  6:07 UTC (permalink / raw)
  To: 'Daniel Henrique Barboza', qemu-devel
  Cc: qemu-trivial, 'Paolo Bonzini', 'Pavel Dovgalyuk'

> From: Daniel Henrique Barboza [mailto:danielhb413@gmail.com]
> Sent: Monday, January 06, 2020 9:24 PM
> To: qemu-devel@nongnu.org
> Cc: qemu-trivial@nongnu.org; Daniel Henrique Barboza; Pavel Dovgalyuk; Paolo Bonzini
> Subject: [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open()
> 
> Both the 'fail' label and the 'ret' variable can be removed.
> Use 'return -EINVAL' in the error condition and 'return 0' in
> the end of the function.
> 
> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>


Reviewed-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>

> ---
>  block/blkreplay.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blkreplay.c b/block/blkreplay.c
> index c96ac8f4bc..d8c4c311f3 100644
> --- a/block/blkreplay.c
> +++ b/block/blkreplay.c
> @@ -24,23 +24,19 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
>                            Error **errp)
>  {
>      Error *local_err = NULL;
> -    int ret;
> 
>      /* Open the image file */
>      bs->file = bdrv_open_child(NULL, options, "image",
>                                 bs, &child_file, false, &local_err);
>      if (local_err) {
> -        ret = -EINVAL;
>          error_propagate(errp, local_err);
> -        goto fail;
> +        return -EINVAL;
>      }
> 
>      bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
>      bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
> 
> -    ret = 0;
> -fail:
> -    return ret;
> +    return 0;
>  }
> 
>  static int64_t blkreplay_getlength(BlockDriverState *bs)
> --
> 2.24.1



Pavel Dovgalyuk



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
                   ` (60 preceding siblings ...)
  2020-01-07  9:43 ` Max Reitz
@ 2020-01-10 19:05 ` Eric Blake
  2020-01-10 20:31   ` Daniel Henrique Barboza
  61 siblings, 1 reply; 113+ messages in thread
From: Eric Blake @ 2020-01-10 19:05 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial, Markus Armbruster

On 1/6/20 12:23 PM, Daniel Henrique Barboza wrote:
> Hello,
> 
> This is the type of cleanup I've contributed to Libvirt
> during the last year. Figured QEMU also deserves the same
> care.
> 
> The idea here is remove unneeded labels. By 'unneeded' I
> mean labels that does nothing but a 'return' call. One
> common case is something like this:
> 
> if ()
>      goto cleanup;
> [...]
>   cleanup:
>      return 0;
> 
> This code can be simplified to:
> 
> if ()
>      return 0;
> 
> 

How much of this work is done manually, and how much via Coccinelle?


>   qga/commands-win32.c          | 17 ++++---
>   target/mips/mips-semi.c       | 15 +++---
>   target/unicore32/softmmu.c    | 23 +++-------
>   util/aio-posix.c              |  3 +-
>   util/module.c                 | 11 ++---

Hmm, no change to scripts/coccinelle, so presumably all manual :(

If we have a Coccinelle script that performs this transformation, we are 
more likely to be able to catch all places in the tree that would 
benefit (rather than relying on grep calls or other manual inspection), 
and more importantly, we can repeat the effort periodically to fix 
future additions that don't comply with the preferred style as well as 
backport the patch by rerunning the Coccinelle script with less worry of 
changed context.  Automated cleanups are always going to be easier to 
swallow (even if the diffstat is larger) than manual ad hoc cleanups.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-10 19:05 ` Eric Blake
@ 2020-01-10 20:31   ` Daniel Henrique Barboza
  0 siblings, 0 replies; 113+ messages in thread
From: Daniel Henrique Barboza @ 2020-01-10 20:31 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: qemu-trivial, Markus Armbruster



On 1/10/20 4:05 PM, Eric Blake wrote:
> On 1/6/20 12:23 PM, Daniel Henrique Barboza wrote:
>> Hello,
>>
>> This is the type of cleanup I've contributed to Libvirt
>> during the last year. Figured QEMU also deserves the same
>> care.
>>
>> The idea here is remove unneeded labels. By 'unneeded' I
>> mean labels that does nothing but a 'return' call. One
>> common case is something like this:
>>
>> if ()
>>      goto cleanup;
>> [...]
>>   cleanup:
>>      return 0;
>>
>> This code can be simplified to:
>>
>> if ()
>>      return 0;
>>
>>
> 
> How much of this work is done manually, and how much via Coccinelle?


I'm still getting along with Coccinelle. I'm able to do simple matches but
couldn't make it work to match this scenario. I didn't invest too much
time on it though.


> 
> 
>>   qga/commands-win32.c          | 17 ++++---
>>   target/mips/mips-semi.c       | 15 +++---
>>   target/unicore32/softmmu.c    | 23 +++-------
>>   util/aio-posix.c              |  3 +-
>>   util/module.c                 | 11 ++---
> 
> Hmm, no change to scripts/coccinelle, so presumably all manual :(

I used pcregrep:

$ pcregrep --exclude-dir=build --exclude-dir=docs --exclude-dir=scripts -r -n -M ':\n*\s*return' . > clean_labels

(note: there was a lot more of --exclude-dir in the original command, unfortunately I
didn't record it)

Then I filtered in the output file the cases where the regexp matched "switch"
labels and any other false positives like strings in comments. It's not manual
inspection, but it was crude indeed.



> 
> If we have a Coccinelle script that performs this transformation, we are more likely to be able to catch all places in the tree that would benefit (rather than relying on grep calls or other manual inspection), and more importantly, we can repeat the effort periodically to fix future additions that don't comply with the preferred style as well as backport the patch by rerunning the Coccinelle script with less worry of changed context.  Automated cleanups are always going to be easier to swallow (even if the diffstat is larger) than manual ad hoc cleanups.

I am not aware of how QEMU handles Coccinelle, if it is imposed via
./scripts/checkpatch.pl or something that it is ran from time to time to
suggest changes. But if it's desirable, I can see if I can cook a Coccinelle
script (or anything a bit more sophisticated than what I did)  to flag these
cases I attempted to handle with this series.


Thanks,


DHB


> 


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

* Re: [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  2020-01-07  9:51   ` Greg Kurz
@ 2020-01-13 15:15     ` Markus Armbruster
  2020-01-13 16:32       ` Laurent Vivier
  0 siblings, 1 reply; 113+ messages in thread
From: Markus Armbruster @ 2020-01-13 15:15 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-devel

Greg Kurz <groug@kaod.org> writes:

> On Mon,  6 Jan 2020 15:23:38 -0300
> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
>
>> 'err_out' can be removed and be replaced by 'return -errno'
>> in its only instance in the function.
>> 
>> CC: Greg Kurz <groug@kaod.org>
>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>> ---
>
> I don't really mind, but I confirm this doesn't change behavior.
>
> Acked-by: Greg Kurz <groug@kaod.org>
>
> What's the plan to get this and the other 9p related patches merged ?
> Through the trivial tree or each subsystem tree ?

I guess qemu-trivial will eventually pick up whatever hasn't been merged
by maintainers.

[...]



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

* Re: [PATCH v1 40/59] hsb/hcd-ehci.c: remove unneeded labels
  2020-01-06 18:24 ` [PATCH v1 40/59] hsb/hcd-ehci.c: remove unneeded labels Daniel Henrique Barboza
@ 2020-01-13 15:17   ` Markus Armbruster
  0 siblings, 0 replies; 113+ messages in thread
From: Markus Armbruster @ 2020-01-13 15:17 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-trivial, qemu-devel, Gerd Hoffmann

Typo in subject: s/hsb/usb/



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

* Re: [PATCH v1 00/59] trivial unneeded labels cleanup
  2020-01-06 19:54 ` [PATCH v1 00/59] trivial unneeded labels cleanup Corey Minyard
  2020-01-06 20:35   ` Daniel Henrique Barboza
@ 2020-01-13 15:26   ` Markus Armbruster
  1 sibling, 0 replies; 113+ messages in thread
From: Markus Armbruster @ 2020-01-13 15:26 UTC (permalink / raw)
  To: Corey Minyard; +Cc: qemu-trivial, Daniel Henrique Barboza, qemu-devel

Corey Minyard <minyard@acm.org> writes:

> On Mon, Jan 06, 2020 at 03:23:26PM -0300, Daniel Henrique Barboza wrote:
>> Hello,
>> 
>> This is the type of cleanup I've contributed to Libvirt
>> during the last year. Figured QEMU also deserves the same
>> care.
>> 
>> The idea here is remove unneeded labels. By 'unneeded' I
>> mean labels that does nothing but a 'return' call. One
>> common case is something like this:
>> 
>> if ()
>>     goto cleanup;
>> [...]
>>  cleanup:
>>     return 0;
>> 
>> This code can be simplified to:
>> 
>> if ()
>>     return 0;
>> 
>> 
>> Which is cleaner and requires less brain cycles to wonder
>> whether the 'cleanup' label does anything special, such
>> as a heap memory cleanup.
>
> I would disagree with this analysis.  To me, I often wonder
> when I have to add cleanup code to a routine whether there is
> some hidden return in the middle of the function.  That's a lot
> harder to spot than just looking for the cleanup label at the
> end of the function to see what it does.

A cleanup label does not preclude existence of return.  You have to
check for return anyway.

>                                           For non-trivial
> functions I prefer to have one point of return at the end
> (and maybe some minor checks with returns right at the beginning).
> I'm not adamant about this, just my opinion.

I'm in Daniel's camp: if there's no need for cleanup, return without
ado.

> But if we are going to fix things like this, it might be best to add
> them to the coding style document and checkpatch script.  Otherwise
> these sorts of things will just continue.

Maybe.



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

* Re: [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
  2020-01-06 18:24 ` [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() Daniel Henrique Barboza
  2020-01-08 13:00   ` Cornelia Huck
@ 2020-01-13 16:06   ` Thomas Huth
  1 sibling, 0 replies; 113+ messages in thread
From: Thomas Huth @ 2020-01-13 16:06 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-trivial

On 06/01/2020 19.24, Daniel Henrique Barboza wrote:
> 'out' label can be replaced by 'return' with the apropriate

s/apropriate/appropriate/

> value that is set by 'r' right before the jump.
> 
> Christian Borntraeger <borntraeger@de.ibm.com>

Missing "Cc:" ? With this line and the typo removed/fixed:

Reviewed-by: Thomas Huth <thuth@redhat.com>


> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/intc/s390_flic_kvm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
> index dddd33ea61..2e1e70c61d 100644
> --- a/hw/intc/s390_flic_kvm.c
> +++ b/hw/intc/s390_flic_kvm.c
> @@ -439,17 +439,14 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
>      count = qemu_get_be64(f);
>      len = count * sizeof(struct kvm_s390_irq);
>      if (count == FLIC_FAILED) {
> -        r = -EINVAL;
> -        goto out;
> +        return -EINVAL;
>      }
>      if (count == 0) {
> -        r = 0;
> -        goto out;
> +        return 0;
>      }
>      buf = g_try_malloc0(len);
>      if (!buf) {
> -        r = -ENOMEM;
> -        goto out;
> +        return -ENOMEM;
>      }
>  
>      if (qemu_get_buffer(f, (uint8_t *) buf, len) != len) {
> @@ -460,7 +457,6 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
>  
>  out_free:
>      g_free(buf);
> -out:
>      return r;
>  }
>  
> 



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

* Re: [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  2020-01-13 15:15     ` Markus Armbruster
@ 2020-01-13 16:32       ` Laurent Vivier
  2020-01-13 19:56         ` Greg Kurz
  2020-01-14  7:55         ` Markus Armbruster
  0 siblings, 2 replies; 113+ messages in thread
From: Laurent Vivier @ 2020-01-13 16:32 UTC (permalink / raw)
  To: Markus Armbruster, Greg Kurz
  Cc: qemu-trivial, Daniel Henrique Barboza, qemu-devel

Le 13/01/2020 à 16:15, Markus Armbruster a écrit :
> Greg Kurz <groug@kaod.org> writes:
> 
>> On Mon,  6 Jan 2020 15:23:38 -0300
>> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
>>
>>> 'err_out' can be removed and be replaced by 'return -errno'
>>> in its only instance in the function.
>>>
>>> CC: Greg Kurz <groug@kaod.org>
>>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>>> ---
>>
>> I don't really mind, but I confirm this doesn't change behavior.
>>
>> Acked-by: Greg Kurz <groug@kaod.org>
>>
>> What's the plan to get this and the other 9p related patches merged ?
>> Through the trivial tree or each subsystem tree ?
> 
> I guess qemu-trivial will eventually pick up whatever hasn't been merged
> by maintainers.
> 
> [...]
> 

Yes, but the difficulty will be to sort which ones of the 59 patches
series to collect...

Thanks,
Laurent



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

* Re: [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
  2020-01-08 13:00   ` Cornelia Huck
@ 2020-01-13 16:51     ` Cornelia Huck
  0 siblings, 0 replies; 113+ messages in thread
From: Cornelia Huck @ 2020-01-13 16:51 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: qemu-trivial, Halil Pasic, qemu-s390x, qemu-devel, Christian Borntraeger

On Wed, 8 Jan 2020 14:00:46 +0100
Cornelia Huck <cohuck@redhat.com> wrote:

> On Mon,  6 Jan 2020 15:24:07 -0300
> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
> 
> > 'out' label can be replaced by 'return' with the apropriate
> > value that is set by 'r' right before the jump.
> > 
> > Christian Borntraeger <borntraeger@de.ibm.com>  
> 
> I think something went wrong here; adding some cc:s.
> 
> > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> > ---
> >  hw/intc/s390_flic_kvm.c | 10 +++-------
> >  1 file changed, 3 insertions(+), 7 deletions(-)

> Looks fine to me; will apply unless someone sees an issue.
> 
> 

Thanks, applied (with the patch description fixed as per Thomas'
comments).



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

* Re: [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  2020-01-13 16:32       ` Laurent Vivier
@ 2020-01-13 19:56         ` Greg Kurz
  2020-01-14  7:55         ` Markus Armbruster
  1 sibling, 0 replies; 113+ messages in thread
From: Greg Kurz @ 2020-01-13 19:56 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: qemu-trivial, Daniel Henrique Barboza, Markus Armbruster, qemu-devel

On Mon, 13 Jan 2020 17:32:31 +0100
Laurent Vivier <laurent@vivier.eu> wrote:

> Le 13/01/2020 à 16:15, Markus Armbruster a écrit :
> > Greg Kurz <groug@kaod.org> writes:
> > 
> >> On Mon,  6 Jan 2020 15:23:38 -0300
> >> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
> >>
> >>> 'err_out' can be removed and be replaced by 'return -errno'
> >>> in its only instance in the function.
> >>>
> >>> CC: Greg Kurz <groug@kaod.org>
> >>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> >>> ---
> >>
> >> I don't really mind, but I confirm this doesn't change behavior.
> >>
> >> Acked-by: Greg Kurz <groug@kaod.org>
> >>
> >> What's the plan to get this and the other 9p related patches merged ?
> >> Through the trivial tree or each subsystem tree ?
> > 
> > I guess qemu-trivial will eventually pick up whatever hasn't been merged
> > by maintainers.
> > 
> > [...]
> > 
> 
> Yes, but the difficulty will be to sort which ones of the 59 patches
> series to collect...
> 

Ok, less work for you then. I've applied both 12/59 and 45/59 to 9p-next.
I'm planning to send a PR later this week.

> Thanks,
> Laurent
> 

Cheers,

--
Greg


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

* Re: [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid()
  2020-01-13 16:32       ` Laurent Vivier
  2020-01-13 19:56         ` Greg Kurz
@ 2020-01-14  7:55         ` Markus Armbruster
  1 sibling, 0 replies; 113+ messages in thread
From: Markus Armbruster @ 2020-01-14  7:55 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: qemu-trivial, Daniel Henrique Barboza, Greg Kurz, qemu-devel

Laurent Vivier <laurent@vivier.eu> writes:

> Le 13/01/2020 à 16:15, Markus Armbruster a écrit :
>> Greg Kurz <groug@kaod.org> writes:
>> 
>>> On Mon,  6 Jan 2020 15:23:38 -0300
>>> Daniel Henrique Barboza <danielhb413@gmail.com> wrote:
>>>
>>>> 'err_out' can be removed and be replaced by 'return -errno'
>>>> in its only instance in the function.
>>>>
>>>> CC: Greg Kurz <groug@kaod.org>
>>>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>>>> ---
>>>
>>> I don't really mind, but I confirm this doesn't change behavior.
>>>
>>> Acked-by: Greg Kurz <groug@kaod.org>
>>>
>>> What's the plan to get this and the other 9p related patches merged ?
>>> Through the trivial tree or each subsystem tree ?
>> 
>> I guess qemu-trivial will eventually pick up whatever hasn't been merged
>> by maintainers.
>> 
>> [...]
>> 
>
> Yes, but the difficulty will be to sort which ones of the 59 patches
> series to collect...

Collect them all and let git figure out which ones have been applied
already?



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

* Re: [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting()
  2020-01-06 18:23 ` [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting() Daniel Henrique Barboza
  2020-01-09 20:41   ` Aleksandar Markovic
@ 2020-01-24 17:22   ` Aleksandar Markovic
  1 sibling, 0 replies; 113+ messages in thread
From: Aleksandar Markovic @ 2020-01-24 17:22 UTC (permalink / raw)
  To: Daniel Henrique Barboza
  Cc: QEMU Trivial, Aurelien Jarno, Aleksandar Rikalo, QEMU Developers,
	Aleksandar Markovic

[-- Attachment #1: Type: text/plain, Size: 3567 bytes --]

On Mon, Jan 6, 2020 at 7:29 PM Daniel Henrique Barboza <
danielhb413@gmail.com> wrote:

> The label 'uhi_done' is a simple 'return' call and can
> be removed for a bit more clarity in the code.
>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  target/mips/mips-semi.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
>
Applied to MIPS queue.


> diff --git a/target/mips/mips-semi.c b/target/mips/mips-semi.c
> index 35bdfd7c77..10a710c1e8 100644
> --- a/target/mips/mips-semi.c
> +++ b/target/mips/mips-semi.c
> @@ -218,7 +218,7 @@ static int copy_argn_to_target(CPUMIPSState *env, int
> arg_num,
>          if (!p) {                               \
>              gpr[2] = -1;                        \
>              gpr[3] = EFAULT;                    \
> -            goto uhi_done;                      \
> +            return;                             \
>          }                                       \
>      } while (0)
>
> @@ -228,14 +228,14 @@ static int copy_argn_to_target(CPUMIPSState *env,
> int arg_num,
>          if (!p) {                                       \
>              gpr[2] = -1;                                \
>              gpr[3] = EFAULT;                            \
> -            goto uhi_done;                              \
> +            return;                                     \
>          }                                               \
>          p2 = lock_user_string(addr2);                   \
>          if (!p2) {                                      \
>              unlock_user(p, addr, 0);                    \
>              gpr[2] = -1;                                \
>              gpr[3] = EFAULT;                            \
> -            goto uhi_done;                              \
> +            return;                                     \
>          }                                               \
>      } while (0)
>
> @@ -272,7 +272,7 @@ void helper_do_semihosting(CPUMIPSState *env)
>          if (gpr[4] < 3) {
>              /* ignore closing stdin/stdout/stderr */
>              gpr[2] = 0;
> -            goto uhi_done;
> +            return;
>          }
>          gpr[2] = close(gpr[4]);
>          gpr[3] = errno_mips(errno);
> @@ -302,7 +302,7 @@ void helper_do_semihosting(CPUMIPSState *env)
>              gpr[2] = fstat(gpr[4], &sbuf);
>              gpr[3] = errno_mips(errno);
>              if (gpr[2]) {
> -                goto uhi_done;
> +                return;
>              }
>              gpr[2] = copy_stat_to_target(env, &sbuf, gpr[5]);
>              gpr[3] = errno_mips(errno);
> @@ -314,14 +314,14 @@ void helper_do_semihosting(CPUMIPSState *env)
>      case UHI_argnlen:
>          if (gpr[4] >= semihosting_get_argc()) {
>              gpr[2] = -1;
> -            goto uhi_done;
> +            return;
>          }
>          gpr[2] = strlen(semihosting_get_arg(gpr[4]));
>          break;
>      case UHI_argn:
>          if (gpr[4] >= semihosting_get_argc()) {
>              gpr[2] = -1;
> -            goto uhi_done;
> +            return;
>          }
>          gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]);
>          break;
> @@ -369,6 +369,5 @@ void helper_do_semihosting(CPUMIPSState *env)
>          fprintf(stderr, "Unknown UHI operation %d\n", op);
>          abort();
>      }
> -uhi_done:
>      return;
>  }
> --
> 2.24.1
>
>
>

[-- Attachment #2: Type: text/html, Size: 5269 bytes --]

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

end of thread, other threads:[~2020-01-24 17:23 UTC | newest]

Thread overview: 113+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06 18:23 [PATCH v1 00/59] trivial unneeded labels cleanup Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates() Daniel Henrique Barboza
2020-01-06 23:44   ` David Gibson
2020-01-06 18:23 ` [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree() Daniel Henrique Barboza
2020-01-06 23:45   ` David Gibson
2020-01-06 18:23 ` [PATCH v1 03/59] kvm-all.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 04/59] paaudio.c: " Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 05/59] ram.c: " Daniel Henrique Barboza
2020-01-06 18:57   ` Dr. David Alan Gilbert
2020-01-06 23:38   ` Juan Quintela
2020-01-08 12:41   ` Juan Quintela
2020-01-06 18:23 ` [PATCH v1 06/59] mips-semi.c: remove 'uhi_done' label in helper_do_semihosting() Daniel Henrique Barboza
2020-01-09 20:41   ` Aleksandar Markovic
2020-01-24 17:22   ` Aleksandar Markovic
2020-01-06 18:23 ` [PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2() Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label Daniel Henrique Barboza
2020-01-06 19:02   ` Marc-André Lureau
2020-01-06 18:23 ` [PATCH v1 09/59] chardev/char-pipe.c: remove 'fail' label in win_chr_pipe_init() Daniel Henrique Barboza
2020-01-06 19:01   ` Marc-André Lureau
2020-01-06 18:23 ` [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init() Daniel Henrique Barboza
2020-01-06 19:01   ` Marc-André Lureau
2020-01-07  6:52   ` Philippe Mathieu-Daudé
2020-01-06 18:23 ` [PATCH v1 11/59] exec.c: remove 'err' label in ram_block_discard_range() Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid() Daniel Henrique Barboza
2020-01-07  9:51   ` Greg Kurz
2020-01-13 15:15     ` Markus Armbruster
2020-01-13 16:32       ` Laurent Vivier
2020-01-13 19:56         ` Greg Kurz
2020-01-14  7:55         ` Markus Armbruster
2020-01-06 18:23 ` [PATCH v1 13/59] block/vdi.c: remove 'fail' label in vdi_open() Daniel Henrique Barboza
2020-01-06 21:04   ` Stefan Weil
2020-01-06 18:23 ` [PATCH v1 14/59] block/file-posix.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 15/59] block/blkreplay.c: remove unneeded 'fail' label in blkreplay_open() Daniel Henrique Barboza
2020-01-10  6:07   ` Pavel Dovgalyuk
2020-01-06 18:23 ` [PATCH v1 16/59] block/gluster.c: remove unneeded 'exit' label Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block() Daniel Henrique Barboza
2020-01-07 16:54   ` Stefan Hajnoczi
2020-01-06 18:23 ` [PATCH v1 18/59] qcow2-refcount.c: remove unneeded 'fail' label in qcow2_refcount_init() Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 19/59] block/ssh.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:37   ` Richard W.M. Jones
2020-01-06 18:23 ` [PATCH v1 20/59] block/vpc.c: remove unneeded 'fail' label in create_dynamic_disk() Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 21/59] block/backup.c remove unneeded 'out' label in backup_run() Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 22/59] block/vmdk.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 23/59] block/vxhs.c: remove unneeded 'out' label in vxhs_iio_callback() Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 24/59] block/vhdx-log.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 25/59] block/vhdx.c: remove unneeded 'exit' labels Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 26/59] block/replication.c: remove unneeded label in replication_co_writev Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 27/59] crypto/block-luks.c: remove unneeded label in qcrypto_block_luks_find_key Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 28/59] qga/commands-win32.c: remove 'out' label in get_pci_info Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 29/59] cryptodev-vhost.c: remove unneeded 'err' label in cryptodev_vhost_start Daniel Henrique Barboza
2020-01-07  6:53   ` Philippe Mathieu-Daudé
2020-01-07  8:18   ` Gonglei (Arei)
2020-01-06 18:23 ` [PATCH v1 30/59] util/module.c: remove unneeded label in module_load_file() Daniel Henrique Barboza
2020-01-07 11:26   ` Thomas Huth
2020-01-06 18:23 ` [PATCH v1 31/59] util/aio-posix.c: remove unneeded 'out' label in aio_epoll Daniel Henrique Barboza
2020-01-07 13:34   ` Thomas Huth
2020-01-06 18:23 ` [PATCH v1 32/59] qemu-img.c: remove 'out4' label in img_compare Daniel Henrique Barboza
2020-01-06 18:23 ` [PATCH v1 33/59] ipmi/ipmi_bmc_sim.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 34/59] ipmi/ipmi_bt.c: remove unneeded label in ipmi_bt_handle_event Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 35/59] ipmi_bmc_extern.c: remove unneeded label in ipmi_bmc_extern_handle_command Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 36/59] ipmi/ipmi_kcs.c: remove unneeded label in ipmi_kcs_handle_event Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 37/59] s390x/event-facility.c: remove unneeded labels Daniel Henrique Barboza
2020-01-07 13:36   ` Thomas Huth
2020-01-08 12:46   ` Cornelia Huck
2020-01-08 14:15     ` Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 38/59] s390x/sclp.c: remove unneeded label in sclp_service_call() Daniel Henrique Barboza
2020-01-07 13:37   ` Thomas Huth
2020-01-08 13:16   ` Cornelia Huck
2020-01-06 18:24 ` [PATCH v1 39/59] usb/dev-mtp.c: remove unneeded label in write_retry() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 40/59] hsb/hcd-ehci.c: remove unneeded labels Daniel Henrique Barboza
2020-01-13 15:17   ` Markus Armbruster
2020-01-06 18:24 ` [PATCH v1 41/59] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() Daniel Henrique Barboza
2020-01-08 13:00   ` Cornelia Huck
2020-01-13 16:51     ` Cornelia Huck
2020-01-13 16:06   ` Thomas Huth
2020-01-06 18:24 ` [PATCH v1 42/59] i386/intel_iommu.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 43/59] i386/amd_iommu.c: remove unneeded label in amdvi_int_remap_msi() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 44/59] 9p-local.c: remove unneeded label in local_unlinkat_common() Daniel Henrique Barboza
2020-01-07 12:04   ` Christian Schoenebeck
2020-01-07 13:58     ` Greg Kurz
2020-01-07 13:53   ` Greg Kurz
2020-01-07 14:16     ` Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 45/59] 9pfs/9p.c: remove unneeded labels Daniel Henrique Barboza
2020-01-07 12:14   ` Christian Schoenebeck
2020-01-08 14:08     ` Greg Kurz
2020-01-06 18:24 ` [PATCH v1 46/59] alpha/typhoon.c: remove unneeded label in typhoon_translate_iommu() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 47/59] pvrdma_main.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 48/59] pvrdma_dev_ring.c: remove unneeded label in pvrdma_ring_init() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 49/59] rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 50/59] rdma/rdma_backend.c: remove unneeded label in rdma_backend_init() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 51/59] virtio/vhost.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 52/59] net/vhost_net.c: " Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 53/59] net/net_tx_pkt.c: remove unneeded label in net_tx_pkt_get_gso_type() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 54/59] ivshmem-server/main.c: remove unneeded label in main() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 55/59] linux-user/flatload.c: remove unused 'out' label Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 56/59] linux-user/signal.c: remove unneeded label in do_sigaltstack() Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 57/59] linux-user/syscall.c: fix trailing whitespaces and style Daniel Henrique Barboza
2020-01-07  6:57   ` Philippe Mathieu-Daudé
2020-01-07 10:37   ` Peter Maydell
2020-01-06 18:24 ` [PATCH v1 58/59] linux-user/syscall.c: remove unneeded labels Daniel Henrique Barboza
2020-01-06 18:24 ` [PATCH v1 59/59] linux-user/vm86.c: remove unneeded label in do_vm86() Daniel Henrique Barboza
2020-01-06 19:54 ` [PATCH v1 00/59] trivial unneeded labels cleanup Corey Minyard
2020-01-06 20:35   ` Daniel Henrique Barboza
2020-01-07  6:16     ` Kevin Wolf
2020-01-07  7:06       ` Philippe Mathieu-Daudé
2020-01-09 19:19         ` Daniel Henrique Barboza
2020-01-07 11:52       ` Daniel Henrique Barboza
2020-01-07 12:21         ` Kevin Wolf
2020-01-13 15:26   ` Markus Armbruster
2020-01-07  9:43 ` Max Reitz
2020-01-09 20:16   ` Daniel Henrique Barboza
2020-01-10 19:05 ` Eric Blake
2020-01-10 20:31   ` Daniel Henrique Barboza

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.