Fix clang build warnings/errors for windows symbol converter. Change-Id: Ib7f6e37af1466b5bed3e7d2921e0d9774394ad1e Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1680056 Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/src/tools/windows/converter/ms_symbol_server_converter.cc b/src/tools/windows/converter/ms_symbol_server_converter.cc index e3215ba..4b0dcf6 100644 --- a/src/tools/windows/converter/ms_symbol_server_converter.cc +++ b/src/tools/windows/converter/ms_symbol_server_converter.cc
@@ -154,7 +154,7 @@ if (!Cleanup()) { // Print the error message here, because destructors have no return // value. - fprintf(stderr, "~AutoSymSrv: SymCleanup: error %d\n", GetLastError()); + fprintf(stderr, "~AutoSymSrv: SymCleanup: error %lu\n", GetLastError()); } } @@ -238,7 +238,7 @@ if (!symsrv.Initialize(process, const_cast<char *>(symbol_path_.c_str()), false)) { - fprintf(stderr, "LocateFile: SymInitialize: error %d for %s %s %s\n", + fprintf(stderr, "LocateFile: SymInitialize: error %lu for %s %s %s\n", GetLastError(), debug_or_code_file.c_str(), debug_or_code_id.c_str(), @@ -249,7 +249,7 @@ if (!SymRegisterCallback64(process, SymCallback, reinterpret_cast<ULONG64>(this))) { fprintf(stderr, - "LocateFile: SymRegisterCallback64: error %d for %s %s %s\n", + "LocateFile: SymRegisterCallback64: error %lu for %s %s %s\n", GetLastError(), debug_or_code_file.c_str(), debug_or_code_id.c_str(), @@ -304,7 +304,7 @@ } fprintf(stderr, - "LocateFile: SymFindFileInPath: error %d for %s %s %s\n", + "LocateFile: SymFindFileInPath: error %lu for %s %s %s\n", error, debug_or_code_file.c_str(), debug_or_code_id.c_str(), @@ -322,7 +322,7 @@ // Do the cleanup here even though it will happen when symsrv goes out of // scope, to allow it to influence the return value. if (!symsrv.Cleanup()) { - fprintf(stderr, "LocateFile: SymCleanup: error %d for %s %s %s\n", + fprintf(stderr, "LocateFile: SymCleanup: error %lu for %s %s %s\n", GetLastError(), debug_or_code_file.c_str(), debug_or_code_id.c_str(), @@ -405,7 +405,8 @@ }; for (int desc_action_index = 0; - desc_action_index < sizeof(desc_actions) / sizeof(desc_action); + desc_action_index < + static_cast<int>(sizeof(desc_actions) / sizeof(desc_action)); ++desc_action_index) { if (desc.find(desc_actions[desc_action_index].desc) != string::npos) { *(desc_actions[desc_action_index].action) = true;
diff --git a/src/tools/windows/converter_exe/converter.cc b/src/tools/windows/converter_exe/converter.cc index df87c7b..5b70903 100644 --- a/src/tools/windows/converter_exe/converter.cc +++ b/src/tools/windows/converter_exe/converter.cc
@@ -66,8 +66,6 @@ const char *kLocalCachePath = "c:\\symbols"; const char *kNoExeMSSSServer = "http://msdl.microsoft.com/download/symbols/"; -const int kMatchArrSize = 64; - // Windows stdio doesn't do line buffering. Use this function to flush after // writing to stdout and stderr so that a log will be available if the // converter crashes. @@ -81,7 +79,7 @@ } static string CurrentDateAndTime() { - const string kUnknownDateAndTime = "????-??-?? ??:??:??"; + const string kUnknownDateAndTime = R"(????-??-?? ??:??:??)"; time_t current_time; time(¤t_time);
diff --git a/src/tools/windows/converter_exe/escaping.cc b/src/tools/windows/converter_exe/escaping.cc index e26bbeb..74a7203 100644 --- a/src/tools/windows/converter_exe/escaping.cc +++ b/src/tools/windows/converter_exe/escaping.cc
@@ -259,10 +259,10 @@ // szsrc claims the string is). if (!src[0] || !src[1] || !src[2] || - (temp = ((unbase64[src[0]] << 18) | - (unbase64[src[1]] << 12) | - (unbase64[src[2]] << 6) | - (unbase64[src[3]]))) & 0x80000000) { + (temp = ((unbase64[static_cast<int>(src[0])] << 18) | + (unbase64[static_cast<int>(src[1])] << 12) | + (unbase64[static_cast<int>(src[2])] << 6) | + (unbase64[static_cast<int>(src[3])]))) & 0x80000000) { // Iff any of those four characters was bad (null, illegal, // whitespace, padding), then temp's high bit will be set // (because unbase64[] is -1 for all bad characters). @@ -301,10 +301,10 @@ } else { while (szsrc >= 4) { if (!src[0] || !src[1] || !src[2] || - (temp = ((unbase64[src[0]] << 18) | - (unbase64[src[1]] << 12) | - (unbase64[src[2]] << 6) | - (unbase64[src[3]]))) & 0x80000000) { + (temp = ((unbase64[static_cast<int>(src[0])] << 18) | + (unbase64[static_cast<int>(src[1])] << 12) | + (unbase64[static_cast<int>(src[2])] << 6) | + (unbase64[static_cast<int>(src[3])]))) & 0x80000000) { GET_INPUT(first_no_dest, 4); GET_INPUT(second_no_dest, 3); GET_INPUT(third_no_dest, 2);
diff --git a/src/tools/windows/converter_exe/http_download.cc b/src/tools/windows/converter_exe/http_download.cc index b037662..5afc1cc 100644 --- a/src/tools/windows/converter_exe/http_download.cc +++ b/src/tools/windows/converter_exe/http_download.cc
@@ -170,7 +170,7 @@ sizeof(path)/sizeof(path[0]), &port)) { fprintf(stderr, - "HTTPDownload::Download: InternetCrackUrl: error %d for %ws\n", + "HTTPDownload::Download: InternetCrackUrl: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } @@ -192,7 +192,7 @@ NULL, // proxy bypass internet.get_handle_addr())) { fprintf(stderr, - "HTTPDownload::Download: Open: error %d for %ws\n", + "HTTPDownload::Download: Open: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } @@ -203,7 +203,7 @@ port, connection.get_handle_addr())) { fprintf(stderr, - "HTTPDownload::Download: InternetConnect: error %d for %ws\n", + "HTTPDownload::Download: InternetConnect: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } @@ -239,21 +239,21 @@ secure, request.get_handle_addr())) { fprintf(stderr, - "HttpClient::OpenRequest: error %d for %ws, request: %ws\n", + "HttpClient::OpenRequest: error %lu for %ws, request: %ws\n", GetLastError(), url.c_str(), request_string.c_str()); return false; } if (!http_client->SendRequest(request.get(), NULL, 0)) { fprintf(stderr, - "HttpClient::SendRequest: error %d for %ws\n", + "HttpClient::SendRequest: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } if (!http_client->ReceiveResponse(request.get())) { fprintf(stderr, - "HttpClient::ReceiveResponse: error %d for %ws\n", + "HttpClient::ReceiveResponse: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } @@ -261,7 +261,7 @@ int http_status = 0; if (!http_client->GetHttpStatusCode(request.get(), &http_status)) { fprintf(stderr, - "HttpClient::GetHttpStatusCode: error %d for %ws\n", + "HttpClient::GetHttpStatusCode: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } @@ -304,13 +304,13 @@ if (!read_result) { fprintf(stderr, - "HttpClient::ReadData: error %d for %ws\n", + "HttpClient::ReadData: error %lu for %ws\n", GetLastError(), url.c_str()); return false; } else if (size_read != 0) { fprintf(stderr, - "HttpClient::ReadData: error %d/%d for %ws\n", + "HttpClient::ReadData: error %lu/%lu for %ws\n", total_read, content_length, url.c_str());