Skip to content

Commit

Permalink
convert random NULL usage to nullptr
Browse files Browse the repository at this point in the history
Since NULL requires headers to be included to define it, and some of
our files are missing those includes depending on optimization settings,
switch over to the language nullptr builtin to avoid.

This doesn't cover all the files in the tree, just some random Linux
and common ones that I ran into build failures with.

Change-Id: I0a68538fa138148c2a0c1ec5d6dd558ffd4629b2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/6173184
Reviewed-by: Lei Zhang <[email protected]>
  • Loading branch information
vapier committed Jan 15, 2025
1 parent 0dfd774 commit 69621cb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/client/linux/handler/exception_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class ExceptionHandler {

// Returns whether out-of-process dump generation is used or not.
bool IsOutOfProcess() const {
return crash_generation_client_.get() != NULL;
return crash_generation_client_.get() != nullptr;
}

// Add information about a memory mapping. This can be used if
Expand Down
8 changes: 4 additions & 4 deletions src/client/linux/handler/microdump_extra_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ struct MicrodumpExtraInfo {
const char* process_type;

MicrodumpExtraInfo()
: build_fingerprint(NULL),
product_info(NULL),
gpu_fingerprint(NULL),
process_type(NULL) {}
: build_fingerprint(nullptr),
product_info(nullptr),
gpu_fingerprint(nullptr),
process_type(nullptr) {}
};

}
Expand Down
4 changes: 2 additions & 2 deletions src/client/linux/handler/minidump_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MinidumpDescriptor {
: mode_(kWriteMinidumpToFile),
fd_(-1),
directory_(directory),
c_path_(NULL),
c_path_(nullptr),
size_limit_(-1),
address_within_principal_mapping_(0),
skip_dump_if_principal_mapping_not_referenced_(false),
Expand All @@ -72,7 +72,7 @@ class MinidumpDescriptor {
explicit MinidumpDescriptor(int fd)
: mode_(kWriteMinidumpToFd),
fd_(fd),
c_path_(NULL),
c_path_(nullptr),
size_limit_(-1),
address_within_principal_mapping_(0),
skip_dump_if_principal_mapping_not_referenced_(false),
Expand Down
2 changes: 1 addition & 1 deletion src/client/linux/minidump_writer/cpu_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CpuSet {
size_t item_len = static_cast<size_t>(p_end - p);
const char* item_next =
static_cast<const char*>(my_memchr(p, ',', item_len));
if (item_next != NULL) {
if (item_next != nullptr) {
p = item_next + 1;
item_len = static_cast<size_t>(item_next - item);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/client/linux/minidump_writer/proc_cpuinfo_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ProcCpuInfoReader {
// - <field-name> can contain spaces.
// - some fields have an empty <value>
char* sep = static_cast<char*>(my_memchr(line, ':', line_len));
if (sep == NULL)
if (sep == nullptr)
continue;

// Record the value. Skip leading space after the column to get
Expand Down
6 changes: 3 additions & 3 deletions src/common/memory_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace google_breakpad {
// in a crashed environment.
class MemoryRange {
public:
MemoryRange() : data_(NULL), length_(0) {}
MemoryRange() : data_(nullptr), length_(0) {}

MemoryRange(const void* data, size_t length) {
Set(data, length);
Expand All @@ -60,7 +60,7 @@ class MemoryRange {

// Resets to an empty range.
void Reset() {
data_ = NULL;
data_ = nullptr;
length_ = 0;
}

Expand All @@ -87,7 +87,7 @@ class MemoryRange {
// |sub_offset| bytes of this memory range, or NULL if the subrange
// is out of bounds.
const void* GetData(size_t sub_offset, size_t sub_length) const {
return Covers(sub_offset, sub_length) ? (data_ + sub_offset) : NULL;
return Covers(sub_offset, sub_length) ? (data_ + sub_offset) : nullptr;
}

// Same as the two-argument version of GetData() but uses sizeof(DataType)
Expand Down
28 changes: 14 additions & 14 deletions src/common/scoped_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class scoped_ptr {
// Constructor. Defaults to initializing with NULL.
// There is no way to create an uninitialized scoped_ptr.
// The input parameter must be allocated with new.
explicit scoped_ptr(C* p = NULL) : ptr_(p) { }
explicit scoped_ptr(C* p = nullptr) : ptr_(p) { }

// Destructor. If there is a C object, delete it.
// We don't need to test ptr_ == NULL because C++ does that for us.
Expand All @@ -101,7 +101,7 @@ class scoped_ptr {
// Reset. Deletes the current owned object, if any.
// Then takes ownership of a new object, if given.
// this->reset(this->get()) works.
void reset(C* p = NULL) {
void reset(C* p = nullptr) {
if (p != ptr_) {
enum { type_must_be_complete = sizeof(C) };
delete ptr_;
Expand All @@ -112,11 +112,11 @@ class scoped_ptr {
// Accessors to get the owned object.
// operator* and operator-> will assert() if there is no current object.
C& operator*() const {
assert(ptr_ != NULL);
assert(ptr_ != nullptr);
return *ptr_;
}
C* operator->() const {
assert(ptr_ != NULL);
assert(ptr_ != nullptr);
return ptr_;
}
C* get() const { return ptr_; }
Expand All @@ -141,7 +141,7 @@ class scoped_ptr {
// and will not own the object any more.
C* release() {
C* retVal = ptr_;
ptr_ = NULL;
ptr_ = nullptr;
return retVal;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ class scoped_array {
// Constructor. Defaults to intializing with NULL.
// There is no way to create an uninitialized scoped_array.
// The input parameter must be allocated with new [].
explicit scoped_array(C* p = NULL) : array_(p) { }
explicit scoped_array(C* p = nullptr) : array_(p) { }

// Destructor. If there is a C object, delete it.
// We don't need to test ptr_ == NULL because C++ does that for us.
Expand All @@ -206,7 +206,7 @@ class scoped_array {
// Reset. Deletes the current owned object, if any.
// Then takes ownership of a new object, if given.
// this->reset(this->get()) works.
void reset(C* p = NULL) {
void reset(C* p = nullptr) {
if (p != array_) {
enum { type_must_be_complete = sizeof(C) };
delete[] array_;
Expand All @@ -218,7 +218,7 @@ class scoped_array {
// Will assert() if there is no current object, or index i is negative.
C& operator[](ptrdiff_t i) const {
assert(i >= 0);
assert(array_ != NULL);
assert(array_ != nullptr);
return array_[i];
}

Expand Down Expand Up @@ -248,7 +248,7 @@ class scoped_array {
// and will not own the object any more.
C* release() {
C* retVal = array_;
array_ = NULL;
array_ = nullptr;
return retVal;
}

Expand Down Expand Up @@ -304,7 +304,7 @@ class scoped_ptr_malloc {
// The input parameter must be allocated with an allocator that matches the
// Free functor. For the default Free functor, this is malloc, calloc, or
// realloc.
explicit scoped_ptr_malloc(C* p = NULL): ptr_(p) {}
explicit scoped_ptr_malloc(C* p = nullptr): ptr_(p) {}

// Destructor. If there is a C object, call the Free functor.
~scoped_ptr_malloc() {
Expand All @@ -314,7 +314,7 @@ class scoped_ptr_malloc {
// Reset. Calls the Free functor on the current owned object, if any.
// Then takes ownership of a new object, if given.
// this->reset(this->get()) works.
void reset(C* p = NULL) {
void reset(C* p = nullptr) {
if (ptr_ != p) {
FreeProc free_proc;
free_proc(ptr_);
Expand All @@ -326,12 +326,12 @@ class scoped_ptr_malloc {
// operator* and operator-> will cause an assert() failure if there is
// no current object.
C& operator*() const {
assert(ptr_ != NULL);
assert(ptr_ != nullptr);
return *ptr_;
}

C* operator->() const {
assert(ptr_ != NULL);
assert(ptr_ != nullptr);
return ptr_;
}

Expand Down Expand Up @@ -366,7 +366,7 @@ class scoped_ptr_malloc {
// and will not own the object any more.
C* release() {
C* tmp = ptr_;
ptr_ = NULL;
ptr_ = nullptr;
return tmp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/processor/static_map_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ template<typename Key, typename Value, typename Compare>
class StaticMapIterator {
public:
// Constructors.
StaticMapIterator(): index_(-1), base_(NULL) { }
StaticMapIterator(): index_(-1), base_(nullptr) { }

// Increment & Decrement operators:
StaticMapIterator& operator++();
Expand Down

0 comments on commit 69621cb

Please sign in to comment.