Browse Source

[2512] Add some comments

Mukund Sivaraman 11 years ago
parent
commit
8d831e9489
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/lib/dns/rdata/generic/detail/char_string.cc

+ 6 - 0
src/lib/dns/rdata/generic/detail/char_string.cc

@@ -105,7 +105,13 @@ stringToCharStringData(const MasterToken::StringRegion& str_region,
         int c = (*s & 0xff);
         int c = (*s & 0xff);
         if (escape && std::isdigit(c) != 0) {
         if (escape && std::isdigit(c) != 0) {
             c = decimalToNumber(s, s_end);
             c = decimalToNumber(s, s_end);
+            // decimalToNumber() already throws if (s_end - s) is less
+            // than 3, so the following assertion is unnecessary. But we
+            // assert it anyway. 'n' is an unsigned type (size_t) and
+            // can underflow.
             assert(n >= 3);
             assert(n >= 3);
+            // 'n' and 's' are also updated by 1 in the for statement's
+            // expression, so we update them by 2 instead of 3 here.
             n -= 2;
             n -= 2;
             s += 2;
             s += 2;
         } else if (!escape && c == '\\') {
         } else if (!escape && c == '\\') {