hyperv: Use g_strdup_printf() instead of virAsprintf()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2019-10-22 15:26:14 +02:00
parent 8cc297932a
commit 5858950a85
2 changed files with 12 additions and 22 deletions

View File

@ -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);

View File

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