From a5a607b0b01c7022d7ccba282491c40da204cba2 Mon Sep 17 00:00:00 2001 From: Nelson Billing Date: Thu, 27 Jun 2019 12:47:45 -0700 Subject: [PATCH] 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 --- .../converter/ms_symbol_server_converter.cc | 13 +++++++------ src/tools/windows/converter_exe/converter.cc | 4 +--- src/tools/windows/converter_exe/escaping.cc | 16 ++++++++-------- .../windows/converter_exe/http_download.cc | 18 +++++++++--------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/tools/windows/converter/ms_symbol_server_converter.cc b/src/tools/windows/converter/ms_symbol_server_converter.cc index e3215ba5..4b0dcf6e 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 @@ class AutoSymSrv { 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 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, if (!symsrv.Initialize(process, const_cast(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 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, if (!SymRegisterCallback64(process, SymCallback, reinterpret_cast(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 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, } 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 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, // 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 @@ BOOL CALLBACK MSSymbolServerConverter::SymCallback(HANDLE process, }; for (int desc_action_index = 0; - desc_action_index < sizeof(desc_actions) / sizeof(desc_action); + desc_action_index < + static_cast(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 df87c7b5..5b70903a 100644 --- a/src/tools/windows/converter_exe/converter.cc +++ b/src/tools/windows/converter_exe/converter.cc @@ -66,8 +66,6 @@ const char *kMissingStringDelimiters = "|"; 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 int FprintfFlush(FILE *file, const char *format, ...) { } 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 e26bbeb3..74a7203a 100644 --- a/src/tools/windows/converter_exe/escaping.cc +++ b/src/tools/windows/converter_exe/escaping.cc @@ -259,10 +259,10 @@ int Base64UnescapeInternal(const char *src, int szsrc, // 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(src[0])] << 18) | + (unbase64[static_cast(src[1])] << 12) | + (unbase64[static_cast(src[2])] << 6) | + (unbase64[static_cast(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 @@ int Base64UnescapeInternal(const char *src, int szsrc, } 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(src[0])] << 18) | + (unbase64[static_cast(src[1])] << 12) | + (unbase64[static_cast(src[2])] << 6) | + (unbase64[static_cast(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 b037662f..5afc1ccc 100644 --- a/src/tools/windows/converter_exe/http_download.cc +++ b/src/tools/windows/converter_exe/http_download.cc @@ -170,7 +170,7 @@ bool HTTPDownload::Download(const wstring &url, 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 @@ bool HTTPDownload::Download(const wstring &url, 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 @@ bool HTTPDownload::Download(const wstring &url, 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 @@ bool HTTPDownload::Download(const wstring &url, 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 @@ bool HTTPDownload::Download(const wstring &url, 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 @@ bool HTTPDownload::Download(const wstring &url, 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());