Re: [PATCH 44/75] libxl: Use g_strdup_printf() instead of virAsprintf()

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

 



On Tue, Oct 22, 2019 at 03:57:48PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
src/libxl/libxl_conf.c      | 22 +++++++++++-----------
src/libxl/libxl_domain.c    | 15 +++++++--------
src/libxl/libxl_driver.c    | 12 ++++++------
src/libxl/libxl_logger.c    |  8 ++++----
src/libxl/libxl_migration.c |  6 +++---
src/libxl/xen_common.c      | 10 +++++-----
src/libxl/xen_xl.c          | 12 ++++++------
src/libxl/xen_xm.c          |  4 ++--
8 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index a984c9c8aa..1ff2a6af07 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -231,8 +231,8 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
        if (bindService == NULL)
            bindService = "0";

-        virAsprintf(buf, "udp:%s:%s@%s:%s", connectHost,
-                    srcdef->data.udp.connectService, bindHost, bindService);
+        *buf = g_strdup_printf("udp:%s:%s@%s:%s", connectHost,
+                              srcdef->data.udp.connectService, bindHost, bindService);

Misaligned.

        break;
    }

@@ -244,15 +244,15 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
        else
            prefix = "tcp";

-        virAsprintf(buf, "%s:%s:%s%s", prefix, srcdef->data.tcp.host,
-                    srcdef->data.tcp.service,
-                    srcdef->data.tcp.listen ? ",server,nowait" : "");
+        *buf = g_strdup_printf("%s:%s:%s%s", prefix, srcdef->data.tcp.host,
+                              srcdef->data.tcp.service,
+                              srcdef->data.tcp.listen ? ",server,nowait" : "");

Misaligned.
        break;
    }

    case VIR_DOMAIN_CHR_TYPE_UNIX:
-        virAsprintf(buf, "unix:%s%s", srcdef->data.nix.path,
-                    srcdef->data.nix.listen ? ",server,nowait" : "");
+        *buf = g_strdup_printf("unix:%s%s", srcdef->data.nix.path,
+                              srcdef->data.nix.listen ? ",server,nowait" : "");

Misaligned.

        break;

    default:
@@ -1927,9 +1927,9 @@ libxlPrepareChannel(virDomainChrDefPtr channel,
    if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN &&
        channel->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
        !channel->source->data.nix.path) {
-        virAsprintf(&channel->source->data.nix.path, "%s/%s-%s", channelDir,
-                    domainName,
-                    channel->target.name ? channel->target.name : "unknown.sock");
+        channel->source->data.nix.path = g_strdup_printf("%s/%s-%s", channelDir,
+                                                         domainName,
+                                                         channel->target.name ? channel->target.name : "unknown.sock");

Way too long line, consider using a temporary variable for either target
name or the whole path.


        channel->source->data.nix.listen = true;
    }

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
However I do have comments on the cleanup counterpart.

Jano

Attachment: signature.asc
Description: PGP signature

--
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