This is minor code smell, create a method to concentrate common
functionality.
Change-Id: I32fb6c5c29a099885413cf18361e53098593054e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
- verify(j + INT16SZ <= INADDR6SZ, "Overrun in parsing of '%s', should not occur", str);
+ verifySize(j + INT16SZ <= INADDR6SZ, str);
bytes[j++] = (byte) (val >> 8 & 0xff);
bytes[j++] = (byte) (val & 0xff);
}
if (colonp != -1) {
bytes[j++] = (byte) (val >> 8 & 0xff);
bytes[j++] = (byte) (val & 0xff);
}
if (colonp != -1) {
- verify(j != INADDR6SZ, "Overrun in parsing of '%s', should not occur", str);
+ verifySize(j != INADDR6SZ, str);
expandZeros(bytes, colonp, j);
} else {
expandZeros(bytes, colonp, j);
} else {
- verify(j == INADDR6SZ, "Overrun in parsing of '%s', should not occur", str);
+ verifySize(j == INADDR6SZ, str);
+ private static void verifySize(final boolean expression, final String str) {
+ verify(expression, "Overrun in parsing of '%s', should not occur", str);
+ }
+
private static void expandZeros(final byte[] bytes, final int where, final int filledBytes) {
final int tailLength = filledBytes - where;
final int tailOffset = INADDR6SZ - tailLength;
private static void expandZeros(final byte[] bytes, final int where, final int filledBytes) {
final int tailLength = filledBytes - where;
final int tailOffset = INADDR6SZ - tailLength;