[PATCH 00/25] Several g_auto* conversion and related small bugfixes

Laine Stump laine at redhat.com
Thu Jun 25 03:33:49 UTC 2020


This started out with me noticing a memory leak in a patch that led to
the realization that domain_conf.c hadn't been converted to use
g_autofree yet, and each step of the way uncovered some other
annoyance that I wanted to get rid of. Most of the changes are related
to converting code to use g_auto*, g_new0, and g_free, but there is
also a some of elimination of labels, fixing actual or theoretical
memory leaks, modifications for style, etc. None of it should have any
functional effect (except the fixing one or two memory leaks).


Laine Stump (25):
  conf, vmx: check for OOM after calling xmlBufferCreate()
  use g_autoptr for all xmlBuffers
  conf: refactor virDomainBlkioDeviceParseXML to remove possible NULL
    dereference
  util: validate return from xmlNodeGetContent before use
  util: remove OOM error log from virGetHostnameImpl()
  conf: eliminate useless error label in virDomainFeaturesDefParse()
  util: eliminate error label in virDomainDefFormatInternalSetRootName()
  network: fix memory leak in networkBuildDhcpDaemonCommandLine()
  util: add g_autoptr cleanup function for virFirewall objects
  network: convert local pointers to g_auto*
  network: use g_free() in place of remaining VIR_FREE()
  network: make networkDnsmasqXmlNsDef private to bridge_driver.c
  define g_autoptr cleanup function for virNetworkDHCPLease
  network: replace VIR_ALLOC/REALLOC with g_new0/g_renew
  network: use proper arg type when calling virNetDevSetOnline()
  squash into 'network: convert local pointers to g_auto*'
  use g_autoptr() for all usages of virFirewallNew/Free
  nwfilter: define a typedef for struct ebtablesSubChainInst
  nwfilter replace VIR_ALLOC with g_new0
  nwfilter: remove unnecessary code from ebtablesGetSubChainInsts()
  nwfilter: convert local pointers to use g_auto*
  nwfilter: convert remaining VIR_FREE() to g_free()
  nwfilter: transform logic in virNWFilterRuleInstSort to eliminate
    label
  nwfilter: use standard label names when reasonable
  replace g_new() with g_new0() for consistency

 src/conf/domain_conf.c                    | 254 +++++-----
 src/conf/network_conf.c                   |  10 +-
 src/datatypes.h                           |   2 +
 src/network/bridge_driver.c               | 585 +++++++++-------------
 src/network/bridge_driver.h               |   9 -
 src/network/bridge_driver_linux.c         |  58 +--
 src/network/leaseshelper.c                |  16 +-
 src/nwfilter/nwfilter_dhcpsnoop.c         | 150 +++---
 src/nwfilter/nwfilter_driver.c            |  13 +-
 src/nwfilter/nwfilter_ebiptables_driver.c | 277 ++++------
 src/nwfilter/nwfilter_gentech_driver.c    |  60 +--
 src/nwfilter/nwfilter_learnipaddr.c       |  45 +-
 src/qemu/qemu_backup.c                    |   2 +-
 src/util/virdnsmasq.h                     |   4 +
 src/util/virebtables.c                    |  24 +-
 src/util/virfirewall.h                    |   1 +
 src/util/viriptables.c                    |  14 +-
 src/util/virutil.c                        |  12 +-
 src/util/virxml.c                         |  12 +-
 src/vmx/vmx.c                             |  17 +-
 tests/qemuhotplugmock.c                   |   2 +-
 tests/virfirewalltest.c                   |  50 +-
 22 files changed, 640 insertions(+), 977 deletions(-)

-- 
2.25.4




More information about the libvir-list mailing list