BUG-2825: rename have_xdigit 89/35389/4
authorRobert Varga <robert.varga@pantheon.sk>
Thu, 25 Feb 2016 11:07:45 +0000 (12:07 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 25 Feb 2016 15:23:30 +0000 (15:23 +0000)
Do not use an underscore and make sure the name relates to the fact that
the contents of 'val' are valid and need to be propagated to the byte
array.

Change-Id: I4596a679b9c8e871ba57aaae1a59d8df01383803
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
model/ietf/ietf-type-util/src/main/java/org/opendaylight/mdsal/model/ietf/util/Ipv6Utils.java

index ce35e413497987f32c2d19d8a17d1228be1728d1..72c8bf9c12dd603795b62fa79463d267704f239f 100644 (file)
@@ -70,7 +70,7 @@ final class Ipv6Utils {
 
        final byte[] dst = new byte[INADDR6SZ];
 
-       boolean saw_xdigit = false;
+       boolean haveVal = false;
        int val = 0;
        int colonp = -1;
        int j = 0;
@@ -81,18 +81,17 @@ final class Ipv6Utils {
            // v6 separator
            if (ch == ':') {
                curtok = i;
-               if (!saw_xdigit) {
+               if (haveVal) {
+                   // removed overrun check - the regexp checks for valid data
+                   dst[j++] = (byte) ((val >>> 8) & 0xff);
+                   dst[j++] = (byte) (val & 0xff);
+                   haveVal = false;
+                   val = 0;
+               } else {
                    // no need to check separator position validity - regexp does that
                    colonp = j;
-                   continue;
                }
 
-               // removed overrun check - the regexp checks for valid data
-
-               dst[j++] = (byte) ((val >>> 8) & 0xff);
-               dst[j++] = (byte) (val & 0xff);
-               saw_xdigit = false;
-               val = 0;
                continue;
            }
 
@@ -104,7 +103,7 @@ final class Ipv6Utils {
                 */
                Ipv4Utils.fillIpv4Bytes(dst, j, addrStr, curtok, addrStrLen);
                j += INADDR4SZ;
-               saw_xdigit = false;
+               haveVal = false;
                break;
            }
 
@@ -116,10 +115,10 @@ final class Ipv6Utils {
             */
            final int chval = AbstractIetfYangUtil.hexValue(ch);
            val = (val << 4) | chval;
-           saw_xdigit = true;
+           haveVal = true;
        }
 
-       if (saw_xdigit) {
+       if (haveVal) {
            Verify.verify(j + INT16SZ <= INADDR6SZ, "Overrun in parsing of '%s', should not occur", addrStr);
            dst[j++] = (byte) ((val >> 8) & 0xff);
            dst[j++] = (byte) (val & 0xff);