From cd6e4e5fe4d636d8c56214a72cc333d1efebccad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 14 Jun 2016 08:02:30 +0200 Subject: [PATCH] cgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape Use virAsprintf to prepend an underscore to make the code more readable. --- src/util/vircgroup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 04f38181e5..07cd7f65c9 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -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; } -- GitLab