mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
esx: use g_auto() for all virBuffers
Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2a15aa090d
commit
2ab37b6b90
@ -275,7 +275,7 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
|
|||||||
esxVI_ObjectContent *datastore = NULL;
|
esxVI_ObjectContent *datastore = NULL;
|
||||||
esxVI_DatastoreHostMount *hostMount = NULL;
|
esxVI_DatastoreHostMount *hostMount = NULL;
|
||||||
char separator = '/';
|
char separator = '/';
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
@ -336,10 +336,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
|
|||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (! success) {
|
if (! success)
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
VIR_FREE(result);
|
VIR_FREE(result);
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(datastoreName);
|
VIR_FREE(datastoreName);
|
||||||
VIR_FREE(directoryAndFileName);
|
VIR_FREE(directoryAndFileName);
|
||||||
@ -2359,7 +2357,7 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr stream,
|
|||||||
esxVI_String *propertyNameList = NULL;
|
esxVI_String *propertyNameList = NULL;
|
||||||
esxVI_ObjectContent *virtualMachine = NULL;
|
esxVI_ObjectContent *virtualMachine = NULL;
|
||||||
esxVI_VirtualMachinePowerState powerState;
|
esxVI_VirtualMachinePowerState powerState;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
@ -2413,7 +2411,6 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
|
|
||||||
esxVI_String_Free(&propertyNameList);
|
esxVI_String_Free(&propertyNameList);
|
||||||
esxVI_ObjectContent_Free(&virtualMachine);
|
esxVI_ObjectContent_Free(&virtualMachine);
|
||||||
@ -2579,7 +2576,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
char *datastoreName = NULL;
|
char *datastoreName = NULL;
|
||||||
char *directoryName = NULL;
|
char *directoryName = NULL;
|
||||||
char *directoryAndFileName = NULL;
|
char *directoryAndFileName = NULL;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
char *vmx = NULL;
|
char *vmx = NULL;
|
||||||
virVMXContext ctx;
|
virVMXContext ctx;
|
||||||
@ -2653,9 +2650,6 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!url)
|
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
|
|
||||||
esxVI_String_Free(&propertyNameList);
|
esxVI_String_Free(&propertyNameList);
|
||||||
esxVI_ObjectContent_Free(&virtualMachine);
|
esxVI_ObjectContent_Free(&virtualMachine);
|
||||||
VIR_FREE(moref);
|
VIR_FREE(moref);
|
||||||
@ -2936,7 +2930,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
|||||||
char *datastoreName = NULL;
|
char *datastoreName = NULL;
|
||||||
char *directoryName = NULL;
|
char *directoryName = NULL;
|
||||||
char *escapedName = NULL;
|
char *escapedName = NULL;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
char *datastoreRelatedPath = NULL;
|
char *datastoreRelatedPath = NULL;
|
||||||
esxVI_String *propertyNameList = NULL;
|
esxVI_String *propertyNameList = NULL;
|
||||||
@ -3124,9 +3118,6 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
|||||||
/* FIXME: Add proper rollback in case of an error */
|
/* FIXME: Add proper rollback in case of an error */
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!url)
|
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
|
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
VIR_FREE(vmx);
|
VIR_FREE(vmx);
|
||||||
VIR_FREE(datastoreName);
|
VIR_FREE(datastoreName);
|
||||||
|
@ -357,7 +357,7 @@ esxUtil_EscapeBase64(const char *string)
|
|||||||
static const char *base64 =
|
static const char *base64 =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
|
||||||
|
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
const char *tmp1 = string;
|
const char *tmp1 = string;
|
||||||
size_t length;
|
size_t length;
|
||||||
unsigned char c1, c2, c3;
|
unsigned char c1, c2, c3;
|
||||||
@ -456,7 +456,7 @@ esxUtil_EscapeDatastoreItem(const char *string)
|
|||||||
char *
|
char *
|
||||||
esxUtil_EscapeForXml(const char *string)
|
esxUtil_EscapeForXml(const char *string)
|
||||||
{
|
{
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
virBufferEscapeString(&buffer, "%s", string);
|
virBufferEscapeString(&buffer, "%s", string);
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
|
|||||||
unsigned long long offset, unsigned long long *length)
|
unsigned long long offset, unsigned long long *length)
|
||||||
{
|
{
|
||||||
char *range = NULL;
|
char *range = NULL;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
int responseCode = 0;
|
int responseCode = 0;
|
||||||
|
|
||||||
ESX_VI_CHECK_ARG_LIST(content);
|
ESX_VI_CHECK_ARG_LIST(content);
|
||||||
@ -421,10 +421,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(range);
|
VIR_FREE(range);
|
||||||
|
|
||||||
if (!(*content)) {
|
if (!(*content))
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1025,7 +1023,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
char *saveptr = NULL;
|
char *saveptr = NULL;
|
||||||
char *previousItem = NULL;
|
char *previousItem = NULL;
|
||||||
char *item = NULL;
|
char *item = NULL;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
esxVI_ManagedObjectReference *root = NULL;
|
esxVI_ManagedObjectReference *root = NULL;
|
||||||
esxVI_Folder *folder = NULL;
|
esxVI_Folder *folder = NULL;
|
||||||
|
|
||||||
@ -1184,9 +1182,6 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0)
|
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
|
|
||||||
if (root != ctx->service->rootFolder &&
|
if (root != ctx->service->rootFolder &&
|
||||||
(!ctx->datacenter || root != ctx->datacenter->hostFolder)) {
|
(!ctx->datacenter || root != ctx->datacenter->hostFolder)) {
|
||||||
esxVI_ManagedObjectReference_Free(&root);
|
esxVI_ManagedObjectReference_Free(&root);
|
||||||
@ -1248,7 +1243,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
|
|||||||
esxVI_Occurrence occurrence)
|
esxVI_Occurrence occurrence)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
esxVI_Fault *fault = NULL;
|
esxVI_Fault *fault = NULL;
|
||||||
char *xpathExpression = NULL;
|
char *xpathExpression = NULL;
|
||||||
xmlXPathContextPtr xpathContext = NULL;
|
xmlXPathContextPtr xpathContext = NULL;
|
||||||
@ -1408,7 +1403,6 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
esxVI_Response_Free(response);
|
esxVI_Response_Free(response);
|
||||||
esxVI_Fault_Free(&fault);
|
esxVI_Fault_Free(&fault);
|
||||||
}
|
}
|
||||||
@ -4130,7 +4124,7 @@ esxVI_HandleVirtualMachineQuestion
|
|||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
esxVI_ElementDescription *elementDescription = NULL;
|
esxVI_ElementDescription *elementDescription = NULL;
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
||||||
esxVI_ElementDescription *answerChoice = NULL;
|
esxVI_ElementDescription *answerChoice = NULL;
|
||||||
int answerIndex = 0;
|
int answerIndex = 0;
|
||||||
char *possibleAnswers = NULL;
|
char *possibleAnswers = NULL;
|
||||||
@ -4212,9 +4206,6 @@ esxVI_HandleVirtualMachineQuestion
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0)
|
|
||||||
virBufferFreeAndReset(&buffer);
|
|
||||||
|
|
||||||
VIR_FREE(possibleAnswers);
|
VIR_FREE(possibleAnswers);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
{ \
|
{ \
|
||||||
int result = -1; \
|
int result = -1; \
|
||||||
const char *methodName = #_name; \
|
const char *methodName = #_name; \
|
||||||
virBuffer buffer = VIR_BUFFER_INITIALIZER; \
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER; \
|
||||||
char *request = NULL; \
|
char *request = NULL; \
|
||||||
esxVI_Response *response = NULL; \
|
esxVI_Response *response = NULL; \
|
||||||
\
|
\
|
||||||
@ -136,10 +136,6 @@
|
|||||||
result = 0; \
|
result = 0; \
|
||||||
\
|
\
|
||||||
cleanup: \
|
cleanup: \
|
||||||
if (result < 0) { \
|
|
||||||
virBufferFreeAndReset(&buffer); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
VIR_FREE(request); \
|
VIR_FREE(request); \
|
||||||
esxVI_Response_Free(&response); \
|
esxVI_Response_Free(&response); \
|
||||||
\
|
\
|
||||||
|
Loading…
Reference in New Issue
Block a user