Repository: cloudstack
Updated Branches:
  refs/heads/master dbe950a27 -> 023811286


Fixed few coverity issues

Signed-off-by: Santhosh Edukulla <santhosh.eduku...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/02381128
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/02381128
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/02381128

Branch: refs/heads/master
Commit: 023811286e1fe362f86b237bad40e60b1dcf2602
Parents: dbe950a
Author: Santhosh Edukulla <santhosh.eduku...@gmail.com>
Authored: Tue Aug 19 21:56:58 2014 +0530
Committer: Santhosh Edukulla <santhosh.eduku...@gmail.com>
Committed: Tue Aug 19 22:01:15 2014 +0530

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/NetUtils.java | 37 ++++++++++++++++--------
 1 file changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/02381128/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java 
b/utils/src/com/cloud/utils/net/NetUtils.java
index 874bf79..ab0f64d 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -192,7 +192,10 @@ public class NetUtils {
             }
 
             String[] info = NetUtils.getNetworkParams(nic);
-            return info[0];
+            if (info != null) {
+                return info[0];
+            }
+            return null;
         }
     }
 
@@ -489,7 +492,10 @@ public class NetUtils {
             return false;
         } else {
             InetAddress ip = parseIpAddress(ipAddress);
-            return ip.isSiteLocalAddress();
+            if(ip != null) {
+                return ip.isSiteLocalAddress();
+            }
+            return false;
         }
     }
 
@@ -1252,16 +1258,21 @@ public class NetUtils {
         while (next.compareTo(gap) >= 0) {
             next = new BigInteger(gap.bitLength(), s_rand);
         }
+        InetAddress resultAddr = null;
         BigInteger startInt = convertIPv6AddressToBigInteger(start);
-        BigInteger resultInt = startInt.add(next);
-        InetAddress resultAddr;
-        try {
-            resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
-        } catch (UnknownHostException e) {
-            return null;
+        if (startInt != null) {
+            BigInteger resultInt = startInt.add(next);
+            try {
+                resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
+            } catch (UnknownHostException e) {
+                return null;
+            }
         }
-        IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
-        return ip.toString();
+        if( resultAddr != null) {
+            IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
+            return ip.toString();
+        }
+        return null;
     }
 
     //RFC3315, section 9.4
@@ -1300,8 +1311,10 @@ public class NetUtils {
         }
         BigInteger startInt = convertIPv6AddressToBigInteger(start);
         BigInteger endInt = convertIPv6AddressToBigInteger(end);
-        if (startInt.compareTo(endInt) > 0) {
-            return null;
+        if (endInt != null) {
+            if (startInt.compareTo(endInt) > 0) {
+                return null;
+            }
         }
         return endInt.subtract(startInt).add(BigInteger.ONE);
     }

Reply via email to