[PATCH 06/11] libxl: Don't use a static buffer in xenParseXLVnuma()

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

 



The xenParseXLVnuma() function is responsible for parsing 'vnuma'
part of XL config and setting corresponding values in
virDomainDef. While doing so it uses a static buffer which is set
to data we are interested in and then parsing the buffer further
(e.g. string to integer conversion, bitmap parsing, and so on).
Well, the data we are interested in are already in a string
(@data) which can be used directly rendering this intermediary
buffer needless.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libxl/xen_xl.c | 43 ++++---------------------------------------
 1 file changed, 4 insertions(+), 39 deletions(-)

diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index 6e489f35ad..3a4e21ee0e 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -394,7 +394,6 @@ xenParseXLVnuma(virConf *conf,
                 virDomainDef *def)
 {
     int ret = -1;
-    char *tmp = NULL;
     size_t vcpus = 0;
     size_t nr_nodes = 0;
     size_t vnodeCnt = 0;
@@ -446,19 +445,10 @@ xenParseXLVnuma(virConf *conf,
                 data++;
 
                 if (*data) {
-                    char vtoken[64];
-
                     if (STRPREFIX(str, "pnode")) {
                         unsigned int cellid;
 
-                        if (virStrcpyStatic(vtoken, data) < 0) {
-                            virReportError(VIR_ERR_INTERNAL_ERROR,
-                                           _("vnuma vnode %zu pnode '%s' too long for destination"),
-                                           vnodeCnt, data);
-                            goto cleanup;
-                        }
-
-                        if ((virStrToLong_ui(vtoken, NULL, 10, &cellid) < 0) ||
+                        if ((virStrToLong_ui(data, NULL, 10, &cellid) < 0) ||
                             (cellid >= nr_nodes)) {
                             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                            _("vnuma vnode %zu contains invalid pnode value '%s'"),
@@ -467,27 +457,13 @@ xenParseXLVnuma(virConf *conf,
                         }
                         pnode = cellid;
                     } else if (STRPREFIX(str, "size")) {
-                        if (virStrcpyStatic(vtoken, data) < 0) {
-                            virReportError(VIR_ERR_INTERNAL_ERROR,
-                                           _("vnuma vnode %zu size '%s' too long for destination"),
-                                           vnodeCnt, data);
-                            goto cleanup;
-                        }
-
-                        if (virStrToLong_ull(vtoken, NULL, 10, &kbsize) < 0)
+                        if (virStrToLong_ull(data, NULL, 10, &kbsize) < 0)
                             goto cleanup;
 
                         virDomainNumaSetNodeMemorySize(numa, vnodeCnt, (kbsize * 1024));
 
                     } else if (STRPREFIX(str, "vcpus")) {
-                        if (virStrcpyStatic(vtoken, data) < 0) {
-                            virReportError(VIR_ERR_INTERNAL_ERROR,
-                                           _("vnuma vnode %zu vcpus '%s' too long for destination"),
-                                           vnodeCnt, data);
-                            goto cleanup;
-                        }
-
-                        if (virBitmapParse(vtoken, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
+                        if (virBitmapParse(data, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
                             goto cleanup;
 
                         virDomainNumaSetNodeCpumask(numa, vnodeCnt, cpumask);
@@ -498,17 +474,7 @@ xenParseXLVnuma(virConf *conf,
                         size_t i, ndistances;
                         unsigned int value;
 
-                        if (virStrcpyStatic(vtoken, data) < 0) {
-                            virReportError(VIR_ERR_INTERNAL_ERROR,
-                                           _("vnuma vnode %zu vdistances '%s' too long for destination"),
-                                           vnodeCnt, data);
-                            goto cleanup;
-                        }
-
-                        VIR_FREE(tmp);
-                        tmp = g_strdup(vtoken);
-
-                        if (!(token = g_strsplit(tmp, ",", 0)))
+                        if (!(token = g_strsplit(data, ",", 0)))
                             goto cleanup;
 
                         ndistances = g_strv_length(token);
@@ -571,7 +537,6 @@ xenParseXLVnuma(virConf *conf,
  cleanup:
     if (ret)
         VIR_FREE(cpu);
-    VIR_FREE(tmp);
 
     return ret;
 }
-- 
2.34.1




[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]

  Powered by Linux