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

[libvirt] [PATCHv3 07/17] xen: Use VIR_DELETE_ELEMENT for disk/net devices



The stock remove functions in domain_conf.c already use
VIR_DELETE_ELEMENT. This does the same in a xen file.
---
 src/xen/xm_internal.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 9da2974..aac9ec5 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1477,12 +1477,7 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
                 dev->data.disk->dst &&
                 STREQ(def->disks[i]->dst, dev->data.disk->dst)) {
                 virDomainDiskDefFree(def->disks[i]);
-                if (i < (def->ndisks - 1))
-                    memmove(def->disks + i,
-                            def->disks + i + 1,
-                            sizeof(*def->disks) *
-                            (def->ndisks - (i + 1)));
-                def->ndisks--;
+                VIR_DELETE_ELEMENT(def->disks, i, def->ndisks);
                 break;
             }
         }
@@ -1494,12 +1489,7 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
         for (i = 0 ; i < def->nnets ; i++) {
             if (!virMacAddrCmp(&def->nets[i]->mac, &dev->data.net->mac)) {
                 virDomainNetDefFree(def->nets[i]);
-                if (i < (def->nnets - 1))
-                    memmove(def->nets + i,
-                            def->nets + i + 1,
-                            sizeof(*def->nets) *
-                            (def->nnets - (i + 1)));
-                def->nnets--;
+                VIR_DELETE_ELEMENT(def->nets, i, def->nnets);
                 break;
             }
         }
-- 
1.7.11.7


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