[libvirt] [PATCH] qemuDomainCleanupRemove: s/memmove/VIR_DELETE_ELEMENT_INPLACE/

Michal Privoznik mprivozn at redhat.com
Thu Oct 17 13:33:52 UTC 2013


The last argument of memmove is the amount of bytes to be moved. The
amount is in Bytes. We are moving some void pointers around. However,
since sizeof(void *) is not Byte on any architecture, we've got the
arithmetic wrong.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_domain.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d054d64..b8aec2d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2235,12 +2235,9 @@ qemuDomainCleanupRemove(virDomainObjPtr vm,
     VIR_DEBUG("vm=%s, cb=%p", vm->def->name, cb);
 
     for (i = 0; i < priv->ncleanupCallbacks; i++) {
-        if (priv->cleanupCallbacks[i] == cb) {
-            memmove(priv->cleanupCallbacks + i,
-                    priv->cleanupCallbacks + i + 1,
-                    priv->ncleanupCallbacks - i - 1);
-            priv->ncleanupCallbacks--;
-        }
+        if (priv->cleanupCallbacks[i] == cb)
+            VIR_DELETE_ELEMENT_INPLACE(priv->cleanupCallbacks,
+                                       i, priv->ncleanupCallbacks);
     }
 
     VIR_SHRINK_N(priv->cleanupCallbacks,
-- 
1.8.1.5




More information about the libvir-list mailing list