From 2c63d76205c1a7533f78b73255d0d7923ca225cc Mon Sep 17 00:00:00 2001 From: Robert Edmonds Date: Sun, 2 Sep 2018 20:01:32 -0400 Subject: [PATCH] protoc-c: Fix -Wsign-compare diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the following compiler diagnostics: ../protoc-c/c_helpers.cc: In function ‘void google::protobuf::compiler::c::PrintComment(google::protobuf::io::Printer*, std::__cxx11::string)’: ../protoc-c/c_helpers.cc:221:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] for (int i = 0; i < comment_lines.size(); i++) ~~^~~~~~~~~~~~~~~~~~~~~~ ../protoc-c/c_helpers.cc: In function ‘std::set > google::protobuf::compiler::c::MakeKeywordsMap()’: ../protoc-c/c_helpers.cc:273:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare] for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) { ^ --- protoc-c/c_helpers.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protoc-c/c_helpers.cc b/protoc-c/c_helpers.cc index 6fd0cd3..ea693c6 100644 --- a/protoc-c/c_helpers.cc +++ b/protoc-c/c_helpers.cc @@ -234,7 +234,7 @@ void PrintComment (io::Printer* printer, std::string comment) std::vector comment_lines; SplitStringUsing (comment, "\r\n", &comment_lines); printer->Print ("/*\n"); - for (int i = 0; i < comment_lines.size(); i++) + for (size_t i = 0; i < comment_lines.size(); i++) { if (!comment_lines[i].empty()) { @@ -286,7 +286,7 @@ const char* const kKeywordList[] = { std::set MakeKeywordsMap() { std::set result; - for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) { + for (size_t i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) { result.insert(kKeywordList[i]); } return result;