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