]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: alloc: Reimplement VIR_APPEND_ELEMENT_QUIET using virAppendElement
authorPeter Krempa <pkrempa@redhat.com>
Wed, 4 Aug 2021 07:25:23 +0000 (09:25 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 6 Aug 2021 06:53:25 +0000 (08:53 +0200)
For now it was an alias to VIR_APPEND_ELEMENT. Use virAppendElement
directly until VIR_APPEND_ELEMENT is refactored too and we'll be able to
get rid of VIR_APPEND_ELEMENT_QUIET completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/viralloc.h
tests/virfilewrapper.c
tests/virpcimock.c

index 70cd721bc79ca2c8696b23675e15a64a13104231..c5ca8e9929f90ae1b09fc4e4cf2f384f2de7c2a5 100644 (file)
@@ -247,7 +247,8 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
 
 /* Quiet version of macros above */
 #define VIR_APPEND_ELEMENT_QUIET(ptr, count, newelem) \
-    VIR_APPEND_ELEMENT(ptr, count, newelem)
+    virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \
+                     VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false)
 
 /**
  * VIR_DELETE_ELEMENT:
index 30c63ecf562a50b0149682b91dcef2c843e4d89c..3085a190fb98849629c1c4f8e73c5bdfbfc8cdd8 100644 (file)
@@ -78,13 +78,8 @@ virFileWrapperAddPrefix(const char *prefix,
 
     init_syms();
 
-    if (VIR_APPEND_ELEMENT_QUIET(prefixes, nprefixes, prefix) < 0 ||
-        VIR_APPEND_ELEMENT_QUIET(overrides, noverrides, override) < 0) {
-        VIR_FREE(prefixes);
-        VIR_FREE(overrides);
-        fprintf(stderr, "Unable to add path override for '%s'\n", prefix);
-        abort();
-    }
+    VIR_APPEND_ELEMENT_QUIET(prefixes, nprefixes, prefix);
+    VIR_APPEND_ELEMENT_QUIET(overrides, noverrides, override);
 }
 
 
index be513ad91842df6c129289b88e1f5b401ca13eca..de39fc65a4c84d30b66c80586b1c39fe5b95d845 100644 (file)
@@ -428,9 +428,7 @@ pci_device_create_iommu(const struct pciDevice *dev,
     iommuGroup->iommu = dev->iommuGroup;
     iommuGroup->nDevicesBoundToVFIO = 0; /* No device bound to VFIO by default */
 
-    if (VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups,
-                                 iommuGroup) < 0)
-        ABORT_OOM();
+    VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, iommuGroup);
 }
 
 
@@ -544,8 +542,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
     if (pci_device_autobind(dev) < 0)
         ABORT("Unable to bind: %s", devid);
 
-    if (VIR_APPEND_ELEMENT_QUIET(pciDevices, nPCIDevices, dev) < 0)
-        ABORT_OOM();
+    VIR_APPEND_ELEMENT_QUIET(pciDevices, nPCIDevices, dev);
 }
 
 static struct pciDevice *
@@ -716,8 +713,7 @@ pci_driver_new(const char *name, ...)
     make_file(driverpath, "bind", NULL, -1);
     make_file(driverpath, "unbind", NULL, -1);
 
-    if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver) < 0)
-        ABORT_OOM();
+    VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver);
 }
 
 static struct pciDriver *