[libvirt] [PATCH v1 00/21] remove 'cleanup: return' labels

Daniel Henrique Barboza danielhb413 at gmail.com
Mon Oct 21 18:18:50 UTC 2019


Hi,

This series is focused on removing most of the unused 'cleanup'
labels that we have in the code so far (as of master commit
2cff65e4c6). I say 'most' because there's a handful of instances
left that are being used by macros and other machinery that
I judged it wasn't worth to deal with in the scope of this work.

The motivations for this change are (1) less code to deal with and
(2) a bit more clarity, since the presence of a 'cleanup' label should
indicate a cleanup procedure (virObjectUnref and so on).

The vast majority of the cases being handled here are variations
of the following pattern:

-----
(function header)
    int ret = -1;

( nothing is done with 'ret' in the function body,
'cleanup' calls are made on error conditions)

    ret = 0;
 cleanup:
    return ret;
(end of function)
-----

This pattern can be replaced by removing 'cleanup:' and 'ret',
replacing it with 'return -1' on error conditions and 'return 0'
on success. Other patterns were handled as well, but this is the
most frequent one.

I made an effort to *not* change or refactor the function logic in
the attempt of removing labels.

Patches were split by directory. If only one file in a dir got
changed, the file is mentioned in the commit instead.

There were not preparatory patches for these changes because they
are intended to be somewhat simple. The one exception is patch 09.
I chose to handle that case in a separated patch to not clutter the
review of patch 10, but I expect it to be merged with the 'qemu'
patch once it is reviewed.

All these changes are available in [1].

[1] https://github.com/danielhb/libvirt/tree/clean_trivial_labels


