[PATCH 0/3] batch: don't require checking retvalue of some bitmap ops

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Thu Jul 30 14:27:35 UTC 2020


Most of bitmap setBit/clearBit/getBit users know that the bitmap index is
not out of bound and thus don't check the return value. More precisely
the stats is next:

Method                all   check
===================================
virBitmapSetBit        85      14
virBitmapClearBit      15       3
virBitmapGetBit        15       6

where 'all' is the number of all occurences of the method and 'check' is the
number of occurences with 'if (method' pattern.

Thus keeping the retvalue checking requirement produces more
noise then helps. I guess we even can make these function return
void as users can simply compare the index with the bitmap size.

The removing of ignore_value was done by sed together with several manual
editings where methods calls were splitted across two lines.

FILES=`git grep -l 'ignore_value(virBitmapGetBit('`
sed -ibak -re 's/ignore_value\(virBitmapGetBit\((.*)\)\);/virBitmapGetBit(\1\);/' "$FILES"

Nikolay Shirokovskiy (3):
  batch: don't require checking retvalue for virBitmapSetBit
  batch: don't require checking retvalue for virBitmapClearBit
  batch: don't require checking retvalue for virBitmapGetBit

 src/conf/capabilities.c           |  2 +-
 src/conf/checkpoint_conf.c        |  2 +-
 src/conf/domain_addr.c            |  8 ++++----
 src/conf/domain_conf.c            |  9 ++++-----
 src/conf/node_device_conf.c       |  2 +-
 src/conf/snapshot_conf.c          |  2 +-
 src/conf/storage_conf.c           |  2 +-
 src/libxl/libxl_capabilities.c    |  2 +-
 src/network/bridge_driver.c       |  6 +++---
 src/qemu/qemu_capabilities.c      |  4 ++--
 src/qemu/qemu_domain.c            |  2 +-
 src/qemu/qemu_domain_address.c    |  4 ++--
 src/qemu/qemu_driver.c            |  8 ++++----
 src/qemu/qemu_hotplug.c           |  6 +++---
 src/qemu/qemu_migration_cookie.c  |  8 ++++----
 src/qemu/qemu_migration_params.c  | 28 +++++++++++++---------------
 src/qemu/qemu_monitor.c           |  2 +-
 src/qemu/qemu_slirp.c             |  2 +-
 src/test/test_driver.c            |  2 +-
 src/util/virbitmap.h              |  6 +++---
 src/util/vircommand.c             |  2 +-
 src/util/virdnsmasq.c             |  2 +-
 src/util/virhostcpu.c             |  2 +-
 src/util/virjson.c                |  2 +-
 src/util/virnetdev.c              | 10 +++++-----
 src/util/virnuma.c                |  4 ++--
 src/util/virprocess.c             |  4 ++--
 src/util/virresctrl.c             |  2 +-
 src/util/virstoragefile.c         |  2 +-
 src/vmx/vmx.c                     |  2 +-
 tests/qemumonitorjsontest.c       |  2 +-
 tests/testutils.c                 |  2 +-
 tests/virbitmaptest.c             | 28 ++++++++++++++--------------
 tools/virsh-domain.c              |  4 ++--
 tools/virt-host-validate-common.c |  2 +-
 35 files changed, 87 insertions(+), 90 deletions(-)

-- 
1.8.3.1




More information about the libvir-list mailing list