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

[libvirt] [PATCH 1/4] phyp: prefer memcpy over memmove when legal



* src/phyp/phyp_driver.c (phypUUIDTable_AddLpar)
(phypGetLparUUID, phypGetStoragePoolUUID, phypVolumeGetXMLDesc)
(phypGetStoragePoolXMLDesc): Use faster method.
---

memmove is only required for overlapping regions; none of these
instances could overlap and memcpy is theoretically faster

 src/phyp/phyp_driver.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index a1b6819..ec2ac09 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -633,7 +633,7 @@ phypUUIDTable_AddLpar(virConnectPtr conn, unsigned char *uuid, int id)
     }

     uuid_table->lpars[i]->id = id;
-    memmove(uuid_table->lpars[i]->uuid, uuid, VIR_UUID_BUFLEN);
+    memcpy(uuid_table->lpars[i]->uuid, uuid, VIR_UUID_BUFLEN);

     if (phypUUIDTable_WriteFile(conn) == -1)
         goto err;
@@ -1398,7 +1398,7 @@ phypGetLparUUID(unsigned char *uuid, int lpar_id, virConnectPtr conn)

     for (i = 0; i < uuid_table->nlpars; i++) {
         if (lpars[i]->id == lpar_id) {
-            memmove(uuid, lpars[i]->uuid, VIR_UUID_BUFLEN);
+            memcpy(uuid, lpars[i]->uuid, VIR_UUID_BUFLEN);
             return 0;
         }
     }
@@ -2623,7 +2623,7 @@ phypGetStoragePoolUUID(virConnectPtr conn, unsigned char *uuid,
     if (exit_status < 0 || ret == NULL)
         goto err;

-    if (memmove(uuid, ret, VIR_UUID_BUFLEN) == NULL)
+    if (memcpy(uuid, ret, VIR_UUID_BUFLEN) == NULL)
         goto err;

     VIR_FREE(cmd);
@@ -2676,7 +2676,7 @@ phypVolumeGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
         goto err;
     }

-    if (memmove(pool.uuid, sp->uuid, VIR_UUID_BUFLEN) == NULL) {
+    if (memcpy(pool.uuid, sp->uuid, VIR_UUID_BUFLEN) == NULL) {
         VIR_ERROR0(_("Unable to determine storage sp's uuid."));
         goto err;
     }
@@ -2705,7 +2705,7 @@ phypVolumeGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
         goto err;
     }

-    if (memmove(voldef.key, vol->key, PATH_MAX) == NULL) {
+    if (memcpy(voldef.key, vol->key, PATH_MAX) == NULL) {
         VIR_ERROR0(_("Unable to determine volume's key."));
         goto err;
     }
@@ -3262,7 +3262,7 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags)
         goto err;
     }

-    if (memmove(def.uuid, pool->uuid, VIR_UUID_BUFLEN) == NULL) {
+    if (memcpy(def.uuid, pool->uuid, VIR_UUID_BUFLEN) == NULL) {
         VIR_ERROR0(_("Unable to determine storage pool's uuid."));
         goto err;
     }
-- 
1.7.4.2


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