[libvirt-php PATCH 20/35] Switch all add_assoc_string_ex to add_assoc_string to avoid nul char management

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

 



From: Remi Collet <fedora@xxxxxxxxxxxxxxxxx>

PHP 5 => #define add_assoc_string(__arg, __key, __str, __duplicate) add_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
PHP 7 => #define add_assoc_string(__arg, __key, __str)              add_assoc_string_ex(__arg, __key, strlen(__key),   __str)
---
 src/libvirt-php.c | 136 +++++++++++++++++++++++++++---------------------------
 1 file changed, 68 insertions(+), 68 deletions(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 1977039..ee79f0e 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -2003,7 +2003,7 @@ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\
 #define LONGLONG_ASSOC(out,key,in) \
     if (LIBVIRT_G(longlong_to_string_ini)) { \
         snprintf(tmpnumber,63,"%llu",in); \
-        add_assoc_string_ex(out,key,strlen(key)+1,tmpnumber VIRT_COPY_OPT); \
+        add_assoc_string(out,key,tmpnumber VIRT_COPY_OPT); \
     } \
 else \
 { \
@@ -2232,7 +2232,7 @@ PHP_FUNCTION(libvirt_node_get_info)
     if (retval==-1) RETURN_FALSE;
 
     array_init(return_value);
-    add_assoc_string_ex(return_value, "model", 6, info.model VIRT_COPY_OPT);
+    add_assoc_string(return_value, "model", info.model VIRT_COPY_OPT);
     add_assoc_long(return_value, "memory", (long)info.memory);
     add_assoc_long(return_value, "cpus", (long)info.cpus);
     add_assoc_long(return_value, "nodes", (long)info.nodes);
@@ -2335,9 +2335,9 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats)
         add_assoc_long(return_value, "cpu", cpunr);
     else
         if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS)
-            add_assoc_string_ex(return_value, "cpu", 4, "all" VIRT_COPY_OPT);
+            add_assoc_string(return_value, "cpu", "all" VIRT_COPY_OPT);
         else
-            add_assoc_string_ex(return_value, "cpu", 4, "unknown" VIRT_COPY_OPT);
+            add_assoc_string(return_value, "cpu", "unknown" VIRT_COPY_OPT);
 
     free(params);
     params = NULL;
@@ -2580,14 +2580,14 @@ PHP_FUNCTION(libvirt_connect_get_machine_types)
                             char tmp3[2048] = { 0 };
 
                             snprintf(key, sizeof(key), "%d", k);
-                            //add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT);
+                            //add_assoc_string(arr2, key, ret3[k] VIRT_COPY_OPT);
 
                             snprintf(tmp3, sizeof(tmp3), "//capabilities/guest/arch[@name=\"%s\"]/machine[text()=\"%s\"]/@maxCpus",
                                      ret[i], ret3[k]);
 
                             numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL);
                             if (numTmp == NULL)
-                                add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT);
+                                add_assoc_string(arr2, key, ret3[k] VIRT_COPY_OPT);
                             else {
 #if PHP_MAJOR_VERSION >= 7
                                 zval *arr4, zarr4;
@@ -2598,8 +2598,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types)
 #endif
                                 array_init(arr4);
 
-                                add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT);
-                                add_assoc_string_ex(arr4, "maxCpus", 9, numTmp VIRT_COPY_OPT);
+                                add_assoc_string(arr4, "name", ret3[k] VIRT_COPY_OPT);
+                                add_assoc_string(arr4, "maxCpus", numTmp VIRT_COPY_OPT);
 
                                 add_assoc_zval_ex(arr2, key, strlen(key) + 1, arr4);
                                 free(numTmp);
@@ -2627,7 +2627,7 @@ PHP_FUNCTION(libvirt_connect_get_machine_types)
 
                             numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL);
                             if (numTmp == NULL)
-                                add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT);
+                                add_assoc_string(arr3, key, ret3[k] VIRT_COPY_OPT);
                             else {
 #if PHP_MAJOR_VERSION >= 7
                                 zval *arr4, zarr4;
@@ -2638,8 +2638,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types)
 #endif
                                 array_init(arr4);
 
-                                add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT);
-                                add_assoc_string_ex(arr4, "maxCpus", 9, numTmp VIRT_COPY_OPT);
+                                add_assoc_string(arr4, "name", ret3[k] VIRT_COPY_OPT);
+                                add_assoc_string(arr4, "maxCpus", numTmp VIRT_COPY_OPT);
 
                                 add_assoc_zval_ex(arr3, key, strlen(key) + 1, arr4);
                                 free(numTmp);
