mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 13:35:17 +00:00
admin: Use g_autofree in getSocketPath()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ac5a58dad6
commit
1be7136495
@ -99,12 +99,12 @@ virAdmInitialize(void)
|
|||||||
static char *
|
static char *
|
||||||
getSocketPath(virURIPtr uri)
|
getSocketPath(virURIPtr uri)
|
||||||
{
|
{
|
||||||
char *rundir = virGetUserRuntimeDirectory();
|
g_autofree char *rundir = virGetUserRuntimeDirectory();
|
||||||
char *sock_path = NULL;
|
g_autofree char *sock_path = NULL;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
if (!uri)
|
if (!uri)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < uri->paramsCount; i++) {
|
for (i = 0; i < uri->paramsCount; i++) {
|
||||||
@ -116,7 +116,7 @@ getSocketPath(virURIPtr uri)
|
|||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Unknown URI parameter '%s'"), param->name);
|
_("Unknown URI parameter '%s'"), param->name);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ getSocketPath(virURIPtr uri)
|
|||||||
if (!uri->scheme) {
|
if (!uri->scheme) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
"%s", _("No URI scheme specified"));
|
"%s", _("No URI scheme specified"));
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (STREQ(uri->scheme, "libvirtd")) {
|
if (STREQ(uri->scheme, "libvirtd")) {
|
||||||
legacy = true;
|
legacy = true;
|
||||||
@ -135,7 +135,7 @@ getSocketPath(virURIPtr uri)
|
|||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Unsupported URI scheme '%s'"),
|
_("Unsupported URI scheme '%s'"),
|
||||||
uri->scheme);
|
uri->scheme);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (legacy) {
|
if (legacy) {
|
||||||
@ -148,24 +148,18 @@ getSocketPath(virURIPtr uri)
|
|||||||
sock_path = g_strdup_printf(RUNSTATEDIR "/libvirt/%s", sockbase);
|
sock_path = g_strdup_printf(RUNSTATEDIR "/libvirt/%s", sockbase);
|
||||||
} else if (STREQ_NULLABLE(uri->path, "/session")) {
|
} else if (STREQ_NULLABLE(uri->path, "/session")) {
|
||||||
if (!rundir)
|
if (!rundir)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
sock_path = g_strdup_printf("%s/%s", rundir, sockbase);
|
sock_path = g_strdup_printf("%s/%s", rundir, sockbase);
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Invalid URI path '%s', try '/system'"),
|
_("Invalid URI path '%s', try '/system'"),
|
||||||
NULLSTR_EMPTY(uri->path));
|
NULLSTR_EMPTY(uri->path));
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return g_steal_pointer(&sock_path);
|
||||||
VIR_FREE(rundir);
|
|
||||||
return sock_path;
|
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(sock_path);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user