]> xenbits.xensource.com Git - libvirt.git/commitdiff
Adapt to new VIR_STRNDUP behavior
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 24 May 2013 09:21:36 +0000 (11:21 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 24 May 2013 15:00:39 +0000 (17:00 +0200)
With previous patch, we accept negative value as length of string to
duplicate. So there is no need to pass strlen(src) in case we want to do
duplicate the whole string.

src/conf/domain_conf.c
src/qemu/qemu_command.c
src/util/virsexpr.c
src/xenxs/xen_sxpr.c

index ad5550c54032808061ba5f14b763db4ee2ecbc75..a9656aff369a87602d706b09bc3ac80b4183b820 100644 (file)
@@ -17370,8 +17370,7 @@ virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
         return 0;
     }
 
-    if (VIR_STRNDUP(listenInfo->address, address,
-                    len == -1 ? strlen(address) : len) < 0)
+    if (VIR_STRNDUP(listenInfo->address, address, len) < 0)
         return -1;
     return 0;
 }
@@ -17409,8 +17408,7 @@ virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
         return 0;
     }
 
-    if (VIR_STRNDUP(listenInfo->network, network,
-                    len == -1 ? strlen(network) : len) < 0)
+    if (VIR_STRNDUP(listenInfo->network, network, len) < 0)
         return -1;
     return 0;
 }
index 434f5a78bdee4efa73d69980822edf458a978396..0373626556e7af718a2e8fa38d7c5d0fde92d25d 100644 (file)
@@ -8674,7 +8674,7 @@ static int qemuStringToArgvEnv(const char *args,
         if (!next)
             next = strchr(curr, '\n');
 
-        if (VIR_STRNDUP(arg, curr, next ? next - curr : strlen(curr)) < 0)
+        if (VIR_STRNDUP(arg, curr, next ? next - curr : -1) < 0)
             goto error;
 
         if (next && (*next == '\'' || *next == '"'))
@@ -9566,16 +9566,14 @@ qemuParseCommandLineChr(virDomainChrSourceDefPtr source,
         if (VIR_STRNDUP(source->data.tcp.host, val, svc - val) < 0)
             goto error;
         svc++;
-        if (VIR_STRNDUP(source->data.tcp.service, svc,
-                        opt ? opt - svc : strlen(svc)) < 0)
+        if (VIR_STRNDUP(source->data.tcp.service, svc, opt ? opt - svc : -1) < 0)
             goto error;
     } else if (STRPREFIX(val, "unix:")) {
         const char *opt;
         val += strlen("unix:");
         opt = strchr(val, ',');
         source->type = VIR_DOMAIN_CHR_TYPE_UNIX;
-        if (VIR_STRNDUP(source->data.nix.path, val,
-                        opt ? opt - val : strlen(val)) < 0)
+        if (VIR_STRNDUP(source->data.nix.path, val, opt ? opt - val : -1) < 0)
             goto error;
 
     } else if (STRPREFIX(val, "/dev")) {
@@ -9634,7 +9632,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
             next++;
 
         if (p == val) {
-            if (VIR_STRNDUP(model, p, next ? next - p - 1 : strlen(p)) < 0)
+            if (VIR_STRNDUP(model, p, next ? next - p - 1 : -1) < 0)
                 goto error;
 
             if (!STREQ(model, "qemu32") && !STREQ(model, "qemu64")) {
@@ -9658,7 +9656,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
             if (*p == '\0' || *p == ',')
                 goto syntax;
 
-            if (VIR_STRNDUP(feature, p, next ? next - p - 1 : strlen(p)) < 0)
+            if (VIR_STRNDUP(feature, p, next ? next - p - 1 : -1) < 0)
                 goto error;
 
             if (STREQ(feature, "kvmclock")) {
@@ -9717,7 +9715,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
             if (*p == '\0' || *p == ',')
                 goto syntax;
 
-            if (VIR_STRNDUP(feature, p, next ? next - p - 1 : strlen(p)) < 0)
+            if (VIR_STRNDUP(feature, p, next ? next - p - 1 : -1) < 0)
                 goto error;
 
             dom->features |= (1 << VIR_DOMAIN_FEATURE_HYPERV);
index c75dfd928ef388021da64163d100286410a5b82c..7db215a7a11d1c835af79a3948e8fc8a0bd55103 100644 (file)
@@ -120,7 +120,7 @@ sexpr_string(const char *str, ssize_t len)
         return ret;
     ret->kind = SEXPR_VALUE;
 
-    if (VIR_STRNDUP(ret->u.value, str, len > 0 ? len : strlen(str)) < 0)
+    if (VIR_STRNDUP(ret->u.value, str, len) < 0)
         VIR_FREE(ret);
 
     return ret;
index c17aa5d1a46e96a4f152a4bcc3f9c42879e352fd..394b81417a36d5409260ff03bffc4def3b526e40 100644 (file)
@@ -242,7 +242,7 @@ xenParseSxprChar(const char *value,
         offset2 = strchr(offset, ',');
         offset++;
         if (VIR_STRNDUP(def->source.data.tcp.service, offset,
-                        offset2 ? offset2 - offset : strlen(offset)) < 0)
+                        offset2 ? offset2 - offset : -1) < 0)
             goto error;
 
         if (offset2 && strstr(offset2, ",server"))
@@ -296,7 +296,7 @@ xenParseSxprChar(const char *value,
     {
         const char *offset = strchr(value, ',');
         if (VIR_STRNDUP(def->source.data.nix.path, value,
-                        offset ? offset - value : strlen(value)) < 0)
+                        offset ? offset - value : -1) < 0)
             goto error;
 
         if (offset != NULL &&