]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Use virStringReplace instead of openvz_replace
authorJán Tomko <jtomko@redhat.com>
Fri, 27 Jun 2014 07:32:38 +0000 (09:32 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 3 Jul 2014 08:41:15 +0000 (10:41 +0200)
This function didn't report an error on OOM. Better delete it
and use virStringReplace instead. :)

src/openvz/openvz_conf.c

index dc84b298606d29e6d7b0c8bfbd247b92b65b1e89..38d3ea72e1f6f4627bfdabfd2c1b9ee0d62883fc 100644 (file)
@@ -343,40 +343,6 @@ openvzReadNetworkConf(virDomainDefPtr def,
 }
 
 
-/* utility function to replace 'from' by 'to' in 'str' */
-static char*
-openvz_replace(const char* str,
-               const char* from,
-               const char* to) {
-    const char* offset = NULL;
-    const char* str_start = str;
-    int to_len;
-    int from_len;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
-
-    if ((!from) || (!to))
-        return NULL;
-    from_len = strlen(from);
-    to_len = strlen(to);
-
-    while ((offset = strstr(str_start, from)))
-    {
-        virBufferAdd(&buf, str_start, offset-str_start);
-        virBufferAdd(&buf, to, to_len);
-        str_start = offset + from_len;
-    }
-
-    virBufferAdd(&buf, str_start, -1);
-
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        return NULL;
-    }
-
-    return virBufferContentAndReset(&buf);
-}
-
-
 static int
 openvzReadFSConf(virDomainDefPtr def,
                  int veid)
@@ -418,8 +384,8 @@ openvzReadFSConf(virDomainDefPtr def,
             goto error;
 
         fs->type = VIR_DOMAIN_FS_TYPE_MOUNT;
-        if (!(fs->src = openvz_replace(temp, "$VEID", veid_str)))
-            goto no_memory;
+        if (!(fs->src = virStringReplace(temp, "$VEID", veid_str)))
+            goto error;
 
         VIR_FREE(veid_str);
     }
@@ -454,8 +420,6 @@ openvzReadFSConf(virDomainDefPtr def,
     VIR_FREE(temp);
 
     return 0;
- no_memory:
-    virReportOOMError();
  error:
     VIR_FREE(temp);
     virDomainFSDefFree(fs);