@@ -2682,21 +2682,21 @@ PHP_FUNCTION(libvirt_connect_get_information)
     tmp = virConnectGetURI(conn->conn);
     DPRINTF("%s: Got connection URI of %s...\n", PHPFUNC, tmp);
     array_init(return_value);
-    add_assoc_string_ex(return_value, "uri", 4, tmp ? tmp : "unknown" VIRT_COPY_OPT);
+    add_assoc_string(return_value, "uri", tmp ? tmp : "unknown" VIRT_COPY_OPT);
     free(tmp);
     tmp = virConnectGetHostname(conn->conn);
-    add_assoc_string_ex(return_value, "hostname", 9, tmp ? tmp : "unknown" VIRT_COPY_OPT);
+    add_assoc_string(return_value, "hostname", tmp ? tmp : "unknown" VIRT_COPY_OPT);
     free(tmp);
 
     if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn)))
     {
-        add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type VIRT_COPY_OPT);
+        add_assoc_string(return_value, "hypervisor", (char *)type VIRT_COPY_OPT);
         add_assoc_long(return_value, "hypervisor_major",(long)((hvVer/1000000) % 1000));
         add_assoc_long(return_value, "hypervisor_minor",(long)((hvVer/1000) % 1000));
         add_assoc_long(return_value, "hypervisor_release",(long)(hvVer %1000));
         snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type,
                  (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000));
-        add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr VIRT_COPY_OPT);
+        add_assoc_string(return_value, "hypervisor_string", hvStr VIRT_COPY_OPT);
     }
 
     if (strcmp(type, "QEMU") == 0) {
@@ -2709,21 +2709,21 @@ PHP_FUNCTION(libvirt_connect_get_information)
     add_assoc_long(return_value, "hypervisor_maxvcpus", maxvcpus);
     iTmp = virConnectIsEncrypted(conn->conn);
     if (iTmp == 1)
-        add_assoc_string_ex(return_value, "encrypted", 10, "Yes" VIRT_COPY_OPT);
+        add_assoc_string(return_value, "encrypted", "Yes" VIRT_COPY_OPT);
     else
         if (iTmp == 0)
-            add_assoc_string_ex(return_value, "encrypted", 10, "No" VIRT_COPY_OPT);
+            add_assoc_string(return_value, "encrypted", "No" VIRT_COPY_OPT);
         else
-            add_assoc_string_ex(return_value, "encrypted", 10, "unknown" VIRT_COPY_OPT);
+            add_assoc_string(return_value, "encrypted", "unknown" VIRT_COPY_OPT);
 
     iTmp = virConnectIsSecure(conn->conn);
     if (iTmp == 1)
-        add_assoc_string_ex(return_value, "secure", 7, "Yes" VIRT_COPY_OPT);
+        add_assoc_string(return_value, "secure", "Yes" VIRT_COPY_OPT);
     else
         if (iTmp == 0)
-            add_assoc_string_ex(return_value, "secure", 7, "No" VIRT_COPY_OPT);
+            add_assoc_string(return_value, "secure", "No" VIRT_COPY_OPT);
         else
-            add_assoc_string_ex(return_value, "secure", 7, "unknown" VIRT_COPY_OPT);
+            add_assoc_string(return_value, "secure", "unknown" VIRT_COPY_OPT);
 
     add_assoc_long(return_value, "num_inactive_domains", virConnectNumOfDefinedDomains(conn->conn));
     add_assoc_long(return_value, "num_inactive_interfaces", virConnectNumOfDefinedInterfaces(conn->conn));
@@ -2938,14 +2938,14 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor)
     DPRINTF("%s: virConnectGetType returned %s\n", PHPFUNC, type);
 
     array_init(return_value);
-    add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type VIRT_COPY_OPT);
+    add_assoc_string(return_value, "hypervisor", (char *)type VIRT_COPY_OPT);
     add_assoc_long(return_value, "major",(long)((hvVer/1000000) % 1000));
     add_assoc_long(return_value, "minor",(long)((hvVer/1000) % 1000));
     add_assoc_long(return_value, "release",(long)(hvVer %1000));
 
     snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type,
              (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000));
