Fixed few coverity issues

Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
This commit is contained in:
Santhosh Edukulla 2014-08-19 21:56:58 +05:30
parent dbe950a27e
commit 023811286e

View File

@ -192,7 +192,10 @@ public class NetUtils {
} }
String[] info = NetUtils.getNetworkParams(nic); 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; return false;
} else { } else {
InetAddress ip = parseIpAddress(ipAddress); 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) { while (next.compareTo(gap) >= 0) {
next = new BigInteger(gap.bitLength(), s_rand); next = new BigInteger(gap.bitLength(), s_rand);
} }
InetAddress resultAddr = null;
BigInteger startInt = convertIPv6AddressToBigInteger(start); BigInteger startInt = convertIPv6AddressToBigInteger(start);
BigInteger resultInt = startInt.add(next); if (startInt != null) {
InetAddress resultAddr; BigInteger resultInt = startInt.add(next);
try { try {
resultAddr = InetAddress.getByAddress(resultInt.toByteArray()); resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
return null; return null;
}
} }
IPv6Address ip = IPv6Address.fromInetAddress(resultAddr); if( resultAddr != null) {
return ip.toString(); IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
return ip.toString();
}
return null;
} }
//RFC3315, section 9.4 //RFC3315, section 9.4
@ -1300,8 +1311,10 @@ public class NetUtils {
} }
BigInteger startInt = convertIPv6AddressToBigInteger(start); BigInteger startInt = convertIPv6AddressToBigInteger(start);
BigInteger endInt = convertIPv6AddressToBigInteger(end); BigInteger endInt = convertIPv6AddressToBigInteger(end);
if (startInt.compareTo(endInt) > 0) { if (endInt != null) {
return null; if (startInt.compareTo(endInt) > 0) {
return null;
}
} }
return endInt.subtract(startInt).add(BigInteger.ONE); return endInt.subtract(startInt).add(BigInteger.ONE);
} }