This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 5a80007e Replace NULL with nullptr in butil/debug (#3438)
5a80007e is described below
commit 5a80007eb128426a0eb0de4e78607ddb8a078651
Author: Bright Chen <[email protected]>
AuthorDate: Sat Aug 15 13:55:23 2026 +0800
Replace NULL with nullptr in butil/debug (#3438)
---
src/butil/debug/crash_logging.cc | 18 +++++++++---------
src/butil/debug/crash_logging.h | 2 +-
src/butil/debug/debugger_posix.cc | 4 ++--
src/butil/debug/dump_without_crashing.cc | 2 +-
src/butil/debug/stack_trace.cc | 2 +-
src/butil/debug/stack_trace.h | 2 +-
src/butil/debug/stack_trace_posix.cc | 28 ++++++++++++++--------------
7 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/butil/debug/crash_logging.cc b/src/butil/debug/crash_logging.cc
index d17e9c0e..6bd2f85c 100644
--- a/src/butil/debug/crash_logging.cc
+++ b/src/butil/debug/crash_logging.cc
@@ -20,7 +20,7 @@ namespace {
// Global map of crash key names to registration entries.
typedef std::map<butil::StringPiece, CrashKey> CrashKeyMap;
-CrashKeyMap* g_crash_keys_ = NULL;
+CrashKeyMap* g_crash_keys_ = nullptr;
// The maximum length of a single chunk.
size_t g_chunk_max_length_ = 0;
@@ -30,8 +30,8 @@ const char kChunkFormatString[] = "%s-%" PRIuS;
// The functions that are called to actually set the key-value pairs in the
// crash reportng system.
-SetCrashKeyValueFuncT g_set_key_func_ = NULL;
-ClearCrashKeyValueFuncT g_clear_key_func_ = NULL;
+SetCrashKeyValueFuncT g_set_key_func_ = nullptr;
+ClearCrashKeyValueFuncT g_clear_key_func_ = nullptr;
// For a given |length|, computes the number of chunks a value of that size
// will occupy.
@@ -142,7 +142,7 @@ size_t InitCrashKeys(const CrashKey* const keys, size_t
count,
DCHECK(!g_crash_keys_) << "Crash logging may only be initialized once";
if (!keys) {
delete g_crash_keys_;
- g_crash_keys_ = NULL;
+ g_crash_keys_ = nullptr;
return 0;
}
@@ -163,10 +163,10 @@ size_t InitCrashKeys(const CrashKey* const keys, size_t
count,
const CrashKey* LookupCrashKey(const butil::StringPiece& key) {
if (!g_crash_keys_)
- return NULL;
+ return nullptr;
CrashKeyMap::const_iterator it = g_crash_keys_->find(key.as_string());
if (it == g_crash_keys_->end())
- return NULL;
+ return nullptr;
return &(it->second);
}
@@ -192,10 +192,10 @@ std::vector<std::string> ChunkCrashKeyValue(const
CrashKey& crash_key,
void ResetCrashLoggingForTesting() {
delete g_crash_keys_;
- g_crash_keys_ = NULL;
+ g_crash_keys_ = nullptr;
g_chunk_max_length_ = 0;
- g_set_key_func_ = NULL;
- g_clear_key_func_ = NULL;
+ g_set_key_func_ = nullptr;
+ g_clear_key_func_ = nullptr;
}
} // namespace debug
diff --git a/src/butil/debug/crash_logging.h b/src/butil/debug/crash_logging.h
index d1cb131d..a525f07a 100644
--- a/src/butil/debug/crash_logging.h
+++ b/src/butil/debug/crash_logging.h
@@ -73,7 +73,7 @@ struct BUTIL_EXPORT CrashKey {
BUTIL_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count,
size_t chunk_max_length);
-// Returns the correspnding crash key object or NULL for a given key.
+// Returns the correspnding crash key object or nullptr for a given key.
BUTIL_EXPORT const CrashKey* LookupCrashKey(const butil::StringPiece& key);
// In the platform crash reporting implementation, these functions set and
diff --git a/src/butil/debug/debugger_posix.cc
b/src/butil/debug/debugger_posix.cc
index 0e463533..c806b845 100644
--- a/src/butil/debug/debugger_posix.cc
+++ b/src/butil/debug/debugger_posix.cc
@@ -92,13 +92,13 @@ bool BeingDebugged() {
size_t info_size = sizeof(info);
#if defined(OS_OPENBSD)
- if (sysctl(mib, arraysize(mib), NULL, &info_size, NULL, 0) < 0)
+ if (sysctl(mib, arraysize(mib), nullptr, &info_size, nullptr, 0) < 0)
return -1;
mib[5] = (info_size / sizeof(struct kinfo_proc));
#endif
- int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0);
+ int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, nullptr,
0);
DCHECK_EQ(sysctl_result, 0);
if (sysctl_result != 0) {
is_set = true;
diff --git a/src/butil/debug/dump_without_crashing.cc
b/src/butil/debug/dump_without_crashing.cc
index b4b2efce..4cf074bd 100644
--- a/src/butil/debug/dump_without_crashing.cc
+++ b/src/butil/debug/dump_without_crashing.cc
@@ -10,7 +10,7 @@ namespace {
// Pointer to the function that's called by DumpWithoutCrashing() to dump the
// process's memory.
-void (CDECL *dump_without_crashing_function_)() = NULL;
+void (CDECL *dump_without_crashing_function_)() = nullptr;
} // namespace
diff --git a/src/butil/debug/stack_trace.cc b/src/butil/debug/stack_trace.cc
index 97a4cd76..4dc49957 100644
--- a/src/butil/debug/stack_trace.cc
+++ b/src/butil/debug/stack_trace.cc
@@ -25,7 +25,7 @@ const void *const *StackTrace::Addresses(size_t* count) const
{
*count = count_;
if (count_)
return trace_;
- return NULL;
+ return nullptr;
}
size_t StackTrace::CopyAddressTo(void** buffer, size_t max_nframes) const {
diff --git a/src/butil/debug/stack_trace.h b/src/butil/debug/stack_trace.h
index e8120583..991348b1 100644
--- a/src/butil/debug/stack_trace.h
+++ b/src/butil/debug/stack_trace.h
@@ -104,7 +104,7 @@ namespace internal {
// POSIX doesn't define any async-signal safe function for converting
// an integer to ASCII. We'll have to define our own version.
// itoa_r() converts a (signed) integer to ASCII. It returns "buf", if the
-// conversion was successful or NULL otherwise. It never writes more than "sz"
+// conversion was successful or nullptr otherwise. It never writes more than
"sz"
// bytes. Output will be truncated as needed, and a NUL character is always
// appended.
BUTIL_EXPORT char *itoa_r(intptr_t i,
diff --git a/src/butil/debug/stack_trace_posix.cc
b/src/butil/debug/stack_trace_posix.cc
index 9ef91c2f..6b556e9a 100644
--- a/src/butil/debug/stack_trace_posix.cc
+++ b/src/butil/debug/stack_trace_posix.cc
@@ -98,7 +98,7 @@ void DemangleSymbols(std::string* text) {
// Try to demangle the mangled symbol candidate.
int status = 0;
scoped_ptr<char, butil::FreeDeleter> demangled_symbol(
- abi::__cxa_demangle(mangled_symbol.c_str(), NULL, 0, &status));
+ abi::__cxa_demangle(mangled_symbol.c_str(), nullptr, 0, &status));
if (status == 0) { // Demangling is successful.
// Remove the mangled symbol.
text->erase(mangled_start, mangled_end - mangled_start);
@@ -436,7 +436,7 @@ public:
DISALLOW_COPY_AND_ASSIGN(StringBacktraceOutputHandler);
void HandleOutput(const char* output) OVERRIDE {
- if (NULL == output) {
+ if (nullptr == output) {
return;
}
_str.append(output);
@@ -686,7 +686,7 @@ class SandboxSymbolizeHelper {
// Unregister symbolization callback.
void UnregisterCallback() {
if (is_initialized_) {
- google::InstallSymbolizeOpenObjectFileCallback(NULL);
+ google::InstallSymbolizeOpenObjectFileCallback(nullptr);
is_initialized_ = false;
}
}
@@ -739,7 +739,7 @@ bool EnableInProcessStackDumping() {
memset(&sigpipe_action, 0, sizeof(sigpipe_action));
sigpipe_action.sa_handler = SIG_IGN;
sigemptyset(&sigpipe_action.sa_mask);
- bool success = (sigaction(SIGPIPE, &sigpipe_action, NULL) == 0);
+ bool success = (sigaction(SIGPIPE, &sigpipe_action, nullptr) == 0);
// Avoid hangs during backtrace initialization, see above.
WarmUpBacktrace();
@@ -750,14 +750,14 @@ bool EnableInProcessStackDumping() {
action.sa_sigaction = &StackDumpSignalHandler;
sigemptyset(&action.sa_mask);
- success &= (sigaction(SIGILL, &action, NULL) == 0);
- success &= (sigaction(SIGABRT, &action, NULL) == 0);
- success &= (sigaction(SIGFPE, &action, NULL) == 0);
- success &= (sigaction(SIGBUS, &action, NULL) == 0);
- success &= (sigaction(SIGSEGV, &action, NULL) == 0);
+ success &= (sigaction(SIGILL, &action, nullptr) == 0);
+ success &= (sigaction(SIGABRT, &action, nullptr) == 0);
+ success &= (sigaction(SIGFPE, &action, nullptr) == 0);
+ success &= (sigaction(SIGBUS, &action, nullptr) == 0);
+ success &= (sigaction(SIGSEGV, &action, nullptr) == 0);
// On Linux, SIGSYS is reserved by the kernel for seccomp-bpf sandboxing.
#if !defined(OS_LINUX)
- success &= (sigaction(SIGSYS, &action, NULL) == 0);
+ success &= (sigaction(SIGSYS, &action, nullptr) == 0);
#endif // !defined(OS_LINUX)
return success;
@@ -832,11 +832,11 @@ char *itoa_r(intptr_t i, char *buf, size_t sz, int base,
size_t padding) {
// Make sure we can write at least one NUL byte.
size_t n = 1;
if (n > sz)
- return NULL;
+ return nullptr;
if (base < 2 || base > 16) {
buf[0] = '\000';
- return NULL;
+ return nullptr;
}
char *start = buf;
@@ -850,7 +850,7 @@ char *itoa_r(intptr_t i, char *buf, size_t sz, int base,
size_t padding) {
// Make sure we can write the '-' character.
if (++n > sz) {
buf[0] = '\000';
- return NULL;
+ return nullptr;
}
*start++ = '-';
}
@@ -862,7 +862,7 @@ char *itoa_r(intptr_t i, char *buf, size_t sz, int base,
size_t padding) {
// Make sure there is still enough space left in our output buffer.
if (++n > sz) {
buf[0] = '\000';
- return NULL;
+ return nullptr;
}
// Output the next digit.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]