mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tools: Use g_strdup_printf() instead of virAsprintf()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
@@ -5523,11 +5523,8 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, const char *mime)
|
||||
localtime_r(&cur_time, &time_info);
|
||||
strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
|
||||
|
||||
if (virAsprintf(&ret, "%s-%s%s", virDomainGetName(dom),
|
||||
timestr, NULLSTR_EMPTY(ext)) < 0) {
|
||||
vshError(ctl, "%s", _("Out of memory"));
|
||||
return NULL;
|
||||
}
|
||||
ret = g_strdup_printf("%s-%s%s", virDomainGetName(dom), timestr,
|
||||
NULLSTR_EMPTY(ext));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -6957,8 +6954,7 @@ virshVcpuPinQuery(vshControl *ctl,
|
||||
cpumaplen)))
|
||||
goto cleanup;
|
||||
|
||||
if (virAsprintf(&vcpuStr, "%zu", i) < 0)
|
||||
goto cleanup;
|
||||
vcpuStr = g_strdup_printf("%zu", i);
|
||||
|
||||
if (vshTableRowAppend(table, vcpuStr, pinInfo, NULL) < 0)
|
||||
goto cleanup;
|
||||
@@ -7574,8 +7570,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
|
||||
g_autofree char *pinInfo = NULL;
|
||||
g_autofree char *iothreadIdStr = NULL;
|
||||
|
||||
if (virAsprintf(&iothreadIdStr, "%u", info[i]->iothread_id) < 0)
|
||||
goto cleanup;
|
||||
iothreadIdStr = g_strdup_printf("%u", info[i]->iothread_id);
|
||||
|
||||
ignore_value(pinInfo = virBitmapDataFormat(info[i]->cpumap, info[i]->cpumaplen));
|
||||
|
||||
@@ -11367,8 +11362,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
/* Create our XPATH lookup for the current display's port */
|
||||
VIR_FREE(xpath);
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@port") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "@port");
|
||||
|
||||
/* Attempt to get the port number for the current graphics scheme */
|
||||
tmp = virXPathInt(xpath, ctxt, &port);
|
||||
@@ -11381,8 +11375,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
/* Create our XPATH lookup for TLS Port (automatically skipped
|
||||
* for unsupported schemes */
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@tlsPort") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "@tlsPort");
|
||||
|
||||
/* Attempt to get the TLS port number */
|
||||
tmp = virXPathInt(xpath, ctxt, &tls_port);
|
||||
@@ -11391,8 +11384,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
tls_port = 0;
|
||||
|
||||
/* Create our XPATH lookup for the current display's address */
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@listen") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "@listen");
|
||||
|
||||
/* Attempt to get the listening addr if set for the current
|
||||
* graphics scheme */
|
||||
@@ -11401,8 +11393,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
VIR_FREE(xpath);
|
||||
|
||||
/* Create our XPATH lookup for the current spice type. */
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@type") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "listen/@type");
|
||||
|
||||
/* Attempt to get the type of spice connection */
|
||||
VIR_FREE(type_conn);
|
||||
@@ -11411,8 +11402,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (STREQ_NULLABLE(type_conn, "socket")) {
|
||||
if (!sockpath) {
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@socket") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "listen/@socket");
|
||||
|
||||
sockpath = virXPathString(xpath, ctxt);
|
||||
|
||||
@@ -11432,8 +11422,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
* subelement (which, by the way, doesn't exist on libvirt
|
||||
* < 0.9.4, so we really do need to check both places)
|
||||
*/
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@address") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "listen/@address");
|
||||
|
||||
listen_addr = virXPathString(xpath, ctxt);
|
||||
VIR_FREE(xpath);
|
||||
@@ -11469,8 +11458,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
||||
* care of when getting the XML */
|
||||
|
||||
/* Create our XPATH lookup for the password */
|
||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@passwd") < 0)
|
||||
goto cleanup;
|
||||
xpath = g_strdup_printf(xpath_fmt, scheme[iter], "@passwd");
|
||||
|
||||
/* Attempt to get the password */
|
||||
VIR_FREE(passwd);
|
||||
|
||||
Reference in New Issue
Block a user