mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
virDomainGenerateMachineName: Use g_autofree for @username
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
06a19921b6
commit
1dd3282873
@ -31080,18 +31080,17 @@ virDomainGenerateMachineName(const char *drivername,
|
|||||||
const char *name,
|
const char *name,
|
||||||
bool privileged)
|
bool privileged)
|
||||||
{
|
{
|
||||||
char *username = NULL;
|
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (privileged) {
|
if (privileged) {
|
||||||
virBufferAsprintf(&buf, "%s-", drivername);
|
virBufferAsprintf(&buf, "%s-", drivername);
|
||||||
} else {
|
} else {
|
||||||
|
g_autofree char *username = NULL;
|
||||||
if (!(username = virGetUserName(geteuid()))) {
|
if (!(username = virGetUserName(geteuid()))) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
|
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
|
||||||
VIR_FREE(username);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "%d-", id);
|
virBufferAsprintf(&buf, "%d-", id);
|
||||||
|
Loading…
Reference in New Issue
Block a user