Fixes for re-enabling more MSVC level 4 warnings: misc edition #2 This contains fixes for the following sorts of issues: * Assignment inside conditional * Taking the address of a temporary * Octal escape sequence terminated by decimal number * Signedness mismatch * Possibly-uninitialized local variable This also contains a small number of cleanups to nearby code (e.g. no else after return). BUG=81439 TEST=none Review URL: https://codereview.chromium.org/382673002 Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 481c3e82e2dcbcb676501f18bc8f58900071b935
diff --git a/tools/gn/tokenizer.cc b/tools/gn/tokenizer.cc index c089006..87a4d90 100644 --- a/tools/gn/tokenizer.cc +++ b/tools/gn/tokenizer.cc
@@ -134,14 +134,13 @@ // static size_t Tokenizer::ByteOffsetOfNthLine(const base::StringPiece& buf, int n) { - int cur_line = 1; - size_t cur_byte = 0; - - DCHECK(n > 0); + DCHECK_GT(n, 0); if (n == 1) return 0; + int cur_line = 1; + size_t cur_byte = 0; while (cur_byte < buf.size()) { if (IsNewline(buf, cur_byte)) { cur_line++; @@ -150,7 +149,7 @@ } cur_byte++; } - return -1; + return static_cast<size_t>(-1); } // static