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>
This commit is contained in:
Nelson Billing 2019-06-27 12:47:45 -07:00
parent b62101dead
commit a5a607b0b0
4 changed files with 25 additions and 26 deletions

View File

@ -154,7 +154,7 @@ class AutoSymSrv {
if (!Cleanup()) { if (!Cleanup()) {
// Print the error message here, because destructors have no return // Print the error message here, because destructors have no return
// value. // 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, if (!symsrv.Initialize(process,
const_cast<char *>(symbol_path_.c_str()), const_cast<char *>(symbol_path_.c_str()),
false)) { false)) {
fprintf(stderr, "LocateFile: SymInitialize: error %d for %s %s %s\n", fprintf(stderr, "LocateFile: SymInitialize: error %lu for %s %s %s\n",
GetLastError(), GetLastError(),
debug_or_code_file.c_str(), debug_or_code_file.c_str(),
debug_or_code_id.c_str(), debug_or_code_id.c_str(),
@ -249,7 +249,7 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file,
if (!SymRegisterCallback64(process, SymCallback, if (!SymRegisterCallback64(process, SymCallback,
reinterpret_cast<ULONG64>(this))) { reinterpret_cast<ULONG64>(this))) {
fprintf(stderr, fprintf(stderr,
"LocateFile: SymRegisterCallback64: error %d for %s %s %s\n", "LocateFile: SymRegisterCallback64: error %lu for %s %s %s\n",
GetLastError(), GetLastError(),
debug_or_code_file.c_str(), debug_or_code_file.c_str(),
debug_or_code_id.c_str(), debug_or_code_id.c_str(),
@ -304,7 +304,7 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file,
} }
fprintf(stderr, fprintf(stderr,
"LocateFile: SymFindFileInPath: error %d for %s %s %s\n", "LocateFile: SymFindFileInPath: error %lu for %s %s %s\n",
error, error,
debug_or_code_file.c_str(), debug_or_code_file.c_str(),
debug_or_code_id.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 // Do the cleanup here even though it will happen when symsrv goes out of
// scope, to allow it to influence the return value. // scope, to allow it to influence the return value.
if (!symsrv.Cleanup()) { 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(), GetLastError(),
debug_or_code_file.c_str(), debug_or_code_file.c_str(),
debug_or_code_id.c_str(), debug_or_code_id.c_str(),
@ -405,7 +405,8 @@ BOOL CALLBACK MSSymbolServerConverter::SymCallback(HANDLE process,
}; };
for (int desc_action_index = 0; 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) { ++desc_action_index) {
if (desc.find(desc_actions[desc_action_index].desc) != string::npos) { if (desc.find(desc_actions[desc_action_index].desc) != string::npos) {
*(desc_actions[desc_action_index].action) = true; *(desc_actions[desc_action_index].action) = true;

View File

@ -66,8 +66,6 @@ const char *kMissingStringDelimiters = "|";
const char *kLocalCachePath = "c:\\symbols"; const char *kLocalCachePath = "c:\\symbols";
const char *kNoExeMSSSServer = "http://msdl.microsoft.com/download/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 // 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 // writing to stdout and stderr so that a log will be available if the
// converter crashes. // converter crashes.
@ -81,7 +79,7 @@ static int FprintfFlush(FILE *file, const char *format, ...) {
} }
static string CurrentDateAndTime() { static string CurrentDateAndTime() {
const string kUnknownDateAndTime = "????-??-?? ??:??:??"; const string kUnknownDateAndTime = R"(????-??-?? ??:??:??)";
time_t current_time; time_t current_time;
time(&current_time); time(&current_time);

View File

@ -259,10 +259,10 @@ int Base64UnescapeInternal(const char *src, int szsrc,
// szsrc claims the string is). // szsrc claims the string is).
if (!src[0] || !src[1] || !src[2] || if (!src[0] || !src[1] || !src[2] ||
(temp = ((unbase64[src[0]] << 18) | (temp = ((unbase64[static_cast<int>(src[0])] << 18) |
(unbase64[src[1]] << 12) | (unbase64[static_cast<int>(src[1])] << 12) |
(unbase64[src[2]] << 6) | (unbase64[static_cast<int>(src[2])] << 6) |
(unbase64[src[3]]))) & 0x80000000) { (unbase64[static_cast<int>(src[3])]))) & 0x80000000) {
// Iff any of those four characters was bad (null, illegal, // Iff any of those four characters was bad (null, illegal,
// whitespace, padding), then temp's high bit will be set // whitespace, padding), then temp's high bit will be set
// (because unbase64[] is -1 for all bad characters). // (because unbase64[] is -1 for all bad characters).
@ -301,10 +301,10 @@ int Base64UnescapeInternal(const char *src, int szsrc,
} else { } else {
while (szsrc >= 4) { while (szsrc >= 4) {
if (!src[0] || !src[1] || !src[2] || if (!src[0] || !src[1] || !src[2] ||
(temp = ((unbase64[src[0]] << 18) | (temp = ((unbase64[static_cast<int>(src[0])] << 18) |
(unbase64[src[1]] << 12) | (unbase64[static_cast<int>(src[1])] << 12) |
(unbase64[src[2]] << 6) | (unbase64[static_cast<int>(src[2])] << 6) |
(unbase64[src[3]]))) & 0x80000000) { (unbase64[static_cast<int>(src[3])]))) & 0x80000000) {
GET_INPUT(first_no_dest, 4); GET_INPUT(first_no_dest, 4);
GET_INPUT(second_no_dest, 3); GET_INPUT(second_no_dest, 3);
GET_INPUT(third_no_dest, 2); GET_INPUT(third_no_dest, 2);

View File

@ -170,7 +170,7 @@ bool HTTPDownload::Download(const wstring &url,
sizeof(path)/sizeof(path[0]), sizeof(path)/sizeof(path[0]),
&port)) { &port)) {
fprintf(stderr, fprintf(stderr,
"HTTPDownload::Download: InternetCrackUrl: error %d for %ws\n", "HTTPDownload::Download: InternetCrackUrl: error %lu for %ws\n",
GetLastError(), url.c_str()); GetLastError(), url.c_str());
return false; return false;
} }
@ -192,7 +192,7 @@ bool HTTPDownload::Download(const wstring &url,
NULL, // proxy bypass NULL, // proxy bypass
internet.get_handle_addr())) { internet.get_handle_addr())) {
fprintf(stderr, fprintf(stderr,
"HTTPDownload::Download: Open: error %d for %ws\n", "HTTPDownload::Download: Open: error %lu for %ws\n",
GetLastError(), url.c_str()); GetLastError(), url.c_str());
return false; return false;
} }
@ -203,7 +203,7 @@ bool HTTPDownload::Download(const wstring &url,
port, port,
connection.get_handle_addr())) { connection.get_handle_addr())) {
fprintf(stderr, fprintf(stderr,
"HTTPDownload::Download: InternetConnect: error %d for %ws\n", "HTTPDownload::Download: InternetConnect: error %lu for %ws\n",
GetLastError(), url.c_str()); GetLastError(), url.c_str());
return false; return false;
} }
@ -239,21 +239,21 @@ bool HTTPDownload::Download(const wstring &url,
secure, secure,
request.get_handle_addr())) { request.get_handle_addr())) {
fprintf(stderr, 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()); GetLastError(), url.c_str(), request_string.c_str());
return false; return false;
} }
if (!http_client->SendRequest(request.get(), NULL, 0)) { if (!http_client->SendRequest(request.get(), NULL, 0)) {
fprintf(stderr, fprintf(stderr,
"HttpClient::SendRequest: error %d for %ws\n", "HttpClient::SendRequest: error %lu for %ws\n",
GetLastError(), url.c_str()); GetLastError(), url.c_str());
return false; return false;
} }
if (!http_client->ReceiveResponse(request.get())) { if (!http_client->ReceiveResponse(request.get())) {
fprintf(stderr, fprintf(stderr,
"HttpClient::ReceiveResponse: error %d for %ws\n", "HttpClient::ReceiveResponse: error %lu for %ws\n",
GetLastError(), url.c_str()); GetLastError(), url.c_str());
return false; return false;
} }
@ -261,7 +261,7 @@ bool HTTPDownload::Download(const wstring &url,
int http_status = 0; int http_status = 0;
if (!http_client->GetHttpStatusCode(request.get(), &http_status)) { if (!http_client->GetHttpStatusCode(request.get(), &http_status)) {
fprintf(stderr, fprintf(stderr,
"HttpClient::GetHttpStatusCode: error %d for %ws\n", "HttpClient::GetHttpStatusCode: error %lu for %ws\n",
GetLastError(), url.c_str()); GetLastError(), url.c_str());
return false; return false;
} }
@ -304,13 +304,13 @@ bool HTTPDownload::Download(const wstring &url,
if (!read_result) { if (!read_result) {
fprintf(stderr, fprintf(stderr,
"HttpClient::ReadData: error %d for %ws\n", "HttpClient::ReadData: error %lu for %ws\n",
GetLastError(), GetLastError(),
url.c_str()); url.c_str());
return false; return false;
} else if (size_read != 0) { } else if (size_read != 0) {
fprintf(stderr, fprintf(stderr,
"HttpClient::ReadData: error %d/%d for %ws\n", "HttpClient::ReadData: error %lu/%lu for %ws\n",
total_read, total_read,
content_length, content_length,
url.c_str()); url.c_str());