fix: replace NULL by nullptr (#993)

This commit is contained in:
Sergiu Deitsch 2023-12-20 20:48:43 +01:00 committed by GitHub
parent a9eecd7f9a
commit 3731c120c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 25 deletions

View File

@ -205,7 +205,7 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo
// vector<string> errors; // vector<string> errors;
// LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num; // LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num;
// //
// This pushes back the new error onto 'errors'; if given a NULL pointer, // This pushes back the new error onto 'errors'; if given a nullptr pointer,
// it reports the error via LOG(ERROR). // it reports the error via LOG(ERROR).
// //
// You can also do conditional logging: // You can also do conditional logging:
@ -570,12 +570,12 @@ DECLARE_string(logmailer);
// A very useful logging macro to log windows errors: // A very useful logging macro to log windows errors:
#define LOG_SYSRESULT(result) \ #define LOG_SYSRESULT(result) \
if (FAILED(HRESULT_FROM_WIN32(result))) { \ if (FAILED(HRESULT_FROM_WIN32(result))) { \
LPSTR message = NULL; \ LPSTR message = nullptr; \
LPSTR msg = reinterpret_cast<LPSTR>(&message); \ LPSTR msg = reinterpret_cast<LPSTR>(&message); \
DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \ DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
FORMAT_MESSAGE_FROM_SYSTEM | \ FORMAT_MESSAGE_FROM_SYSTEM | \
FORMAT_MESSAGE_IGNORE_INSERTS, \ FORMAT_MESSAGE_IGNORE_INSERTS, \
0, result, 0, msg, 100, NULL); \ 0, result, 0, msg, 100, nullptr); \
if (message_length > 0) { \ if (message_length > 0) { \
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, 0, \ @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, 0, \
&@ac_google_namespace@::LogMessage::SendToLog).stream() \ &@ac_google_namespace@::LogMessage::SendToLog).stream() \
@ -608,7 +608,7 @@ GLOG_EXPORT void InitGoogleLogging(const char* argv0);
GLOG_EXPORT void InitGoogleLogging(const char* argv0, GLOG_EXPORT void InitGoogleLogging(const char* argv0,
CustomPrefixCallback prefix_callback, CustomPrefixCallback prefix_callback,
void* prefix_callback_data = NULL); void* prefix_callback_data = nullptr);
// Check if google's logging library has been initialized. // Check if google's logging library has been initialized.
GLOG_EXPORT bool IsGoogleLoggingInitialized(); GLOG_EXPORT bool IsGoogleLoggingInitialized();
@ -632,14 +632,14 @@ GLOG_EXPORT void SetApplicationFingerprint(const std::string& fingerprint);
class LogSink; // defined below class LogSink; // defined below
// If a non-NULL sink pointer is given, we push this message to that sink. // If a non-nullptr sink pointer is given, we push this message to that sink.
// For LOG_TO_SINK we then do normal LOG(severity) logging as well. // For LOG_TO_SINK we then do normal LOG(severity) logging as well.
// This is useful for capturing messages and passing/storing them // This is useful for capturing messages and passing/storing them
// somewhere more specific than the global log of the process. // somewhere more specific than the global log of the process.
// Argument types: // Argument types:
// LogSink* sink; // LogSink* sink;
// LogSeverity severity; // LogSeverity severity;
// The cast is to disambiguate NULL arguments. // The cast is to disambiguate nullptr arguments.
#define LOG_TO_SINK(sink, severity) \ #define LOG_TO_SINK(sink, severity) \
@ac_google_namespace@::LogMessage( \ @ac_google_namespace@::LogMessage( \
__FILE__, __LINE__, \ __FILE__, __LINE__, \
@ -651,27 +651,27 @@ class LogSink; // defined below
@ac_google_namespace@::GLOG_ ## severity, \ @ac_google_namespace@::GLOG_ ## severity, \
static_cast<@ac_google_namespace@::LogSink*>(sink), false).stream() static_cast<@ac_google_namespace@::LogSink*>(sink), false).stream()
// If a non-NULL string pointer is given, we write this message to that string. // If a non-nullptr string pointer is given, we write this message to that string.
// We then do normal LOG(severity) logging as well. // We then do normal LOG(severity) logging as well.
// This is useful for capturing messages and storing them somewhere more // This is useful for capturing messages and storing them somewhere more
// specific than the global log of the process. // specific than the global log of the process.
// Argument types: // Argument types:
// string* message; // string* message;
// LogSeverity severity; // LogSeverity severity;
// The cast is to disambiguate NULL arguments. // The cast is to disambiguate nullptr arguments.
// NOTE: LOG(severity) expands to LogMessage().stream() for the specified // NOTE: LOG(severity) expands to LogMessage().stream() for the specified
// severity. // severity.
#define LOG_TO_STRING(severity, message) \ #define LOG_TO_STRING(severity, message) \
LOG_TO_STRING_##severity(static_cast<std::string*>(message)).stream() LOG_TO_STRING_##severity(static_cast<std::string*>(message)).stream()
// If a non-NULL pointer is given, we push the message onto the end // If a non-nullptr pointer is given, we push the message onto the end
// of a vector of strings; otherwise, we report it with LOG(severity). // of a vector of strings; otherwise, we report it with LOG(severity).
// This is handy for capturing messages and perhaps passing them back // This is handy for capturing messages and perhaps passing them back
// to the caller, rather than reporting them immediately. // to the caller, rather than reporting them immediately.
// Argument types: // Argument types:
// LogSeverity severity; // LogSeverity severity;
// vector<string> *outvec; // vector<string> *outvec;
// The cast is to disambiguate NULL arguments. // The cast is to disambiguate nullptr arguments.
#define LOG_STRING(severity, outvec) \ #define LOG_STRING(severity, outvec) \
LOG_TO_STRING_##severity(static_cast<std::vector<std::string>*>(outvec)).stream() LOG_TO_STRING_##severity(static_cast<std::vector<std::string>*>(outvec)).stream()
@ -696,13 +696,13 @@ class LogSink; // defined below
<< "Check failed: " #condition " " << "Check failed: " #condition " "
// A container for a string pointer which can be evaluated to a bool - // A container for a string pointer which can be evaluated to a bool -
// true iff the pointer is NULL. // true iff the pointer is nullptr.
struct CheckOpString { struct CheckOpString {
CheckOpString(std::string* str) : str_(str) { } CheckOpString(std::string* str) : str_(str) { }
// No destructor: if str_ is non-NULL, we're about to LOG(FATAL), // No destructor: if str_ is non-nullptr, we're about to LOG(FATAL),
// so there's no point in cleaning up str_. // so there's no point in cleaning up str_.
operator bool() const { operator bool() const {
return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL); return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != nullptr);
} }
std::string* str_; std::string* str_;
}; };
@ -818,7 +818,7 @@ std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext)
template <typename T1, typename T2> \ template <typename T1, typename T2> \
inline std::string* name##Impl(const T1& v1, const T2& v2, \ inline std::string* name##Impl(const T1& v1, const T2& v2, \
const char* exprtext) { \ const char* exprtext) { \
if (GOOGLE_PREDICT_TRUE(v1 op v2)) return NULL; \ if (GOOGLE_PREDICT_TRUE(v1 op v2)) return nullptr; \
else return MakeCheckOpString(v1, v2, exprtext); \ else return MakeCheckOpString(v1, v2, exprtext); \
} \ } \
inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \ inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \
@ -829,8 +829,8 @@ std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext)
// base/logging.h provides its own #defines for the simpler names EQ, NE, etc. // base/logging.h provides its own #defines for the simpler names EQ, NE, etc.
// This happens if, for example, those are used as token names in a // This happens if, for example, those are used as token names in a
// yacc grammar. // yacc grammar.
DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(NULL, x)? DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(nullptr, x)?
DEFINE_CHECK_OP_IMPL(Check_NE, !=) // Use CHECK(x == NULL) instead. DEFINE_CHECK_OP_IMPL(Check_NE, !=) // Use CHECK(x == nullptr) instead.
DEFINE_CHECK_OP_IMPL(Check_LE, <=) DEFINE_CHECK_OP_IMPL(Check_LE, <=)
DEFINE_CHECK_OP_IMPL(Check_LT, < ) DEFINE_CHECK_OP_IMPL(Check_LT, < )
DEFINE_CHECK_OP_IMPL(Check_GE, >=) DEFINE_CHECK_OP_IMPL(Check_GE, >=)
@ -897,7 +897,7 @@ typedef std::string _Check_string;
// CHECK_EQ(string("abc")[1], 'b'); // CHECK_EQ(string("abc")[1], 'b');
// //
// WARNING: These don't compile correctly if one of the arguments is a pointer // WARNING: These don't compile correctly if one of the arguments is a pointer
// and the other is NULL. To work around this, simply static_cast NULL to the // and the other is nullptr. To work around this, simply static_cast nullptr to the
// type of the desired pointer. // type of the desired pointer.
#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2) #define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
@ -907,11 +907,11 @@ typedef std::string _Check_string;
#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2) #define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2) #define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
// Check that the input is non NULL. This very useful in constructor // Check that the input is non nullptr. This very useful in constructor
// initializer lists. // initializer lists.
#define CHECK_NOTNULL(val) \ #define CHECK_NOTNULL(val) \
@ac_google_namespace@::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) @ac_google_namespace@::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non nullptr", (val))
// Helper functions for string comparisons. // Helper functions for string comparisons.
// To avoid bloat, the definitions are in logging.cc. // To avoid bloat, the definitions are in logging.cc.
@ -1357,7 +1357,7 @@ GLOG_MSVC_POP_WARNING()
# endif # endif
#endif #endif
LogStream(char *buf, int len, int64 ctr) LogStream(char *buf, int len, int64 ctr)
: std::ostream(NULL), : std::ostream(nullptr),
streambuf_(buf, len), streambuf_(buf, len),
ctr_(ctr), ctr_(ctr),
self_(this) { self_(this) {
@ -1405,20 +1405,20 @@ public:
// saves 17 bytes per call site. // saves 17 bytes per call site.
LogMessage(const char* file, int line, LogSeverity severity); LogMessage(const char* file, int line, LogSeverity severity);
// Constructor to log this message to a specified sink (if not NULL). // Constructor to log this message to a specified sink (if not nullptr).
// Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
// also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise. // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink, LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
bool also_send_to_log); bool also_send_to_log);
// Constructor where we also give a vector<string> pointer // Constructor where we also give a vector<string> pointer
// for storing the messages (if the pointer is not NULL). // for storing the messages (if the pointer is not nullptr).
// Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog. // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog.
LogMessage(const char* file, int line, LogSeverity severity, LogMessage(const char* file, int line, LogSeverity severity,
std::vector<std::string>* outvec); std::vector<std::string>* outvec);
// Constructor where we also give a string pointer for storing the // Constructor where we also give a string pointer for storing the
// message (if the pointer is not NULL). Implied are: ctr = 0, // message (if the pointer is not nullptr). Implied are: ctr = 0,
// send_method = &LogMessage::WriteToStringAndLog. // send_method = &LogMessage::WriteToStringAndLog.
LogMessage(const char* file, int line, LogSeverity severity, LogMessage(const char* file, int line, LogSeverity severity,
std::string* message); std::string* message);

