mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed few coverity issues
Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
This commit is contained in:
parent
dbe950a27e
commit
023811286e
@ -192,8 +192,11 @@ public class NetUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String[] info = NetUtils.getNetworkParams(nic);
|
String[] info = NetUtils.getNetworkParams(nic);
|
||||||
|
if (info != null) {
|
||||||
return info[0];
|
return info[0];
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultEthDevice() {
|
public static String getDefaultEthDevice() {
|
||||||
@ -489,8 +492,11 @@ public class NetUtils {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
InetAddress ip = parseIpAddress(ipAddress);
|
InetAddress ip = parseIpAddress(ipAddress);
|
||||||
|
if(ip != null) {
|
||||||
return ip.isSiteLocalAddress();
|
return ip.isSiteLocalAddress();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean validIpRange(String startIP, String endIP) {
|
public static boolean validIpRange(String startIP, String endIP) {
|
||||||
@ -1252,17 +1258,22 @@ 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);
|
||||||
|
if (startInt != null) {
|
||||||
BigInteger resultInt = startInt.add(next);
|
BigInteger resultInt = startInt.add(next);
|
||||||
InetAddress resultAddr;
|
|
||||||
try {
|
try {
|
||||||
resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
|
resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if( resultAddr != null) {
|
||||||
IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
|
IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
|
||||||
return ip.toString();
|
return ip.toString();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//RFC3315, section 9.4
|
//RFC3315, section 9.4
|
||||||
public static String getDuidLL(String macAddress) {
|
public static String getDuidLL(String macAddress) {
|
||||||
@ -1300,9 +1311,11 @@ public class NetUtils {
|
|||||||
}
|
}
|
||||||
BigInteger startInt = convertIPv6AddressToBigInteger(start);
|
BigInteger startInt = convertIPv6AddressToBigInteger(start);
|
||||||
BigInteger endInt = convertIPv6AddressToBigInteger(end);
|
BigInteger endInt = convertIPv6AddressToBigInteger(end);
|
||||||
|
if (endInt != null) {
|
||||||
if (startInt.compareTo(endInt) > 0) {
|
if (startInt.compareTo(endInt) > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return endInt.subtract(startInt).add(BigInteger.ONE);
|
return endInt.subtract(startInt).add(BigInteger.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user