]> xenbits.xensource.com Git - libvirt.git/commitdiff
cgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape
authorJán Tomko <jtomko@redhat.com>
Tue, 14 Jun 2016 06:02:30 +0000 (08:02 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 26 Jul 2016 08:41:26 +0000 (10:41 +0200)
Use virAsprintf to prepend an underscore to make the code more
readable.

src/util/vircgroup.c

index 04f38181e56a956f2830b4ae12340d921f5cc844..07cd7f65c96500ca341cb5694d174ee57df469ed 100644 (file)
@@ -231,16 +231,18 @@ virCgroupPartitionNeedsEscaping(const char *path)
 static int
 virCgroupPartitionEscape(char **path)
 {
-    size_t len = strlen(*path) + 1;
     int rc;
-    char escape = '_';
+    char *newstr = NULL;
 
     if ((rc = virCgroupPartitionNeedsEscaping(*path)) <= 0)
         return rc;
 
-    if (VIR_INSERT_ELEMENT(*path, 0, len, escape) < 0)
+    if (virAsprintf(&newstr, "_%s", *path) < 0)
         return -1;
 
+    VIR_FREE(*path);
+    *path = newstr;
+
     return 0;
 }