[libvirt] [PATCH 67/75] Use g_strdup_printf instead of virAsprintf everywhere

Michal Privoznik mprivozn at redhat.com
Tue Oct 22 13:58:11 UTC 2019


Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/driver.c        | 4 ++--
 src/libvirt-admin.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/driver.c b/src/driver.c
index 89851cb629..2392fd7d5f 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -90,7 +90,7 @@ virDriverShouldAutostart(const char *dir,
 
     *autostart = false;
 
-    virAsprintf(&path, "%s/autostarted", dir);
+    path = g_strdup_printf("%s/autostarted", dir);
 
     if (virFileExists(path)) {
         VIR_DEBUG("Autostart file %s exists, skipping autostart", path);
@@ -151,7 +151,7 @@ virGetConnectGeneric(virThreadLocalPtr threadPtr, const char *name)
         g_autofree char *uri = NULL;
         const char *uriPath = geteuid() == 0 ? "/system" : "/session";
 
-        virAsprintf(&uri, "%s://%s", name, uriPath);
+        uri = g_strdup_printf("%s://%s", name, uriPath);
 
         conn = virConnectOpen(uri);
         VIR_DEBUG("Opened new %s connection %p", name, conn);
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 7ff549bca4..f156736d9f 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -141,16 +141,16 @@ getSocketPath(virURIPtr uri)
         if (legacy) {
             sockbase = g_strdup("libvirt-admin-sock");
         } else {
-            virAsprintf(&sockbase, "%s-admin-sock", uri->scheme);
+            sockbase = g_strdup_printf("%s-admin-sock", uri->scheme);
         }
 
         if (STREQ_NULLABLE(uri->path, "/system")) {
-            virAsprintf(&sock_path, RUNSTATEDIR "/libvirt/%s", sockbase);
+            sock_path = g_strdup_printf(RUNSTATEDIR "/libvirt/%s", sockbase);
         } else if (STREQ_NULLABLE(uri->path, "/session")) {
             if (!rundir)
                 goto error;
 
-            virAsprintf(&sock_path, "%s/%s", rundir, sockbase);
+            sock_path = g_strdup_printf("%s/%s", rundir, sockbase);
         } else {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Invalid URI path '%s', try '/system'"),
-- 
2.21.0




More information about the libvir-list mailing list