Skip to content

Commit 6290b99

Browse files
committed
fix some invalid uses of nullptr
Some Windows code was misusing NULL, so when it was changed to nullptr, the extra compile-time checks caught it and broke. Since crash_id_ is an integer, initialize it to 0, not a pointer. client/windows/crash_generation/client_info.cc(60,7): error: cannot initialize a member subobject of type 'DWORD' (aka 'unsigned long') with an rvalue of type 'std::nullptr_t' 60 | crash_id_(nullptr) { Casting a pointer to the MINIDUMP_TYPE enum doesn't make sense, especially when the enum with value 0 is a valid value. Switch to MiniDumpNormal since that's what NULL (0) was doing. client/windows/crash_generation/crash_generation_client.cc(209,23): error: static_cast from 'std::nullptr_t' to 'MINIDUMP_TYPE' (aka '_MINIDUMP_TYPE') is not allowed 209 | static_cast<MINIDUMP_TYPE>(nullptr), nullptr, nullptr, While these are ULONG_PTR, MSDN says they're status codes & byte counts, so initialize both to 0 rather than a null pointer. client/windows/crash_generation/crash_generation_server.cc(568,26): error: assigning to 'ULONG_PTR' (aka 'unsigned long long') from incompatible type 'std::nullptr_t' 568 | overlapped_.Internal = nullptr; client/windows/crash_generation/crash_generation_server.cc(569,30): error: assigning to 'ULONG_PTR' (aka 'unsigned long long') from incompatible type 'std::nullptr_t' 569 | overlapped_.InternalHigh = nullptr; Since handle_ is an integer, initialize it to 0. client/windows/crash_generation/minidump_generator.cc(109,7): error: cannot initialize a member subobject of type 'ULONG64' (aka 'unsigned long long') with an rvalue of type 'std::nullptr_t' 109 | handle_(nullptr) { While Linux defines AppMemory.ptr as void*, Windows defines it as ULONG64. Cast nullptr to that to match other ptr code in this file. client/windows/handler/exception_handler.cc(256,28): error: assigning to 'ULONG64' (aka 'unsigned long long') from incompatible type 'std::nullptr_t' 256 | instruction_memory.ptr = nullptr; The last arg to WinHttpConnect is a reserved integer, not a pointer, so passing it NULL was incorrect -- change to 0 per MSDN. tools/windows/converter_exe/winhttp_client.cc(150,42): error: cannot initialize a parameter of type 'DWORD' (aka 'unsigned long') with an rvalue of type 'std::nullptr_t' 150 | nullptr)); We need to pass explicit 0 for DWORD_PTR types. tools/windows/converter_exe/wininet_client.cc(175,39): error: cannot initialize a parameter of type 'DWORD_PTR' (aka 'unsigned long long') with an rvalue of type 'std::nullptr_t' 175 | nullptr)); Change-Id: Id5f5b65a4279fe7aa1cbc1b99b18813d6a150117 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/6388180 Reviewed-by: Lei Zhang <[email protected]>
1 parent 9d80200 commit 6290b99

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

src/client/windows/crash_generation/client_info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ClientInfo::ClientInfo(CrashGenerationServer* crash_server,
5757
dump_generated_handle_(nullptr),
5858
dump_request_wait_handle_(nullptr),
5959
process_exit_wait_handle_(nullptr),
60-
crash_id_(nullptr) {
60+
crash_id_(0) {
6161
GetSystemTimeAsFileTime(&start_time_);
6262
}
6363

src/client/windows/crash_generation/crash_generation_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ bool CrashGenerationClient::RequestUpload(DWORD crash_id) {
206206

207207
CustomClientInfo custom_info = {nullptr, 0};
208208
ProtocolMessage msg(MESSAGE_TAG_UPLOAD_REQUEST, crash_id,
209-
static_cast<MINIDUMP_TYPE>(nullptr), nullptr, nullptr,
209+
MiniDumpNormal, nullptr, nullptr,
210210
nullptr, custom_info, nullptr, nullptr, nullptr);
211211
DWORD bytes_count = 0;
212212
bool success = WriteFile(pipe, &msg, sizeof(msg), &bytes_count, nullptr) != 0;

src/client/windows/crash_generation/crash_generation_server.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ void CrashGenerationServer::HandleDisconnectingState() {
565565
// Done serving the client.
566566
client_info_ = nullptr;
567567

568-
overlapped_.Internal = nullptr;
569-
overlapped_.InternalHigh = nullptr;
568+
overlapped_.Internal = 0;
569+
overlapped_.InternalHigh = 0;
570570
overlapped_.Offset = 0;
571571
overlapped_.OffsetHigh = 0;
572572
overlapped_.Pointer = nullptr;

src/client/windows/crash_generation/minidump_generator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class HandleTraceData {
106106
HandleTraceData::HandleTraceData()
107107
: verifier_module_(nullptr),
108108
enumerate_resource_(nullptr),
109-
handle_(nullptr) {
109+
handle_(0) {
110110
}
111111

112112
HandleTraceData::~HandleTraceData() {

src/client/windows/handler/exception_handler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void ExceptionHandler::Initialize(
253253

254254
// Reserve one element for the instruction memory
255255
AppMemory instruction_memory;
256-
instruction_memory.ptr = nullptr;
256+
instruction_memory.ptr = reinterpret_cast<ULONG64>(nullptr);
257257
instruction_memory.length = 0;
258258
app_memory_info_.push_back(instruction_memory);
259259

src/tools/windows/converter_exe/winhttp_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ bool WinHttpClient::Connect(HttpHandle session_handle,
147147
ToHINTERNET(session_handle),
148148
server,
149149
static_cast<INTERNET_PORT>(port),
150-
nullptr));
150+
0));
151151
return !!(*connection_handle);
152152
}
153153

src/tools/windows/converter_exe/wininet_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ bool WinInetClient::OpenRequest(HttpHandle connection_handle,
172172
referrer,
173173
nullptr,
174174
is_secure ? INTERNET_FLAG_SECURE : 0,
175-
nullptr));
175+
0));
176176
return !!(*request_handle);
177177
}
178178

0 commit comments

Comments
 (0)