Skip to content

Commit

Permalink
fix: replace NULL by nullptr (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud authored Dec 20, 2023
1 parent a9eecd7 commit 3731c12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
46 changes: 23 additions & 23 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo
// vector<string> errors;
// 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).
//
// You can also do conditional logging:
Expand Down Expand Up @@ -570,12 +570,12 @@ DECLARE_string(logmailer);
// A very useful logging macro to log windows errors:
#define LOG_SYSRESULT(result) \
if (FAILED(HRESULT_FROM_WIN32(result))) { \
LPSTR message = NULL; \
LPSTR message = nullptr; \
LPSTR msg = reinterpret_cast<LPSTR>(&message); \
DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
FORMAT_MESSAGE_FROM_SYSTEM | \
FORMAT_MESSAGE_IGNORE_INSERTS, \
0, result, 0, msg, 100, NULL); \
0, result, 0, msg, 100, nullptr); \
if (message_length > 0) { \
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, 0, \
&@ac_google_namespace@::LogMessage::SendToLog).stream() \
Expand Down Expand Up @@ -608,7 +608,7 @@ GLOG_EXPORT void InitGoogleLogging(const char* argv0);

GLOG_EXPORT void InitGoogleLogging(const char* argv0,
CustomPrefixCallback prefix_callback,
void* prefix_callback_data = NULL);
void* prefix_callback_data = nullptr);

// Check if google's logging library has been initialized.
GLOG_EXPORT bool IsGoogleLoggingInitialized();
Expand All @@ -632,14 +632,14 @@ GLOG_EXPORT void SetApplicationFingerprint(const std::string& fingerprint);

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.
// This is useful for capturing messages and passing/storing them
// somewhere more specific than the global log of the process.
// Argument types:
// LogSink* sink;
// LogSeverity severity;
// The cast is to disambiguate NULL arguments.
// The cast is to disambiguate nullptr arguments.
#define LOG_TO_SINK(sink, severity) \
@ac_google_namespace@::LogMessage( \
__FILE__, __LINE__, \
Expand All @@ -651,27 +651,27 @@ class LogSink; // defined below
@ac_google_namespace@::GLOG_ ## severity, \
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.
// This is useful for capturing messages and storing them somewhere more
// specific than the global log of the process.
// Argument types:
// string* message;
// 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
// severity.
#define LOG_TO_STRING(severity, message) \
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).
// This is handy for capturing messages and perhaps passing them back
// to the caller, rather than reporting them immediately.
// Argument types:
// LogSeverity severity;
// vector<string> *outvec;
// The cast is to disambiguate NULL arguments.
// The cast is to disambiguate nullptr arguments.
#define LOG_STRING(severity, outvec) \
LOG_TO_STRING_##severity(static_cast<std::vector<std::string>*>(outvec)).stream()

Expand All @@ -696,13 +696,13 @@ class LogSink; // defined below
<< "Check failed: " #condition " "

// 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 {
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_.
operator bool() const {
return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL);
return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != nullptr);
}
std::string* str_;
};
Expand Down Expand Up @@ -818,7 +818,7 @@ std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext)
template <typename T1, typename T2> \
inline std::string* name##Impl(const T1& v1, const T2& v2, \
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); \
} \
inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \
Expand All @@ -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.
// This happens if, for example, those are used as token names in a
// yacc grammar.
DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(NULL, x)?
DEFINE_CHECK_OP_IMPL(Check_NE, !=) // Use CHECK(x == NULL) instead.
DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(nullptr, x)?
DEFINE_CHECK_OP_IMPL(Check_NE, !=) // Use CHECK(x == nullptr) instead.
DEFINE_CHECK_OP_IMPL(Check_LE, <=)
DEFINE_CHECK_OP_IMPL(Check_LT, < )
DEFINE_CHECK_OP_IMPL(Check_GE, >=)
Expand Down Expand Up @@ -897,7 +897,7 @@ typedef std::string _Check_string;
// CHECK_EQ(string("abc")[1], 'b');
//
// 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.

#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
Expand All @@ -907,11 +907,11 @@ typedef std::string _Check_string;
#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, 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.

#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.
// To avoid bloat, the definitions are in logging.cc.
Expand Down Expand Up @@ -1357,7 +1357,7 @@ GLOG_MSVC_POP_WARNING()
# endif
#endif
LogStream(char *buf, int len, int64 ctr)
: std::ostream(NULL),
: std::ostream(nullptr),
streambuf_(buf, len),
ctr_(ctr),
self_(this) {
Expand Down Expand Up @@ -1405,20 +1405,20 @@ public:
// saves 17 bytes per call site.
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
// also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
bool also_send_to_log);

// 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.
LogMessage(const char* file, int line, LogSeverity severity,
std::vector<std::string>* outvec);

// 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.
LogMessage(const char* file, int line, LogSeverity severity,
std::string* message);
Expand Down
4 changes: 2 additions & 2 deletions src/glog/vlog_is_on.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
// parsing of --vmodule flag and/or SetVLOGLevel calls.
#define VLOG_IS_ON(verboselevel) \
__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( \
AnnotateBenignRaceSized(__FILE__, __LINE__, &vlocal__, sizeof(@ac_google_namespace@::SiteFlag), "")); \
@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__); \
})
#else
Expand Down

0 comments on commit 3731c12

Please sign in to comment.