View File

@ -74,11 +74,11 @@
// parsing of --vmodule flag and/or SetVLOGLevel calls. // parsing of --vmodule flag and/or SetVLOGLevel calls.
#define VLOG_IS_ON(verboselevel) \ #define VLOG_IS_ON(verboselevel) \
__extension__ \ __extension__ \
({ static @ac_google_namespace@::SiteFlag vlocal__ = {NULL, NULL, 0, NULL}; \ ({ static @ac_google_namespace@::SiteFlag vlocal__ = {nullptr, nullptr, 0, nullptr}; \
GLOG_IFDEF_THREAD_SANITIZER( \ GLOG_IFDEF_THREAD_SANITIZER( \
AnnotateBenignRaceSized(__FILE__, __LINE__, &vlocal__, sizeof(@ac_google_namespace@::SiteFlag), "")); \ AnnotateBenignRaceSized(__FILE__, __LINE__, &vlocal__, sizeof(@ac_google_namespace@::SiteFlag), "")); \
@ac_google_namespace@::int32 verbose_level__ = (verboselevel); \ @ac_google_namespace@::int32 verbose_level__ = (verboselevel); \
(vlocal__.level == NULL ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \ (vlocal__.level == nullptr ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \
__FILE__, verbose_level__) : *vlocal__.level >= verbose_level__); \ __FILE__, verbose_level__) : *vlocal__.level >= verbose_level__); \
}) })
#else #else