mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
cgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape
Use virAsprintf to prepend an underscore to make the code more readable.
This commit is contained in:
parent
cabae63194
commit
cd6e4e5fe4
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user