[libvirt] [PATCH] Change return value of VIR_APPEND*INPLACE* to void

Jiri Denemark jdenemar at redhat.com
Tue May 17 13:44:40 UTC 2016


The INPLACE variants of the VIR_APPEND macros cannot fail and they are
inherently quiet.

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/conf/domain_conf.c  |  2 +-
 src/qemu/qemu_hotplug.c |  2 +-
 src/util/viralloc.h     | 25 +++++++++++--------------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 04f1381..3b69771 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13997,7 +13997,7 @@ virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
 
     virDomainChrGetDomainPtrsInternal(vmdef, chr->deviceType, &arrPtr, &cntPtr);
 
-    ignore_value(VIR_APPEND_ELEMENT_INPLACE(*arrPtr, *cntPtr, chr));
+    VIR_APPEND_ELEMENT_INPLACE(*arrPtr, *cntPtr, chr);
 }
 
 virDomainChrDefPtr
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 85c5e0c..2b2e91c 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1660,7 +1660,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    ignore_value(VIR_APPEND_ELEMENT_INPLACE(vm->def->rngs, vm->def->nrngs, rng));
+    VIR_APPEND_ELEMENT_INPLACE(vm->def->rngs, vm->def->nrngs, rng);
 
     ret = 0;
 
diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 5f4e27b..d790b3d 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -436,13 +436,17 @@ void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *countpt
                        VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false, \
                        true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
 # define VIR_APPEND_ELEMENT_INPLACE(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true, \
-                       true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
+    ignore_value(virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),   \
+                                    VIR_TYPEMATCH(ptr, &(newelem)),         \
+                                    &(newelem), true, true, false,          \
+                                    VIR_FROM_THIS, __FILE__,                \
+                                    __FUNCTION__, __LINE__))
 # define VIR_APPEND_ELEMENT_COPY_INPLACE(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true, \
-                       true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
+    ignore_value(virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),   \
+                                    VIR_TYPEMATCH(ptr, &(newelem)),         \
+                                    &(newelem), false, true, false,         \
+                                    VIR_FROM_THIS, __FILE__,                \
+                                    __FUNCTION__, __LINE__))
 
 /* Quiet version of macros above */
 # define VIR_APPEND_ELEMENT_QUIET(ptr, count, newelem) \
@@ -453,14 +457,7 @@ void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *countpt
     virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),  \
                        VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false, \
                        false, 0, NULL, NULL, 0)
-# define VIR_APPEND_ELEMENT_INPLACE_QUIET(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true, \
-                       false. 0, NULL, NULL, 0)
-# define VIR_APPEND_ELEMENT_COPY_INPLACE_QUIET(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true, \
-                       false, 0, NULL, NULL, 0)
+
 /**
  * VIR_DELETE_ELEMENT:
  * @ptr:   pointer to array of objects (*not* ptr to ptr)
-- 
2.8.2




More information about the libvir-list mailing list