提交 f7ac4f7e 编写于 作者: M Marcos Paulo de Souza 提交者: Michal Privoznik

esx: Use ESX_VI_CHECK_ARG_LIST macro to avoid code duplication

By using this macro we can avoid boilerplate code to check for arrays of
objects from ESX driver. This replacement was done using the coccinelle
script bellow:

@@
identifier ptr;
@@

-if (!ptr || *ptr) { ... }
+ESX_VI_CHECK_ARG_LIST(ptr);
Signed-off-by: NMarcos Paulo de Souza <marcos.souza.org@gmail.com>
上级 03212ab9
...@@ -626,10 +626,7 @@ esxConnectToHost(esxPrivate *priv, ...@@ -626,10 +626,7 @@ esxConnectToHost(esxPrivate *priv,
? esxVI_ProductLine_ESX ? esxVI_ProductLine_ESX
: esxVI_ProductLine_GSX; : esxVI_ProductLine_GSX;
if (!vCenterIPAddress || *vCenterIPAddress) { ESX_VI_CHECK_ARG_LIST(vCenterIPAddress);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0) if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0)
return -1; return -1;
......
...@@ -220,10 +220,7 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth, ...@@ -220,10 +220,7 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
{ {
int result = -1; int result = -1;
if (!shapingPolicy || *shapingPolicy) { ESX_VI_CHECK_ARG_LIST(shapingPolicy);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (!bandwidth->in || !bandwidth->out || if (!bandwidth->in || !bandwidth->out ||
bandwidth->in->average != bandwidth->out->average || bandwidth->in->average != bandwidth->out->average ||
...@@ -589,10 +586,7 @@ static int ...@@ -589,10 +586,7 @@ static int
esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy, esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy,
virNetDevBandwidthPtr *bandwidth) virNetDevBandwidthPtr *bandwidth)
{ {
if (!bandwidth || *bandwidth) { ESX_VI_CHECK_ARG_LIST(bandwidth);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True) if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True)
return 0; return 0;
......
...@@ -48,10 +48,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri) ...@@ -48,10 +48,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
int autoAnswer; int autoAnswer;
char *tmp; char *tmp;
if (!parsedUri || *parsedUri) { ESX_VI_CHECK_ARG_LIST(parsedUri);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (VIR_ALLOC(*parsedUri) < 0) if (VIR_ALLOC(*parsedUri) < 0)
return -1; return -1;
......
...@@ -51,10 +51,7 @@ VIR_LOG_INIT("esx.esx_vi"); ...@@ -51,10 +51,7 @@ VIR_LOG_INIT("esx.esx_vi");
int \ int \
esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \ esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
{ \ { \
if (!ptrptr || *ptrptr) { \ ESX_VI_CHECK_ARG_LIST(ptrptr); \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
return -1; \
} \
\ \
if (VIR_ALLOC(*ptrptr) < 0) \ if (VIR_ALLOC(*ptrptr) < 0) \
return -1; \ return -1; \
...@@ -372,10 +369,7 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content, ...@@ -372,10 +369,7 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
virBuffer buffer = VIR_BUFFER_INITIALIZER; virBuffer buffer = VIR_BUFFER_INITIALIZER;
int responseCode = 0; int responseCode = 0;
if (!content || *content) { ESX_VI_CHECK_ARG_LIST(content);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (length && *length > 0) { if (length && *length > 0) {
/* /*
...@@ -1762,10 +1756,7 @@ esxVI_List_DeepCopy(esxVI_List **destList, esxVI_List *srcList, ...@@ -1762,10 +1756,7 @@ esxVI_List_DeepCopy(esxVI_List **destList, esxVI_List *srcList,
esxVI_List *dest = NULL; esxVI_List *dest = NULL;
esxVI_List *src = NULL; esxVI_List *src = NULL;
if (!destList || *destList) { ESX_VI_CHECK_ARG_LIST(destList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (src = srcList; src; src = src->_next) { for (src = srcList; src; src = src->_next) {
if (deepCopyFunc(&dest, src) < 0 || if (deepCopyFunc(&dest, src) < 0 ||
...@@ -2170,10 +2161,7 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, ...@@ -2170,10 +2161,7 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
bool propertySpec_isAppended = false; bool propertySpec_isAppended = false;
esxVI_PropertyFilterSpec *propertyFilterSpec = NULL; esxVI_PropertyFilterSpec *propertyFilterSpec = NULL;
if (!objectContentList || *objectContentList) { ESX_VI_CHECK_ARG_LIST(objectContentList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0)
return -1; return -1;
...@@ -2372,10 +2360,7 @@ esxVI_GetVirtualMachineQuestionInfo ...@@ -2372,10 +2360,7 @@ esxVI_GetVirtualMachineQuestionInfo
{ {
esxVI_DynamicProperty *dynamicProperty; esxVI_DynamicProperty *dynamicProperty;
if (!questionInfo || *questionInfo) { ESX_VI_CHECK_ARG_LIST(questionInfo);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = virtualMachine->propSet; dynamicProperty; for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) { dynamicProperty = dynamicProperty->_next) {
...@@ -2447,10 +2432,7 @@ esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName, ...@@ -2447,10 +2432,7 @@ esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
{ {
esxVI_DynamicProperty *dynamicProperty; esxVI_DynamicProperty *dynamicProperty;
if (!value || *value) { ESX_VI_CHECK_ARG_LIST(value);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = objectContent->propSet; dynamicProperty; for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) { dynamicProperty = dynamicProperty->_next) {
...@@ -2479,10 +2461,7 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName, ...@@ -2479,10 +2461,7 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
{ {
esxVI_DynamicProperty *dynamicProperty; esxVI_DynamicProperty *dynamicProperty;
if (!value || *value) { ESX_VI_CHECK_ARG_LIST(value);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = objectContent->propSet; dynamicProperty; for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) { dynamicProperty = dynamicProperty->_next) {
...@@ -2512,10 +2491,7 @@ esxVI_GetStringValue(esxVI_ObjectContent *objectContent, ...@@ -2512,10 +2491,7 @@ esxVI_GetStringValue(esxVI_ObjectContent *objectContent,
{ {
esxVI_DynamicProperty *dynamicProperty; esxVI_DynamicProperty *dynamicProperty;
if (!value || *value) { ESX_VI_CHECK_ARG_LIST(value);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = objectContent->propSet; dynamicProperty; for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) { dynamicProperty = dynamicProperty->_next) {
...@@ -2549,10 +2525,7 @@ esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent, ...@@ -2549,10 +2525,7 @@ esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent,
{ {
esxVI_DynamicProperty *dynamicProperty; esxVI_DynamicProperty *dynamicProperty;
if (!value || *value) { ESX_VI_CHECK_ARG_LIST(value);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = objectContent->propSet; dynamicProperty; for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) { dynamicProperty = dynamicProperty->_next) {
...@@ -2863,10 +2836,7 @@ esxVI_GetSnapshotTreeBySnapshot ...@@ -2863,10 +2836,7 @@ esxVI_GetSnapshotTreeBySnapshot
{ {
esxVI_VirtualMachineSnapshotTree *candidate; esxVI_VirtualMachineSnapshotTree *candidate;
if (!snapshotTree || *snapshotTree) { ESX_VI_CHECK_ARG_LIST(snapshotTree);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (candidate = snapshotTreeList; candidate; for (candidate = snapshotTreeList; candidate;
candidate = candidate->_next) { candidate = candidate->_next) {
...@@ -2928,10 +2898,7 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned char *uuid, ...@@ -2928,10 +2898,7 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned char *uuid,
esxVI_ManagedObjectReference *managedObjectReference = NULL; esxVI_ManagedObjectReference *managedObjectReference = NULL;
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
if (!virtualMachine || *virtualMachine) { ESX_VI_CHECK_ARG_LIST(virtualMachine);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
virUUIDFormat(uuid, uuid_string); virUUIDFormat(uuid, uuid_string);
...@@ -2983,10 +2950,7 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char *name, ...@@ -2983,10 +2950,7 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char *name,
esxVI_ObjectContent *candidate = NULL; esxVI_ObjectContent *candidate = NULL;
char *name_candidate = NULL; char *name_candidate = NULL;
if (!virtualMachine || *virtualMachine) { ESX_VI_CHECK_ARG_LIST(virtualMachine);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_DeepCopyList(&completePropertyNameList, if (esxVI_String_DeepCopyList(&completePropertyNameList,
propertyNameList) < 0 || propertyNameList) < 0 ||
...@@ -3110,10 +3074,7 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name, ...@@ -3110,10 +3074,7 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name,
esxVI_ObjectContent *candidate = NULL; esxVI_ObjectContent *candidate = NULL;
char *name_candidate; char *name_candidate;
if (!datastore || *datastore) { ESX_VI_CHECK_ARG_LIST(datastore);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* Get all datastores */ /* Get all datastores */
if (esxVI_String_DeepCopyList(&completePropertyNameList, if (esxVI_String_DeepCopyList(&completePropertyNameList,
...@@ -3177,10 +3138,7 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx, ...@@ -3177,10 +3138,7 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
esxVI_DatastoreHostMount *datastoreHostMountList = NULL; esxVI_DatastoreHostMount *datastoreHostMountList = NULL;
esxVI_DatastoreHostMount *datastoreHostMount = NULL; esxVI_DatastoreHostMount *datastoreHostMount = NULL;
if (!datastore || *datastore) { ESX_VI_CHECK_ARG_LIST(datastore);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* Get all datastores */ /* Get all datastores */
if (esxVI_String_DeepCopyList(&completePropertyNameList, if (esxVI_String_DeepCopyList(&completePropertyNameList,
...@@ -3263,10 +3221,7 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx, ...@@ -3263,10 +3221,7 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
esxVI_DatastoreHostMount *hostMountList = NULL; esxVI_DatastoreHostMount *hostMountList = NULL;
esxVI_DatastoreHostMount *candidate = NULL; esxVI_DatastoreHostMount *candidate = NULL;
if (!hostMount || *hostMount) { ESX_VI_CHECK_ARG_LIST(hostMount);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList, "host") < 0 || if (esxVI_String_AppendValueToList(&propertyNameList, "host") < 0 ||
esxVI_LookupObjectContentByType(ctx, datastore, "Datastore", esxVI_LookupObjectContentByType(ctx, datastore, "Datastore",
...@@ -3327,10 +3282,7 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx, ...@@ -3327,10 +3282,7 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx,
esxVI_ObjectContent *objectContent = NULL; esxVI_ObjectContent *objectContent = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!taskInfo || *taskInfo) { ESX_VI_CHECK_ARG_LIST(taskInfo);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0 || if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0 ||
esxVI_LookupObjectContentByType(ctx, task, "Task", propertyNameList, esxVI_LookupObjectContentByType(ctx, task, "Task", propertyNameList,
...@@ -3375,10 +3327,7 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine ...@@ -3375,10 +3327,7 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_TaskInfo *taskInfo = NULL; esxVI_TaskInfo *taskInfo = NULL;
if (!pendingTaskInfoList || *pendingTaskInfoList) { ESX_VI_CHECK_ARG_LIST(pendingTaskInfoList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* Get list of recent tasks */ /* Get list of recent tasks */
for (dynamicProperty = virtualMachine->propSet; dynamicProperty; for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
...@@ -3481,10 +3430,7 @@ esxVI_LookupRootSnapshotTreeList ...@@ -3481,10 +3430,7 @@ esxVI_LookupRootSnapshotTreeList
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!rootSnapshotTreeList || *rootSnapshotTreeList) { ESX_VI_CHECK_ARG_LIST(rootSnapshotTreeList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList, if (esxVI_String_AppendValueToList(&propertyNameList,
"snapshot.rootSnapshotList") < 0 || "snapshot.rootSnapshotList") < 0 ||
...@@ -3536,10 +3482,7 @@ esxVI_LookupCurrentSnapshotTree ...@@ -3536,10 +3482,7 @@ esxVI_LookupCurrentSnapshotTree
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL; esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL; esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
if (!currentSnapshotTree || *currentSnapshotTree) { ESX_VI_CHECK_ARG_LIST(currentSnapshotTree);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueListToList(&propertyNameList, if (esxVI_String_AppendValueListToList(&propertyNameList,
"snapshot.currentSnapshot\0" "snapshot.currentSnapshot\0"
...@@ -3633,10 +3576,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, ...@@ -3633,10 +3576,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
esxVI_TaskInfo *taskInfo = NULL; esxVI_TaskInfo *taskInfo = NULL;
esxVI_HostDatastoreBrowserSearchResults *searchResults = NULL; esxVI_HostDatastoreBrowserSearchResults *searchResults = NULL;
if (!fileInfo || *fileInfo) { ESX_VI_CHECK_ARG_LIST(fileInfo);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxUtil_ParseDatastorePath(datastorePath, &datastoreName, if (esxUtil_ParseDatastorePath(datastorePath, &datastoreName,
&directoryName, &directoryAndFileName) < 0) { &directoryName, &directoryAndFileName) < 0) {
...@@ -3829,10 +3769,7 @@ esxVI_LookupDatastoreContentByDatastoreName ...@@ -3829,10 +3769,7 @@ esxVI_LookupDatastoreContentByDatastoreName
char *taskInfoErrorMessage = NULL; char *taskInfoErrorMessage = NULL;
esxVI_TaskInfo *taskInfo = NULL; esxVI_TaskInfo *taskInfo = NULL;
if (!searchResultsList || *searchResultsList) { ESX_VI_CHECK_ARG_LIST(searchResultsList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* Lookup Datastore and HostDatastoreBrowser */ /* Lookup Datastore and HostDatastoreBrowser */
if (esxVI_String_AppendValueToList(&propertyNameList, "browser") < 0 || if (esxVI_String_AppendValueToList(&propertyNameList, "browser") < 0 ||
...@@ -3941,10 +3878,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx, ...@@ -3941,10 +3878,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx,
esxVI_FileInfo *fileInfo = NULL; esxVI_FileInfo *fileInfo = NULL;
char *uuid_string = NULL; char *uuid_string = NULL;
if (!key || *key) { ESX_VI_CHECK_ARG_LIST(key);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (ctx->hasQueryVirtualDiskUuid) { if (ctx->hasQueryVirtualDiskUuid) {
if (esxVI_LookupFileInfoByDatastorePath if (esxVI_LookupFileInfoByDatastorePath
...@@ -3995,10 +3929,7 @@ esxVI_LookupAutoStartDefaults(esxVI_Context *ctx, ...@@ -3995,10 +3929,7 @@ esxVI_LookupAutoStartDefaults(esxVI_Context *ctx,
esxVI_ObjectContent *hostAutoStartManager = NULL; esxVI_ObjectContent *hostAutoStartManager = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!defaults || *defaults) { ESX_VI_CHECK_ARG_LIST(defaults);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* /*
* Lookup HostAutoStartManagerConfig from the HostAutoStartManager because * Lookup HostAutoStartManagerConfig from the HostAutoStartManager because
...@@ -4052,10 +3983,7 @@ esxVI_LookupAutoStartPowerInfoList(esxVI_Context *ctx, ...@@ -4052,10 +3983,7 @@ esxVI_LookupAutoStartPowerInfoList(esxVI_Context *ctx,
esxVI_ObjectContent *hostAutoStartManager = NULL; esxVI_ObjectContent *hostAutoStartManager = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!powerInfoList || *powerInfoList) { ESX_VI_CHECK_ARG_LIST(powerInfoList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* /*
* Lookup HostAutoStartManagerConfig from the HostAutoStartManager because * Lookup HostAutoStartManagerConfig from the HostAutoStartManager because
...@@ -4103,10 +4031,7 @@ esxVI_LookupPhysicalNicList(esxVI_Context *ctx, ...@@ -4103,10 +4031,7 @@ esxVI_LookupPhysicalNicList(esxVI_Context *ctx,
esxVI_ObjectContent *hostSystem = NULL; esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!physicalNicList || *physicalNicList) { ESX_VI_CHECK_ARG_LIST(physicalNicList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList, if (esxVI_String_AppendValueToList(&propertyNameList,
"config.network.pnic") < 0 || "config.network.pnic") < 0 ||
...@@ -4147,10 +4072,7 @@ esxVI_LookupPhysicalNicByName(esxVI_Context *ctx, const char *name, ...@@ -4147,10 +4072,7 @@ esxVI_LookupPhysicalNicByName(esxVI_Context *ctx, const char *name,
esxVI_PhysicalNic *physicalNicList = NULL; esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *candidate = NULL; esxVI_PhysicalNic *candidate = NULL;
if (!physicalNic || *physicalNic) { ESX_VI_CHECK_ARG_LIST(physicalNic);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0)
goto cleanup; goto cleanup;
...@@ -4194,10 +4116,7 @@ esxVI_LookupPhysicalNicByMACAddress(esxVI_Context *ctx, const char *mac, ...@@ -4194,10 +4116,7 @@ esxVI_LookupPhysicalNicByMACAddress(esxVI_Context *ctx, const char *mac,
esxVI_PhysicalNic *physicalNicList = NULL; esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *candidate = NULL; esxVI_PhysicalNic *candidate = NULL;
if (!physicalNic || *physicalNic) { ESX_VI_CHECK_ARG_LIST(physicalNic);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0)
goto cleanup; goto cleanup;
...@@ -4241,10 +4160,7 @@ esxVI_LookupHostVirtualSwitchList(esxVI_Context *ctx, ...@@ -4241,10 +4160,7 @@ esxVI_LookupHostVirtualSwitchList(esxVI_Context *ctx,
esxVI_ObjectContent *hostSystem = NULL; esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!hostVirtualSwitchList || *hostVirtualSwitchList) { ESX_VI_CHECK_ARG_LIST(hostVirtualSwitchList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList, if (esxVI_String_AppendValueToList(&propertyNameList,
"config.network.vswitch") < 0 || "config.network.vswitch") < 0 ||
...@@ -4285,10 +4201,7 @@ esxVI_LookupHostVirtualSwitchByName(esxVI_Context *ctx, const char *name, ...@@ -4285,10 +4201,7 @@ esxVI_LookupHostVirtualSwitchByName(esxVI_Context *ctx, const char *name,
esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL; esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL;
esxVI_HostVirtualSwitch *candidate = NULL; esxVI_HostVirtualSwitch *candidate = NULL;
if (!hostVirtualSwitch || *hostVirtualSwitch) { ESX_VI_CHECK_ARG_LIST(hostVirtualSwitch);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0) if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0)
goto cleanup; goto cleanup;
...@@ -4336,10 +4249,7 @@ esxVI_LookupHostPortGroupList(esxVI_Context *ctx, ...@@ -4336,10 +4249,7 @@ esxVI_LookupHostPortGroupList(esxVI_Context *ctx,
esxVI_ObjectContent *hostSystem = NULL; esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
if (!hostPortGroupList || *hostPortGroupList) { ESX_VI_CHECK_ARG_LIST(hostPortGroupList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList, if (esxVI_String_AppendValueToList(&propertyNameList,
"config.network.portgroup") < 0 || "config.network.portgroup") < 0 ||
...@@ -4513,10 +4423,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, ...@@ -4513,10 +4423,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
bool blocked; bool blocked;
esxVI_TaskInfo *taskInfo = NULL; esxVI_TaskInfo *taskInfo = NULL;
if (!errorMessage || *errorMessage) { ESX_VI_CHECK_ARG_LIST(errorMessage);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (VIR_STRDUP(version, "") < 0) if (VIR_STRDUP(version, "") < 0)
return -1; return -1;
...@@ -4982,10 +4889,7 @@ esxVI_LookupHostScsiTopologyLunListByTargetName ...@@ -4982,10 +4889,7 @@ esxVI_LookupHostScsiTopologyLunListByTargetName
bool found = false; bool found = false;
esxVI_HostInternetScsiTargetTransport *candidate = NULL; esxVI_HostInternetScsiTargetTransport *candidate = NULL;
if (!hostScsiTopologyLunList || *hostScsiTopologyLunList) { ESX_VI_CHECK_ARG_LIST(hostScsiTopologyLunList);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList if (esxVI_String_AppendValueToList
(&propertyNameList, (&propertyNameList,
...@@ -5076,10 +4980,7 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx, ...@@ -5076,10 +4980,7 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx,
esxVI_HostScsiTopologyLun *hostScsiTopologyLun; esxVI_HostScsiTopologyLun *hostScsiTopologyLun;
bool found = false; bool found = false;
if (!poolName || *poolName) { ESX_VI_CHECK_ARG_LIST(poolName);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_AppendValueToList if (esxVI_String_AppendValueToList
(&propertyNameList, (&propertyNameList,
......
...@@ -38,10 +38,7 @@ ...@@ -38,10 +38,7 @@
#define ESX_VI__METHOD__CHECK_OUTPUT__NotNone \ #define ESX_VI__METHOD__CHECK_OUTPUT__NotNone \
if (!output || *output) { \ ESX_VI_CHECK_ARG_LIST(output);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
return -1; \
}
...@@ -232,10 +229,7 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx, ...@@ -232,10 +229,7 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx,
ESX_VI__SOAP__REQUEST_FOOTER; ESX_VI__SOAP__REQUEST_FOOTER;
esxVI_Response *response = NULL; esxVI_Response *response = NULL;
if (!serviceContent || *serviceContent) { ESX_VI_CHECK_ARG_LIST(serviceContent);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request, if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request,
&response, esxVI_Occurrence_RequiredItem) < 0 || &response, esxVI_Occurrence_RequiredItem) < 0 ||
......
...@@ -43,10 +43,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); ...@@ -43,10 +43,7 @@ VIR_LOG_INIT("esx.esx_vi_types");
int \ int \
esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \ esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \
{ \ { \
if (!ptrptr || *ptrptr) { \ ESX_VI_CHECK_ARG_LIST(ptrptr); \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
return -1; \
} \
\ \
if (VIR_ALLOC(*ptrptr) < 0) \ if (VIR_ALLOC(*ptrptr) < 0) \
return -1; \ return -1; \
...@@ -101,11 +98,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); ...@@ -101,11 +98,7 @@ VIR_LOG_INIT("esx.esx_vi_types");
int \ int \
esxVI_##_type##_DeepCopy(esxVI_##_type **dest, esxVI_##_type *src) \ esxVI_##_type##_DeepCopy(esxVI_##_type **dest, esxVI_##_type *src) \
{ \ { \
if (!dest || *dest) { \ ESX_VI_CHECK_ARG_LIST(dest); \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \
} \
\ \
if (!src) { \ if (!src) { \
return 0; \ return 0; \
...@@ -940,10 +933,7 @@ esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type) ...@@ -940,10 +933,7 @@ esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type)
int int
esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
{ {
if (!dest || *dest) { ESX_VI_CHECK_ARG_LIST(dest);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (!src) if (!src)
return 0; return 0;
...@@ -1009,10 +999,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -1009,10 +999,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
{ {
long long int number; long long int number;
if (!anyType || *anyType) { ESX_VI_CHECK_ARG_LIST(anyType);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_AnyType_Alloc(anyType) < 0) if (esxVI_AnyType_Alloc(anyType) < 0)
return -1; return -1;
...@@ -1218,10 +1205,7 @@ ESX_VI__TEMPLATE__LIST__DEEP_COPY(String) ...@@ -1218,10 +1205,7 @@ ESX_VI__TEMPLATE__LIST__DEEP_COPY(String)
int int
esxVI_String_DeepCopyValue(char **dest, const char *src) esxVI_String_DeepCopyValue(char **dest, const char *src)
{ {
if (!dest || *dest) { ESX_VI_CHECK_ARG_LIST(dest);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (!src) if (!src)
return 0; return 0;
...@@ -1270,10 +1254,7 @@ esxVI_String_SerializeValue(const char *value, const char *element, ...@@ -1270,10 +1254,7 @@ esxVI_String_SerializeValue(const char *value, const char *element,
int int
esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string) esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string)
{ {
if (!string || *string) { ESX_VI_CHECK_ARG_LIST(string);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_String_Alloc(string) < 0 || if (esxVI_String_Alloc(string) < 0 ||
esxVI_String_DeserializeValue(node, &(*string)->value) < 0) { esxVI_String_DeserializeValue(node, &(*string)->value) < 0) {
...@@ -1294,10 +1275,7 @@ ESX_VI__TEMPLATE__LIST__DESERIALIZE(String) ...@@ -1294,10 +1275,7 @@ ESX_VI__TEMPLATE__LIST__DESERIALIZE(String)
int int
esxVI_String_DeserializeValue(xmlNodePtr node, char **value) esxVI_String_DeserializeValue(xmlNodePtr node, char **value)
{ {
if (!value || *value) { ESX_VI_CHECK_ARG_LIST(value);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
*value = (char *)xmlNodeListGetString(node->doc, node->children, 1); *value = (char *)xmlNodeListGetString(node->doc, node->children, 1);
...@@ -1472,10 +1450,7 @@ ESX_VI__TEMPLATE__SERIALIZE(DateTime, ...@@ -1472,10 +1450,7 @@ ESX_VI__TEMPLATE__SERIALIZE(DateTime,
int int
esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime) esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
{ {
if (!dateTime || *dateTime) { ESX_VI_CHECK_ARG_LIST(dateTime);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_DateTime_Alloc(dateTime) < 0) if (esxVI_DateTime_Alloc(dateTime) < 0)
return -1; return -1;
...@@ -1644,10 +1619,7 @@ ESX_VI__TEMPLATE__FREE(MethodFault, ...@@ -1644,10 +1619,7 @@ ESX_VI__TEMPLATE__FREE(MethodFault,
int int
esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault) esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault)
{ {
if (!methodFault || *methodFault) { ESX_VI_CHECK_ARG_LIST(methodFault);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_MethodFault_Alloc(methodFault) < 0) if (esxVI_MethodFault_Alloc(methodFault) < 0)
return -1; return -1;
...@@ -1738,10 +1710,7 @@ int ...@@ -1738,10 +1710,7 @@ int
esxVI_ManagedObjectReference_Deserialize esxVI_ManagedObjectReference_Deserialize
(xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference) (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference)
{ {
if (!managedObjectReference || *managedObjectReference) { ESX_VI_CHECK_ARG_LIST(managedObjectReference);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0) if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0)
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册