-    add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr VIRT_COPY_OPT);
+    add_assoc_string(return_value, "hypervisor_string", hvStr VIRT_COPY_OPT);
 }
 
 /*
@@ -3045,7 +3045,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats)
                 add_assoc_bool(arr2, params.field, params.value.b);
                 break;
             case VIR_TYPED_PARAM_STRING:
-                add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s VIRT_COPY_OPT);
+                add_assoc_string(arr2, params.field, params.value.s VIRT_COPY_OPT);
                 break;
             }
         }
@@ -3170,7 +3170,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal)
                 value = (char *)xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1);
 
                 snprintf(key, sizeof(key), "%d", i);
-                add_assoc_string_ex(*val, key, strlen(key)+1, value VIRT_COPY_OPT);
+                add_assoc_string(*val, key, value VIRT_COPY_OPT);
                 ret++;
             }
         }
@@ -4658,12 +4658,12 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api)
         if (WEXITSTATUS(exitStatus) != 0)
             RETURN_FALSE;
 
-        add_assoc_string_ex(return_value, "file", 5, fileNew VIRT_COPY_OPT);
-        add_assoc_string_ex(return_value, "mime", 5, "image/png" VIRT_COPY_OPT);
+        add_assoc_string(return_value, "file", fileNew VIRT_COPY_OPT);
+        add_assoc_string(return_value, "mime", "image/png" VIRT_COPY_OPT);
     }
     else {
-        add_assoc_string_ex(return_value, "file", 5, file VIRT_COPY_OPT);
-        add_assoc_string_ex(return_value, "mime", 5, mime VIRT_COPY_OPT);
+        add_assoc_string(return_value, "file", file VIRT_COPY_OPT);
+        add_assoc_string(return_value, "mime", mime VIRT_COPY_OPT);
     }
 }
 
@@ -5220,7 +5220,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models)
             tTokenizer t = tokenize(tmp, ",");
             for (i = 0; i < t.numTokens; i++) {
                 snprintf(tmp2, sizeof(tmp2), "%d", i);
-                add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[i] VIRT_COPY_OPT);
+                add_assoc_string(return_value, tmp2, t.tokens[i] VIRT_COPY_OPT);
             }
             free_tokens(t);
         }
@@ -5318,14 +5318,14 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models)
                 }
 
                 array_init(arr);
-                add_assoc_string_ex(arr, "name", 5, t.tokens[0] VIRT_COPY_OPT);
-                add_assoc_string_ex(arr, "description", 12, desc VIRT_COPY_OPT);
+                add_assoc_string(arr, "name", t.tokens[0] VIRT_COPY_OPT);
+                add_assoc_string(arr, "description", desc VIRT_COPY_OPT);
                 add_next_index_zval(return_value, arr);
             }
             else {
                 char tmp2[16] = { 0 };
                 snprintf(tmp2, sizeof(tmp2), "%d", n++);
-                add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[0] VIRT_COPY_OPT);
+                add_assoc_string(return_value, tmp2, t.tokens[0] VIRT_COPY_OPT);
             }
 
             free_tokens(t);
@@ -6847,8 +6847,8 @@ PHP_FUNCTION(libvirt_domain_get_network_info)
     }
 
     array_init(return_value);
-    add_assoc_string_ex(return_value, "mac", 4, mac VIRT_COPY_OPT);
-    add_assoc_string_ex(return_value, "network", 8, tmp VIRT_COPY_OPT);
+    add_assoc_string(return_value, "mac", mac VIRT_COPY_OPT);
+    add_assoc_string(return_value, "network", tmp VIRT_COPY_OPT);
 
     free(tmp);
     free(xpath);
@@ -6859,9 +6859,9 @@ PHP_FUNCTION(libvirt_domain_get_network_info)
     }
     tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "nic_type", 9, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "nic_type", tmp VIRT_COPY_OPT);
     else
-        add_assoc_string_ex(return_value, "nic_type", 9, "default" VIRT_COPY_OPT);
+        add_assoc_string(return_value, "nic_type", "default" VIRT_COPY_OPT);
 
     free(xml);
     free(xpath);
@@ -6946,12 +6946,12 @@ PHP_FUNCTION(libvirt_domain_get_block_info)
 
     array_init(return_value);
     LONGLONG_INIT;
-    add_assoc_string_ex(return_value, "device", 7, dev VIRT_COPY_OPT);
+    add_assoc_string(return_value, "device", dev VIRT_COPY_OPT);
 
     if (isFile)
-        add_assoc_string_ex(return_value, "file", 5, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "file", tmp VIRT_COPY_OPT);
     else
-        add_assoc_string_ex(return_value, "partition", 10, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "partition", tmp VIRT_COPY_OPT);
 
     free(xpath);
     if (asprintf(&xpath, "//domain/devices/disk/target[@dev='%s']/../driver/@type", dev) < 0) {
@@ -6961,7 +6961,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info)
     free(tmp);
     tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
     if (tmp != NULL)
-        add_assoc_string_ex(return_value, "type", 5, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "type", tmp VIRT_COPY_OPT);
 
     LONGLONG_ASSOC(return_value, "capacity", info.capacity);
     LONGLONG_ASSOC(return_value, "allocation", info.allocation);
@@ -7018,7 +7018,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath)
     if (rc == 0)
         RETURN_FALSE;
 
-    add_assoc_string_ex(return_value, "xpath", 6, (char *)zpath VIRT_COPY_OPT);
+    add_assoc_string(return_value, "xpath", (char *)zpath VIRT_COPY_OPT);
     if (rc < 0)
         add_assoc_long(return_value, "error_code", (long)rc);
 }
@@ -9117,18 +9117,18 @@ PHP_FUNCTION(libvirt_nodedev_get_information)
         goto error;
     }
 
-    add_assoc_string_ex(return_value, "name", 5, tmp VIRT_COPY_OPT);
+    add_assoc_string(return_value, "name", tmp VIRT_COPY_OPT);
 
     /* Get parent name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/parent", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "parent", 7, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "parent", tmp VIRT_COPY_OPT);
 
     /* Get capability */
     cap = get_string_from_xpath(xml, "//device/capability/@type", NULL, &retval);
     if ((cap != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "capability", 11, cap VIRT_COPY_OPT);
+        add_assoc_string(return_value, "capability", cap VIRT_COPY_OPT);
 
     /* System capability is having hardware and firmware sub-blocks */
     if (strcmp(cap, "system") == 0) {
@@ -9136,92 +9136,92 @@ PHP_FUNCTION(libvirt_nodedev_get_information)
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/hardware/vendor", NULL, &retval);
         if ((tmp != NULL) && (retval > 0))
-            add_assoc_string_ex(return_value, "hardware_vendor", 16, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "hardware_vendor", tmp VIRT_COPY_OPT);
 
         /* Get hardware version */
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/hardware/version", NULL, &retval);
         if ((tmp != NULL) && (retval > 0))
-            add_assoc_string_ex(return_value, "hardware_version", 17, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "hardware_version", tmp VIRT_COPY_OPT);
 
         /* Get hardware serial */
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/hardware/serial", NULL, &retval);
         if ((tmp != NULL) && (retval > 0))
-            add_assoc_string_ex(return_value, "hardware_serial", 16, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "hardware_serial", tmp VIRT_COPY_OPT);
 
         /* Get hardware UUID */
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/hardware/uuid", NULL, &retval);
         if (tmp != NULL)
-            add_assoc_string_ex(return_value, "hardware_uuid", 15, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "hardware_uuid", tmp VIRT_COPY_OPT);
 
         /* Get firmware vendor */
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/firmware/vendor", NULL, &retval);
         if ((tmp != NULL) && (retval > 0))
-            add_assoc_string_ex(return_value, "firmware_vendor", 16, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "firmware_vendor", tmp VIRT_COPY_OPT);
 
         /* Get firmware version */
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/firmware/version", NULL, &retval);
         if ((tmp != NULL) && (retval > 0))
-            add_assoc_string_ex(return_value, "firmware_version", 17, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "firmware_version", tmp VIRT_COPY_OPT);
 
         /* Get firmware release date */
         free(tmp);
         tmp = get_string_from_xpath(xml, "//device/capability/firmware/release_date", NULL, &retval);
         if ((tmp != NULL) && (retval > 0))
-            add_assoc_string_ex(return_value, "firmware_release_date", 22, tmp VIRT_COPY_OPT);
+            add_assoc_string(return_value, "firmware_release_date", tmp VIRT_COPY_OPT);
     }
 
     /* Get product_id */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/product/@id", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "product_id", 11, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "product_id",  tmp VIRT_COPY_OPT);
 
     /* Get product_name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/product", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "product_name", 13, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "product_name", tmp VIRT_COPY_OPT);
 
     /* Get vendor_id */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/vendor/@id", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "vendor_id", 10, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "vendor_id", tmp VIRT_COPY_OPT);
 
     /* Get vendor_name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/vendor", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "vendor_name", 12, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "vendor_name", tmp VIRT_COPY_OPT);
 
     /* Get driver name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/driver/name", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "driver_name", 12, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "driver_name", tmp VIRT_COPY_OPT);
 
     /* Get driver name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/interface", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "interface_name", 15, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "interface_name", tmp VIRT_COPY_OPT);
 
     /* Get driver name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/address", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "address", 8, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "address", tmp VIRT_COPY_OPT);
 
     /* Get driver name */
     free(tmp);
     tmp = get_string_from_xpath(xml, "//device/capability/capability/@type", NULL, &retval);
     if ((tmp != NULL) && (retval > 0))
-        add_assoc_string_ex(return_value, "capabilities", 11, tmp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "capabilities", tmp VIRT_COPY_OPT);
 
     free(cap);
     free(tmp);
@@ -9426,42 +9426,42 @@ PHP_FUNCTION(libvirt_network_get_information)
         RETURN_FALSE;
     }
 
