Repository: cloudstack Updated Branches: refs/heads/hotfix/coverity-fixes [created] 77ed21c4b
Fixed a few coverity issues in ConfigurationManagerImpl Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/77ed21c4 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/77ed21c4 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/77ed21c4 Branch: refs/heads/hotfix/coverity-fixes Commit: 77ed21c4bead747d1c22febb0b669c98b2a2bc1b Parents: bf9036c Author: Rajani Karuturi <[email protected]> Authored: Wed Aug 6 17:34:43 2014 +0530 Committer: Rajani Karuturi <[email protected]> Committed: Wed Aug 6 17:34:43 2014 +0530 ---------------------------------------------------------------------- .../configuration/ConfigurationManagerImpl.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77ed21c4/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index bcd87da..84f24e8 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1264,6 +1264,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati String cidrAddress = getCidrAddress(cidr); int cidrSize = getCidrSize(cidr); + // Validate new pod settings + checkPodAttributes(-1, podName, zoneId, gateway, cidr, startIp, endIp, allocationStateStr, true, skipGatewayOverlapCheck); + // endIp is an optional parameter; if not specified - default it to the // end ip of the pod's cidr if (startIp != null) { @@ -1272,16 +1275,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } - // Validate new pod settings - checkPodAttributes(-1, podName, zoneId, gateway, cidr, startIp, endIp, allocationStateStr, true, skipGatewayOverlapCheck); - // Create the new pod in the database - String ipRange; - if (startIp != null) { - ipRange = startIp + "-" + endIp; - } else { - throw new InvalidParameterValueException("Start ip is required parameter"); - } + String ipRange = startIp + "-" + endIp; final HostPodVO podFinal = new HostPodVO(podName, zoneId, gateway, cidrAddress, cidrSize, ipRange); @@ -3473,10 +3468,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati skipPod = podIdToBeSkipped; } HashMap<Long, List<Object>> currentPodCidrSubnets = _podDao.getCurrentPodCidrSubnets(dcId, skipPod); + if(currentPodCidrSubnets == null) { + throw new InvalidParameterValueException("There arent any CIDRs in the zone: "+dcId); + } List<Object> newCidrPair = new ArrayList<Object>(); newCidrPair.add(0, getCidrAddress(cidr)); newCidrPair.add(1, (long)getCidrSize(cidr)); - currentPodCidrSubnets.put(new Long(-1), newCidrPair); + currentPodCidrSubnets.put((long) -1, newCidrPair); DataCenterVO dcVo = _zoneDao.findById(dcId); String guestNetworkCidr = dcVo.getGuestNetworkCidr();
