]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainCleanupRemove: s/memmove/VIR_DELETE_ELEMENT_INPLACE/
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Oct 2013 17:07:42 +0000 (19:07 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 17 Oct 2013 13:24:05 +0000 (15:24 +0200)
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.

src/qemu/qemu_domain.c

index d054d64fc5d93075ae53d1ba4fc2cf270f83ec7b..b8aec2d8443f548aaba6972f8ebfcc968cbbf2dd 100644 (file)
@@ -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,