Skip to content

Commit 19ffc93

Browse files
committed
Fixed few coverity reported issues:Aug22 2014
1 parent 6c0a4f7 commit 19ffc93

14 files changed

Lines changed: 66 additions & 51 deletions

File tree

‎api/src/com/cloud/agent/api/to/VirtualMachineTO.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class VirtualMachineTO {
5050
String platformEmulator;
5151
String bootArgs;
5252
String[] bootupScripts;
53-
boolean rebootOnCrash;
5453
boolean enableHA;
5554
boolean limitCpuUse;
5655
boolean enableDynamicallyScaleVm;

‎api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ public void execute() throws ConcurrentOperationException, ResourceUnavailableEx
127127
VirtualRouterProvider result = _service.get(0).configure(this);
128128
if (result != null) {
129129
VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
130-
routerResponse.setResponseName(getCommandName());
131-
this.setResponseObject(routerResponse);
130+
if(routerResponse != null) {
131+
routerResponse.setResponseName(getCommandName());
132+
this.setResponseObject(routerResponse);
133+
}
132134
} else {
133135
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the virtual router provider");
134136
}

‎api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ public void execute() {
110110
VirtualRouterProvider result = _service.get(0).getCreatedElement(getEntityId());
111111
if (result != null) {
112112
VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
113-
response.setResponseName(getCommandName());
114-
this.setResponseObject(response);
113+
if(response != null) {
114+
response.setResponseName(getCommandName());
115+
this.setResponseObject(response);
116+
}
115117
} else {
116118
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
117119
}

‎api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ public void execute() {
8080
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> trafficTypes = _networkService.listTrafficTypes(getPhysicalNetworkId());
8181
ListResponse<TrafficTypeResponse> response = new ListResponse<TrafficTypeResponse>();
8282
List<TrafficTypeResponse> trafficTypesResponses = new ArrayList<TrafficTypeResponse>();
83-
for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
84-
TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
85-
trafficTypesResponses.add(trafficTypeResponse);
83+
if(trafficTypes != null) {
84+
for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
85+
TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
86+
trafficTypesResponses.add(trafficTypeResponse);
87+
}
88+
response.setResponses(trafficTypesResponses, trafficTypes.second());
89+
response.setResponseName(getCommandName());
8690
}
87-
88-
response.setResponses(trafficTypesResponses, trafficTypes.second());
89-
response.setResponseName(getCommandName());
9091
this.setResponseObject(response);
9192
}
9293
}

‎api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ public long getEntityOwnerId() {
7575
public void execute() {
7676
String[] keys = _accountService.createApiKeyAndSecretKey(this);
7777
RegisterResponse response = new RegisterResponse();
78-
response.setApiKey(keys[0]);
79-
response.setSecretKey(keys[1]);
78+
if (keys != null) {
79+
response.setApiKey(keys[0]);
80+
response.setSecretKey(keys[1]);
81+
}
8082
response.setObjectName("userkeys");
8183
response.setResponseName(getCommandName());
8284
this.setResponseObject(response);

‎api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public String getEndIp() {
129129
}
130130

131131
public Boolean isForVirtualNetwork() {
132-
return forVirtualNetwork == null ? true : forVirtualNetwork;
132+
return forVirtualNetwork == null ? Boolean.TRUE : forVirtualNetwork;
133133
}
134134

135135
public String getGateway() {

‎api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ public Long getNetworkId() {
172172
}
173173
Long zoneId = getZoneId();
174174

175-
if (zoneId == null) {
176-
return null;
177-
}
178-
179175
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
180176
if (zone.getNetworkType() == NetworkType.Advanced) {
181177
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));

‎api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
127127
NetworkRuleConflictException {
128128

129129
IpAddress result = _networkService.updateIP(getId(), getCustomId(), getDisplayIp());
130-
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
131-
ipResponse.setResponseName(getCommandName());
132-
setResponseObject(ipResponse);
130+
if(result != null) {
131+
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
132+
ipResponse.setResponseName(getCommandName());
133+
setResponseObject(ipResponse);
134+
}
133135
}
134136
}

‎engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,14 +749,15 @@ public void doInTransactionWithoutResult(TransactionStatus status) throws Insuff
749749
}
750750

751751
Pair<NicProfile, Integer> vmNicPair = allocateNic(requested, config, isDefaultNic, deviceId, vm);
752-
753-
NicProfile vmNic = vmNicPair.first();
754-
if (vmNic == null) {
755-
continue;
752+
NicProfile vmNic = null;
753+
if(vmNicPair != null) {
754+
vmNic = vmNicPair.first();
755+
if (vmNic == null) {
756+
continue;
757+
}
758+
deviceId = vmNicPair.second();
756759
}
757760

758-
deviceId = vmNicPair.second();
759-
760761
int devId = vmNic.getDeviceId();
761762
if (devId > deviceIds.length) {
762763
throw new IllegalArgumentException("Device id for nic is too large: " + vmNic);

‎plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3174,7 +3174,9 @@ private synchronized boolean enableAutoScaleConfig(LoadBalancerTO loadBalancerTO
31743174
scaleUpAction.set_vserver(nsVirtualServerName); // Actions Vserver, the one that is autoscaled, with CS
31753175
// now both are same. Not exposed in API.
31763176
scaleUpAction.set_profilename(profileName);
3177-
scaleUpAction.set_quiettime(scaleUpQuietTime);
3177+
if(scaleUpQuietTime != null) {
3178+
scaleUpAction.set_quiettime(scaleUpQuietTime);
3179+
}
31783180
String scaleUpParameters =
31793181
"command=deployVirtualMachine" + "&" + ApiConstants.ZONE_ID + "=" + profileTO.getZoneId() + "&" + ApiConstants.SERVICE_OFFERING_ID + "=" +
31803182
profileTO.getServiceOfferingId() + "&" + ApiConstants.TEMPLATE_ID + "=" + profileTO.getTemplateId() + "&" + ApiConstants.DISPLAY_NAME + "=" +

0 commit comments

Comments
 (0)