[libvirt] [PATCH 44/75] libxl: Use g_strdup_printf() instead of virAsprintf()
Ján Tomko
jtomko at redhat.com
Tue Oct 22 21:11:47 UTC 2019
On Tue, Oct 22, 2019 at 03:57:48PM +0200, Michal Privoznik wrote:
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> 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 at redhat.com>
However I do have comments on the cleanup counterpart.
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20191022/90a0399a/attachment-0001.sig>
More information about the libvir-list
mailing list