[PATCH] qemuDomainCleanupRemove: s/memmove/VIR_DELETE_ELEMENT_INPLACE/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]