From 5858950a85555e7578345257cb4f6313c06f2d77 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 22 Oct 2019 15:26:14 +0200 Subject: [PATCH] hyperv: Use g_strdup_printf() instead of virAsprintf() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/hyperv/hyperv_driver.c | 11 ++++------- src/hyperv/hyperv_wmi.c | 23 ++++++++--------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 0378478fc7..ac10f86b82 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1375,11 +1375,9 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset, } } - if (virAsprintf(&selector, - "CreationClassName=Msvm_Keyboard&DeviceID=%s&" - "SystemCreationClassName=Msvm_ComputerSystem&" - "SystemName=%s", keyboard->data.common->DeviceID, uuid_string) < 0) - goto cleanup; + selector = g_strdup_printf("CreationClassName=Msvm_Keyboard&DeviceID=%s&" + "SystemCreationClassName=Msvm_ComputerSystem&" + "SystemName=%s", keyboard->data.common->DeviceID, uuid_string); /* press the keys */ for (i = 0; i < nkeycodes; i++) { @@ -1461,8 +1459,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, virCheckFlags(0, -1); - if (virAsprintf(&memory_str, "%lu", memory_mb) < 0) - goto cleanup; + memory_str = g_strdup_printf("%lu", memory_mb); virUUIDFormat(domain->uuid, uuid_string); diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index a70093700a..7d56677588 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -439,8 +439,7 @@ hypervCreateInvokeXmlDoc(hypervInvokeParamsListPtr params, WsXmlDocH *docRoot) char *method = NULL; WsXmlNodeH xmlNodeMethod = NULL; - if (virAsprintf(&method, "%s_INPUT", params->method) < 0) - goto cleanup; + method = g_strdup_printf("%s_INPUT", params->method); *docRoot = ws_xml_create_doc(NULL, method); if (*docRoot == NULL) { @@ -844,9 +843,8 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params, params->method, paramsDocRoot); /* check return code of invocation */ - if (virAsprintf(&returnValue_xpath, "/s:Envelope/s:Body/p:%s_OUTPUT/p:ReturnValue", - params->method) < 0) - goto cleanup; + returnValue_xpath = g_strdup_printf("/s:Envelope/s:Body/p:%s_OUTPUT/p:ReturnValue", + params->method); returnValue = ws_xml_get_xpath_value(response, returnValue_xpath); if (!returnValue) { @@ -860,12 +858,9 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params, goto cleanup; if (returnCode == CIM_RETURNCODE_TRANSITION_STARTED) { - if (virAsprintf(&jobcode_instance_xpath, - "/s:Envelope/s:Body/p:%s_OUTPUT/p:Job/a:ReferenceParameters/" - "w:SelectorSet/w:Selector[@Name='InstanceID']", - params->method) < 0) { - goto cleanup; - } + jobcode_instance_xpath = g_strdup_printf("/s:Envelope/s:Body/p:%s_OUTPUT/p:Job/a:ReferenceParameters/" + "w:SelectorSet/w:Selector[@Name='InstanceID']", + params->method); instanceID = ws_xml_get_xpath_value(response, jobcode_instance_xpath); if (!instanceID) { @@ -1331,10 +1326,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, virUUIDFormat(domain->uuid, uuid_string); - if (virAsprintf(&selector, "Name=%s&CreationClassName=Msvm_ComputerSystem", - uuid_string) < 0 || - virAsprintf(&properties, "RequestedState=%d", requestedState) < 0) - goto cleanup; + selector = g_strdup_printf("Name=%s&CreationClassName=Msvm_ComputerSystem", uuid_string); + properties = g_strdup_printf("RequestedState=%d", requestedState); if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) resourceUri = MSVM_COMPUTERSYSTEM_V1_RESOURCE_URI;