[libvirt] [PATCH] cgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape

Martin Kletzander mkletzan at redhat.com
Mon Jul 25 14:57:20 UTC 2016


On Mon, Jul 25, 2016 at 03:53:42PM +0200, Ján Tomko wrote:
>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 04f3818..07cd7f6 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)

Wow, what a gross hack to prepend a character =D

ACK

>+    if (virAsprintf(&newstr, "_%s", *path) < 0)
>         return -1;
>
>+    VIR_FREE(*path);
>+    *path = newstr;
>+
>     return 0;
> }
>
>--
>2.7.3
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160725/7d3c86f8/attachment-0001.sig>


More information about the libvir-list mailing list