-    add_assoc_string_ex(return_value, "name", 5, name VIRT_COPY_OPT);
+    add_assoc_string(return_value, "name", name VIRT_COPY_OPT);
 
     /* Get gateway IP address */
     ipaddr = get_string_from_xpath(xml, "//network/ip/@address", NULL, &retval);
     if (ipaddr && retval > 0)
-        add_assoc_string_ex(return_value, "ip", 3, ipaddr VIRT_COPY_OPT);
+        add_assoc_string(return_value, "ip", ipaddr VIRT_COPY_OPT);
 
     /* Get netmask */
     netmask = get_string_from_xpath(xml, "//network/ip/@netmask", NULL, &retval);
     if (netmask && retval > 0) {
         int subnet_bits = get_subnet_bits(netmask);
-        add_assoc_string_ex(return_value, "netmask", 8, netmask VIRT_COPY_OPT);
+        add_assoc_string(return_value, "netmask", netmask VIRT_COPY_OPT);
         add_assoc_long(return_value, "netmask_bits", (long) subnet_bits);
 
         /* Format CIDR address representation */
         ipaddr[strlen(ipaddr) - 1] = ipaddr[strlen(ipaddr) - 1] - 1;
         snprintf(fixedtemp, sizeof(fixedtemp), "%s/%d", ipaddr, subnet_bits);
-        add_assoc_string_ex(return_value, "ip_range", 9, fixedtemp VIRT_COPY_OPT);
+        add_assoc_string(return_value, "ip_range", fixedtemp VIRT_COPY_OPT);
     }
 
     /* Get forwarding settings */
     mode = get_string_from_xpath(xml, "//network/forward/@mode", NULL, &retval);
     if (mode && retval > 0)
