提交 265d0bed 编写于 作者: M Martin Kletzander

conf: Clean up and report error in virDomainGenerateMachineName

Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 2a544e31
...@@ -27481,25 +27481,23 @@ virDomainGenerateMachineName(const char *drivername, ...@@ -27481,25 +27481,23 @@ virDomainGenerateMachineName(const char *drivername,
const char *name, const char *name,
bool privileged) bool privileged)
{ {
char *machinename = NULL;
char *username = NULL; 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 {
if (!(username = virGetUserName(geteuid()))) if (!(username = virGetUserName(geteuid()))) {
goto cleanup; virBufferFreeAndReset(&buf);
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);
virDomainMachineNameAppendValid(&buf, name); virDomainMachineNameAppendValid(&buf, name);
machinename = virBufferContentAndReset(&buf); virBufferCheckError(&buf);
cleanup: return virBufferContentAndReset(&buf);
VIR_FREE(username);
return machinename;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册