]> xenbits.xensource.com Git - libvirt.git/commitdiff
Use g_strdup_printf instead of virAsprintf everywhere
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 22 Oct 2019 13:48:08 +0000 (15:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 12 Nov 2019 15:15:59 +0000 (16:15 +0100)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/admin/libvirt-admin.c
src/driver.c

index 9a18ea0f8b8e0f5d8575ae22d5f778fd92da4f21..f156736d9f997087d064e138ba942e97355523ba 100644 (file)
@@ -141,18 +141,16 @@ getSocketPath(virURIPtr uri)
         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'"),
index 125cf028906a8258e8535a0a387d2f9c89e0c65e..2392fd7d5ffef389af7bf0c3349e9aef39f53e70 100644 (file)
@@ -90,8 +90,7 @@ virDriverShouldAutostart(const char *dir,
 
     *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);
@@ -152,8 +151,7 @@ virGetConnectGeneric(virThreadLocalPtr threadPtr, const char *name)
         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);