Daniel Henrique Barboza (21):
  conf: remove unneeded cleanup labels
  storage: remove unneeded cleanup labels
  nwfilter: remove unneeded cleanup labels
  remote: remove unneeded cleanup labels
  lxc: remove unneeded cleanup labels
  node_device: remove unneeded cleanup labels
  secret_driver.c: remove unneeded cleanup label
  openvz_conf.c: remove unneeded cleanup label
  qemu_monitor_json.c: remove unneeded cleanup label
  qemu: remove unneeded cleanup labels
  rpc: remove unneeded cleanup labels
  vz_sdk.c: remove unneeded cleanup label
  vbox: remove unneeded cleanup labels
  util: remove unneeded cleanup labels
  libvirt.c: remove unneeded cleanup label
  libxl_driver.c: remove unneeded cleanup label
  bridge_driver.c: remove unneeded cleanup labels
  suspend.c: remove unneeded cleanup label
  tools: remove unneeded cleanup labels
  tests: remove unneeded cleanup labels
  bhyve_device.c: remove unneeded cleanup labels

 examples/c/domain/suspend.c               |   9 +-
 src/bhyve/bhyve_device.c                  |  18 +-
 src/conf/domain_addr.c                    |  23 +-
 src/conf/domain_capabilities.c            |  21 +-
 src/conf/domain_conf.c                    | 334 ++++++++--------------
 src/conf/netdev_bandwidth_conf.c          |  17 +-
 src/conf/network_conf.c                   |  25 +-
 src/conf/node_device_conf.c               |  28 +-
 src/conf/numa_conf.c                      |  25 +-
 src/conf/nwfilter_conf.c                  |   4 +-
 src/conf/storage_conf.c                   |   7 +-
 src/conf/virnetworkobj.c                  |  14 +-
 src/conf/virsecretobj.c                   |   5 +-
 src/libvirt.c                             |   7 +-
 src/libxl/libxl_driver.c                  |  16 +-
 src/lxc/lxc_cgroup.c                      |  70 ++---
 src/lxc/lxc_container.c                   |  17 +-
 src/lxc/lxc_controller.c                  |  44 ++-
 src/lxc/lxc_driver.c                      |  39 +--
 src/lxc/lxc_process.c                     |  34 +--
 src/network/bridge_driver.c               | 172 +++++------
 src/node_device/node_device_driver.c      |  11 +-
 src/node_device/node_device_udev.c        |   8 +-
 src/nwfilter/nwfilter_ebiptables_driver.c | 132 ++++-----
 src/openvz/openvz_conf.c                  |   3 +-
 src/qemu/qemu_cgroup.c                    |  15 +-
 src/qemu/qemu_domain.c                    |  92 +++---
 src/qemu/qemu_domain_address.c            |  31 +-
 src/qemu/qemu_driver.c                    | 140 ++++-----
 src/qemu/qemu_hotplug.c                   |  45 ++-
 src/qemu/qemu_interface.c                 |  26 +-
 src/qemu/qemu_migration.c                 |  38 +--
 src/qemu/qemu_monitor_json.c              |  15 +-
 src/qemu/qemu_process.c                   |  77 ++---
 src/qemu/qemu_tpm.c                       |  20 +-
 src/remote/remote_daemon.c                |  38 ++-
 src/remote/remote_driver.c                |  15 +-
 src/rpc/virnetserver.c                    |  15 +-
 src/rpc/virnetserverprogram.c             |  13 +-
 src/rpc/virnetsocket.c                    |   9 +-
 src/rpc/virnettlscontext.c                |  20 +-
 src/secret/secret_driver.c                |  11 +-
 src/storage/storage_backend_fs.c          |  13 +-
 src/storage/storage_backend_rbd.c         |  58 ++--
 src/storage/storage_backend_zfs.c         |  21 +-
 src/storage/storage_driver.c              |  38 +--
 src/storage/storage_util.c                |  18 +-
 src/util/vircgroupv1.c                    |  18 +-
 src/util/vircommand.c                     |  11 +-
 src/util/virdbus.c                        |  30 +-
 src/util/virfile.c                        |  19 +-
 src/util/virhash.c                        |   6 +-
 src/util/virhostcpu.c                     |  20 +-
 src/util/virhostdev.c                     |   7 +-
 src/util/virhostmem.c                     |  55 ++--
 src/util/virjson.c                        |  30 +-
 src/util/virmacmap.c                      |  10 +-
 src/util/virnetdevbridge.c                |  21 +-
 src/util/virnuma.c                        |  27 +-
 src/util/virpci.c                         |   7 +-
 src/util/virprocess.c                     |  19 +-
 src/util/virresctrl.c                     |   7 +-
 src/util/virstoragefile.c                 |  46 +--
 src/util/virutil.c                        |  19 +-
 src/vbox/vbox_common.c                    |  12 +-
 src/vbox/vbox_snapshot_conf.c             |  75 ++---
 src/vz/vz_sdk.c                           |   8 +-
 tests/commandtest.c                       |  17 +-
 tests/domainconftest.c                    |   5 +-
 tests/networkxml2firewalltest.c           |  13 +-
 tests/nsstest.c                           |  27 +-
 tests/nwfilterebiptablestest.c            |   4 +-
 tests/nwfilterxml2firewalltest.c          |  16 +-
 tests/qemuhotplugtest.c                   |  19 +-
 tests/qemuxml2argvtest.c                  |  11 +-
 tests/storagebackendsheepdogtest.c        |   5 +-
 tests/virauthconfigtest.c                 |  11 +-
 tests/vircgroupmock.c                     |  11 +-
 tests/virendiantest.c                     |  58 ++--
 tests/virkeycodetest.c                    |  14 +-
 tests/virmacmaptest.c                     |   5 +-
 tests/virnetdevtest.c                     |  11 +-
 tests/virpcimock.c                        |  31 +-
 tests/virpcitest.c                        |   3 +-
 tests/virpolkittest.c                     |  65 ++---
 tests/virstringtest.c                     |  18 +-
 tools/virsh-completer-network.c           |   8 +-
 tools/virsh-domain.c                      |  41 +--
 tools/vsh.c                               |  14 +-
 89 files changed, 983 insertions(+), 1722 deletions(-)

-- 
2.21.0




More information about the libvir-list mailing list