protoc-c: Fix -Wsign-compare diagnostics

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<std::__cxx11::basic_string<char> >::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<std::__cxx11::basic_string<char> > 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++) {
                         ^
This commit is contained in:
Robert Edmonds 2018-09-02 20:01:32 -04:00
parent 69fc2f13bb
commit 2c63d76205

View File

@ -234,7 +234,7 @@ void PrintComment (io::Printer* printer, std::string comment)
std::vector<std::string> comment_lines; std::vector<std::string> comment_lines;
SplitStringUsing (comment, "\r\n", &comment_lines); SplitStringUsing (comment, "\r\n", &comment_lines);
printer->Print ("/*\n"); 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()) if (!comment_lines[i].empty())
{ {
@ -286,7 +286,7 @@ const char* const kKeywordList[] = {
std::set<std::string> MakeKeywordsMap() { std::set<std::string> MakeKeywordsMap() {
std::set<std::string> result; std::set<std::string> result;
for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) { for (size_t i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) {
result.insert(kKeywordList[i]); result.insert(kKeywordList[i]);
} }
return result; return result;