-        add_assoc_string_ex(return_value, "forwarding", 11, mode VIRT_COPY_OPT);
+        add_assoc_string(return_value, "forwarding", mode VIRT_COPY_OPT);
 
     /* Get forwarding settings */
     dev = get_string_from_xpath(xml, "//network/forward/@dev", NULL, &retval);
     if (dev && retval > 0)
-        add_assoc_string_ex(return_value, "forward_dev", 12, dev VIRT_COPY_OPT);
+        add_assoc_string(return_value, "forward_dev", dev VIRT_COPY_OPT);
 
     /* Get DHCP values */
     dhcp_start = get_string_from_xpath(xml, "//network/ip/dhcp/range/@start", NULL, &retval);
     dhcp_end = get_string_from_xpath(xml, "//network/ip/dhcp/range/@end", NULL, &retval);
     if (dhcp_start && dhcp_end && retval > 0) {
-        add_assoc_string_ex(return_value, "dhcp_start", 11, dhcp_start VIRT_COPY_OPT);
-        add_assoc_string_ex(return_value, "dhcp_end", 9, dhcp_end VIRT_COPY_OPT);
+        add_assoc_string(return_value, "dhcp_start", dhcp_start VIRT_COPY_OPT);
+        add_assoc_string(return_value, "dhcp_end", dhcp_end VIRT_COPY_OPT);
     }
 
     free(dhcp_end);
-- 
2.5.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]