[PATCH 48/75] network: Use g_strdup_printf() instead of virAsprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 58 ++++++++++++++++++-------------------
 src/network/leaseshelper.c  |  4 +--
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b82a371fe4..5d424e3681 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -371,7 +371,7 @@ networkDnsmasqLeaseFileNameDefault(virNetworkDriverStatePtr driver,
 {
     char *leasefile;
 
-    virAsprintf(&leasefile, "%s/%s.leases", driver->dnsmasqStateDir, netname);
+    leasefile = g_strdup_printf("%s/%s.leases", driver->dnsmasqStateDir, netname);
     return leasefile;
 }
 
@@ -382,7 +382,7 @@ networkDnsmasqLeaseFileNameCustom(virNetworkDriverStatePtr driver,
 {
     char *leasefile;
 
-    virAsprintf(&leasefile, "%s/%s.status", driver->dnsmasqStateDir, bridge);
+    leasefile = g_strdup_printf("%s/%s.status", driver->dnsmasqStateDir, bridge);
     return leasefile;
 }
 
@@ -393,7 +393,7 @@ networkDnsmasqConfigFileName(virNetworkDriverStatePtr driver,
 {
     char *conffile;
 
-    virAsprintf(&conffile, "%s/%s.conf", driver->dnsmasqStateDir, netname);
+    conffile = g_strdup_printf("%s/%s.conf", driver->dnsmasqStateDir, netname);
     return conffile;
 }
 
@@ -404,7 +404,7 @@ networkRadvdPidfileBasename(const char *netname)
     /* this is simple but we want to be sure it's consistently done */
     char *pidfilebase;
 
-    virAsprintf(&pidfilebase, "%s-radvd", netname);
+    pidfilebase = g_strdup_printf("%s-radvd", netname);
     return pidfilebase;
 }
 
@@ -415,7 +415,7 @@ networkRadvdConfigFileName(virNetworkDriverStatePtr driver,
 {
     char *configfile;
 
-    virAsprintf(&configfile, "%s/%s-radvd.conf", driver->radvdStateDir, netname);
+    configfile = g_strdup_printf("%s/%s-radvd.conf", driver->radvdStateDir, netname);
     return configfile;
 }
 
@@ -511,13 +511,13 @@ networkBridgeDummyNicName(const char *brname)
          * a possible numeric ending (eg virbr0, virbr1, etc), we grab
          * the first 8 and last 3 characters of the string.
          */
-        virAsprintf(&nicname, "%.*s%s%s",
-                    /* space for last 3 chars + "-nic" + NULL */
-                    (int)(IFNAMSIZ - (3 + sizeof(dummyNicSuffix))),
-                    brname, brname + strlen(brname) - 3,
-                    dummyNicSuffix);
+        nicname = g_strdup_printf("%.*s%s%s",
+                                  /* space for last 3 chars + "-nic" + NULL */
+                                  (int)(IFNAMSIZ - (3 + sizeof(dummyNicSuffix))),
+                                  brname, brname + strlen(brname) - 3,
+                                  dummyNicSuffix);
     } else {
-        virAsprintf(&nicname, "%s%s", brname, dummyNicSuffix);
+        nicname = g_strdup_printf("%s%s", brname, dummyNicSuffix);
     }
     return nicname;
 }
@@ -747,18 +747,18 @@ networkStateInitialize(bool privileged,
         if (!(configdir && rundir))
             goto error;
 
-        virAsprintf(&network_driver->networkConfigDir,
-                    "%s/qemu/networks", configdir);
-        virAsprintf(&network_driver->networkAutostartDir,
-                    "%s/qemu/networks/autostart", configdir);
-        virAsprintf(&network_driver->stateDir,
-                    "%s/network/lib", rundir);
-        virAsprintf(&network_driver->pidDir,
-                    "%s/network/run", rundir);
-        virAsprintf(&network_driver->dnsmasqStateDir,
-                    "%s/dnsmasq/lib", rundir);
-        virAsprintf(&network_driver->radvdStateDir,
-                    "%s/radvd/lib", rundir);
+        network_driver->networkConfigDir = g_strdup_printf(
+                                                           "%s/qemu/networks", configdir);
+        network_driver->networkAutostartDir = g_strdup_printf(
+                                                              "%s/qemu/networks/autostart", configdir);
+        network_driver->stateDir = g_strdup_printf(
+                                                   "%s/network/lib", rundir);
+        network_driver->pidDir = g_strdup_printf(
+                                                 "%s/network/run", rundir);
+        network_driver->dnsmasqStateDir = g_strdup_printf(
+                                                          "%s/dnsmasq/lib", rundir);
+        network_driver->radvdStateDir = g_strdup_printf(
+                                                        "%s/radvd/lib", rundir);
     }
 
     if (virFileMakePath(network_driver->stateDir) < 0) {
@@ -2294,8 +2294,8 @@ networkSetIPv6Sysctls(virNetworkObjPtr obj)
      * network. But also unset it if there *are* ipv6 addresses, as we
      * can't be sure of its default value.
      */
-    virAsprintf(&field, SYSCTL_PATH "/net/ipv6/conf/%s/disable_ipv6",
-                def->bridge);
+    field = g_strdup_printf(SYSCTL_PATH "/net/ipv6/conf/%s/disable_ipv6",
+                            def->bridge);
 
     if (access(field, W_OK) < 0 && errno == ENOENT) {
         if (!enableIPv6)
@@ -2320,8 +2320,8 @@ networkSetIPv6Sysctls(virNetworkObjPtr obj)
     /* Prevent guests from hijacking the host network by sending out
      * their own router advertisements.
      */
-    virAsprintf(&field, SYSCTL_PATH "/net/ipv6/conf/%s/accept_ra",
-                def->bridge);
+    field = g_strdup_printf(SYSCTL_PATH "/net/ipv6/conf/%s/accept_ra",
+                            def->bridge);
 
     if (virFileWriteStr(field, "0", 0) < 0) {
         virReportSystemError(errno,
@@ -2333,7 +2333,7 @@ networkSetIPv6Sysctls(virNetworkObjPtr obj)
     /* All interfaces used as a gateway (which is what this is, by
      * definition), must always have autoconf=0.
      */
-    virAsprintf(&field, SYSCTL_PATH "/net/ipv6/conf/%s/autoconf", def->bridge);
+    field = g_strdup_printf(SYSCTL_PATH "/net/ipv6/conf/%s/autoconf", def->bridge);
 
     if (virFileWriteStr(field, "0", 0) < 0) {
         virReportSystemError(errno,
@@ -3318,7 +3318,7 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets,
         templ = def->bridge;
 
     do {
-        virAsprintf(&newname, templ, id);
+        newname = g_strdup_printf(templ, id);
         /* check if this name is used in another libvirt network or
          * there is an existing device with that name. ignore errors
          * from virNetDevExists(), just in case it isn't implemented
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index 008a2d668d..3058a3c038 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -153,8 +153,8 @@ main(int argc, char **argv)
 
     server_duid = g_strdup(getenv("DNSMASQ_SERVER_DUID"));
 
-    virAsprintf(&custom_lease_file,
-                LOCALSTATEDIR "/lib/libvirt/dnsmasq/%s.status", interface);
+    custom_lease_file = g_strdup_printf(
+                                        LOCALSTATEDIR "/lib/libvirt/dnsmasq/%s.status", interface);
 
     pid_file = g_strdup(RUNSTATEDIR "/leaseshelper.pid");
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux