virDomainGenerateMachineName: Use g_autofree for @username

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2020-03-18 15:45:07 +01:00
parent 06a19921b6
commit 1dd3282873

View File

@ -31080,18 +31080,17 @@ virDomainGenerateMachineName(const char *drivername,
const char *name,
bool privileged)
{
char *username = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (privileged) {
virBufferAsprintf(&buf, "%s-", drivername);
} else {
g_autofree char *username = NULL;
if (!(username = virGetUserName(geteuid()))) {
virBufferFreeAndReset(&buf);
return NULL;
}
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
VIR_FREE(username);
}
virBufferAsprintf(&buf, "%d-", id);