diff --git a/src/lib/dns/master_lexer_inputsource.cc b/src/lib/dns/master_lexer_inputsource.cc index 6c43dc1c56..ffaf53e0c5 100644 --- a/src/lib/dns/master_lexer_inputsource.cc +++ b/src/lib/dns/master_lexer_inputsource.cc @@ -21,7 +21,7 @@ namespace master_lexer_internal { namespace { // unnamed namespace std::string -createStreamName(std::istream& input_stream) { +createStreamName(const std::istream& input_stream) { std::stringstream ss; ss << "stream-" << &input_stream; return (ss.str()); @@ -70,7 +70,7 @@ InputSource::getChar() { return (END_OF_STREAM); } // We are not yet at EOF. Read from the stream. - int c = input_.get(); + const int c = input_.get(); // Have we reached EOF now? If so, set at_eof_ and return early, // but don't modify buffer_pos_ (which should still be equal to // the size of buffer_). @@ -87,7 +87,7 @@ InputSource::getChar() { buffer_.push_back(c); } - int c = buffer_[buffer_pos_++]; + const int c = buffer_[buffer_pos_++]; if (c == '\n') { line_++; } diff --git a/src/lib/dns/tests/master_lexer_inputsource_unittest.cc b/src/lib/dns/tests/master_lexer_inputsource_unittest.cc index 1031d0202c..9bb6aabedf 100644 --- a/src/lib/dns/tests/master_lexer_inputsource_unittest.cc +++ b/src/lib/dns/tests/master_lexer_inputsource_unittest.cc @@ -68,7 +68,8 @@ TEST_F(InputSourceTest, nonExistentFile) { // getChar() should return characters from the input stream in // sequence. ungetChar() should skip backwards. void -checkGetAndUngetChar(InputSource& source, const char* str, size_t str_length) +checkGetAndUngetChar(InputSource& source, + const char* str, const size_t str_length) { for (size_t i = 0; i < str_length; i++) { EXPECT_EQ(str[i], source.getChar()); @@ -101,7 +102,7 @@ checkGetAndUngetChar(InputSource& source, const char* str, size_t str_length) source.ungetChar(); for (size_t i = 0; i < str_length; i++) { - size_t index = str_length - 1 - i; + const size_t index = str_length - 1 - i; // Skip one character. source.ungetChar(); EXPECT_EQ(str[index], source.getChar()); @@ -119,8 +120,8 @@ TEST_F(InputSourceTest, stream) { TEST_F(InputSourceTest, file) { std::ifstream fs(TEST_DATA_SRCDIR "/masterload.txt"); - std::string str((std::istreambuf_iterator(fs)), - std::istreambuf_iterator()); + const std::string str((std::istreambuf_iterator(fs)), + std::istreambuf_iterator()); fs.close(); InputSource source(TEST_DATA_SRCDIR "/masterload.txt"); @@ -191,8 +192,7 @@ TEST_F(InputSourceTest, compactDuring) { source_.getChar(); } EXPECT_FALSE(source_.atEOF()); - size_t line = source_.getCurrentLine(); - EXPECT_EQ(2, line); + EXPECT_EQ(2, source_.getCurrentLine()); // Now, unget a couple of characters. This should cause the // buffer_pos_ to be not equal to the size of the buffer. @@ -299,8 +299,7 @@ TEST_F(InputSourceTest, saveLine) { source_.getChar(); } EXPECT_FALSE(source_.atEOF()); - size_t line = source_.getCurrentLine(); - EXPECT_EQ(2, line); + EXPECT_EQ(2, source_.getCurrentLine()); // Now, save the line. source_.saveLine(); @@ -309,11 +308,10 @@ TEST_F(InputSourceTest, saveLine) { while (!source_.atEOF()) { source_.getChar(); } - line = source_.getCurrentLine(); // Now, we are at EOF. EXPECT_TRUE(source_.atEOF()); - EXPECT_EQ(4, line); + EXPECT_EQ(4, source_.getCurrentLine()); // Now, ungetAll() and check where it goes back. source_.ungetAll();