if (legacy) {
sockbase = g_strdup("libvirt-admin-sock");
} else {
- if (virAsprintf(&sockbase, "%s-admin-sock", uri->scheme) < 0)
- goto error;
+ sockbase = g_strdup_printf("%s-admin-sock", uri->scheme);
}
if (STREQ_NULLABLE(uri->path, "/system")) {
- if (virAsprintf(&sock_path, RUNSTATEDIR "/libvirt/%s",
- sockbase) < 0)
- goto error;
+ sock_path = g_strdup_printf(RUNSTATEDIR "/libvirt/%s", sockbase);
} else if (STREQ_NULLABLE(uri->path, "/session")) {
- if (!rundir || virAsprintf(&sock_path, "%s/%s", rundir,
- sockbase) < 0)
+ if (!rundir)
goto error;
+
+ sock_path = g_strdup_printf("%s/%s", rundir, sockbase);
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid URI path '%s', try '/system'"),
*autostart = false;
- if (virAsprintf(&path, "%s/autostarted", dir) < 0)
- return -1;
+ path = g_strdup_printf("%s/autostarted", dir);
if (virFileExists(path)) {
VIR_DEBUG("Autostart file %s exists, skipping autostart", path);
g_autofree char *uri = NULL;
const char *uriPath = geteuid() == 0 ? "/system" : "/session";
- if (virAsprintf(&uri, "%s://%s", name, uriPath) < 0)
- return NULL;
+ uri = g_strdup_printf("%s://%s", name, uriPath);
conn = virConnectOpen(uri);
VIR_DEBUG("Opened new %s connection %p", name, conn);