From 55af3d190b31e6b09943bb6456dc1085688fc007 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 8 Jun 2017 14:48:12 -0700 Subject: [PATCH] Refer to nullptr not NULL Summary: Folly is a C++ library not a C library, and (almost) universally uses `nullptr` everywhere, so refer to `nullptr` rather than `NULL`. This also fixes the 1 place in our actual code where we were using `NULL` rather than `nullptr`. Reviewed By: yfeldblum Differential Revision: D5204766 fbshipit-source-id: 2a5d5011a28d7d5dd48789f60643a656f51b9732 --- folly/ConcurrentSkipList.h | 2 +- folly/Malloc.h | 8 ++++---- folly/Synchronized.h | 4 ++-- folly/experimental/exception_tracer/ExceptionTracer.cpp | 2 +- folly/experimental/symbolizer/Elf.h | 2 +- folly/io/IOBuf.cpp | 2 +- folly/io/async/AsyncSSLSocket.cpp | 2 +- folly/io/async/EventBase.cpp | 2 +- folly/portability/OpenSSL.cpp | 4 ++-- folly/stats/Histogram.h | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/folly/ConcurrentSkipList.h b/folly/ConcurrentSkipList.h index 7d5cb958..8b06f331 100644 --- a/folly/ConcurrentSkipList.h +++ b/folly/ConcurrentSkipList.h @@ -235,7 +235,7 @@ class ConcurrentSkipList { // if found, succs[0..foundLayer] need to point to the cached foundNode, // as foundNode might be deleted at the same time thus pred->skip() can - // return NULL or another node. + // return nullptr or another node. succs[layer] = foundNode ? foundNode : node; } return foundLayer; diff --git a/folly/Malloc.h b/folly/Malloc.h index ca9e7ae1..cb7bfe37 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -67,7 +67,7 @@ namespace folly { /** * Declare *allocx() and mallctl*() as weak symbols. These will be provided by - * jemalloc if we are using jemalloc, or will be NULL if we are using another + * jemalloc if we are using jemalloc, or will be nullptr if we are using another * malloc implementation. */ extern "C" void* mallocx(size_t, int) @@ -148,9 +148,9 @@ namespace folly { * Determine if we are using jemalloc or not. */ FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept { - // Checking for rallocx != NULL is not sufficient; we may be in a dlopen()ed - // module that depends on libjemalloc, so rallocx is resolved, but the main - // program might be using a different memory allocator. + // Checking for rallocx != nullptr is not sufficient; we may be in a + // dlopen()ed module that depends on libjemalloc, so rallocx is resolved, but + // the main program might be using a different memory allocator. // How do we determine that we're using jemalloc? In the hackiest // way possible. We allocate memory using malloc() and see if the // per-thread counter of allocated memory increases. This makes me diff --git a/folly/Synchronized.h b/folly/Synchronized.h index 5d912034..4fce71b5 100644 --- a/folly/Synchronized.h +++ b/folly/Synchronized.h @@ -626,7 +626,7 @@ struct Synchronized : public SynchronizedBase< /** * Attempts to acquire for a given number of milliseconds. If - * acquisition is unsuccessful, the returned LockedPtr is NULL. + * acquisition is unsuccessful, the returned LockedPtr is nullptr. * * NOTE: This API is deprecated. Use lock(), wlock(), or rlock() instead. * In the future it will be marked with a deprecation attribute to emit @@ -638,7 +638,7 @@ struct Synchronized : public SynchronizedBase< /** * Attempts to acquire for a given number of milliseconds. If - * acquisition is unsuccessful, the returned ConstLockedPtr is NULL. + * acquisition is unsuccessful, the returned ConstLockedPtr is nullptr. * * NOTE: This API is deprecated. Use lock(), wlock(), or rlock() instead. * In the future it will be marked with a deprecation attribute to emit diff --git a/folly/experimental/exception_tracer/ExceptionTracer.cpp b/folly/experimental/exception_tracer/ExceptionTracer.cpp index e7ef30f4..2c6e109a 100644 --- a/folly/experimental/exception_tracer/ExceptionTracer.cpp +++ b/folly/experimental/exception_tracer/ExceptionTracer.cpp @@ -155,7 +155,7 @@ std::vector getCurrentExceptions() { // Dependent exceptions (thrown via std::rethrow_exception) aren't // standard ABI __cxa_exception objects, and are correctly labeled as // such in the exception_class field. We could try to extract the - // primary exception type in horribly hacky ways, but, for now, NULL. + // primary exception type in horribly hacky ways, but, for now, nullptr. info.type = isAbiCppException(currentException) ? currentException->exceptionType : diff --git a/folly/experimental/symbolizer/Elf.h b/folly/experimental/symbolizer/Elf.h index 9676e23c..b16c8718 100644 --- a/folly/experimental/symbolizer/Elf.h +++ b/folly/experimental/symbolizer/Elf.h @@ -51,7 +51,7 @@ class ElfFile { // Open the ELF file. // Returns 0 on success, kSystemError (guaranteed to be -1) (and sets errno) // on IO error, kInvalidElfFile (and sets errno to EINVAL) for an invalid - // Elf file. On error, if msg is not NULL, sets *msg to a static string + // Elf file. On error, if msg is not nullptr, sets *msg to a static string // indicating what failed. enum { kSuccess = 0, diff --git a/folly/io/IOBuf.cpp b/folly/io/IOBuf.cpp index c34b5f41..56986061 100644 --- a/folly/io/IOBuf.cpp +++ b/folly/io/IOBuf.cpp @@ -136,7 +136,7 @@ IOBuf::SharedInfo::SharedInfo(FreeFunction fn, void* arg) void* IOBuf::operator new(size_t size) { size_t fullSize = offsetof(HeapStorage, buf) + size; auto* storage = static_cast(malloc(fullSize)); - // operator new is not allowed to return NULL + // operator new is not allowed to return nullptr if (UNLIKELY(storage == nullptr)) { throw std::bad_alloc(); } diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index 234ab5ae..1379bf90 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -406,7 +406,7 @@ size_t AsyncSSLSocket::getRawBytesWritten() const { return 0; } BIO* next = BIO_next(b); - while (next != NULL) { + while (next != nullptr) { b = next; next = BIO_next(b); } diff --git a/folly/io/async/EventBase.cpp b/folly/io/async/EventBase.cpp index a485d332..cf8a87fa 100644 --- a/folly/io/async/EventBase.cpp +++ b/folly/io/async/EventBase.cpp @@ -94,7 +94,7 @@ EventBase::EventBase(bool enableTimeMeasurement) // The value 'current_base' (libevent 1) or // 'event_global_current_base_' (libevent 2) is filled in by event_set(), // allowing examination of its value without an explicit reference here. - // If ev.ev_base is NULL, then event_init() must be called, otherwise + // If ev.ev_base is nullptr, then event_init() must be called, otherwise // call event_base_new(). event_set(&ev, 0, 0, nullptr, nullptr); if (!ev.ev_base) { diff --git a/folly/portability/OpenSSL.cpp b/folly/portability/OpenSSL.cpp index fb47df42..ccaea765 100644 --- a/folly/portability/OpenSSL.cpp +++ b/folly/portability/OpenSSL.cpp @@ -97,8 +97,8 @@ unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION* s) { // This is taken from OpenSSL 1.1.0 int DH_set0_pqg(DH* dh, BIGNUM* p, BIGNUM* q, BIGNUM* g) { - /* If the fields p and g in d are NULL, the corresponding input - * parameters MUST be non-NULL. q may remain NULL. + /* If the fields p and g in d are nullptr, the corresponding input + * parameters MUST not be nullptr. q may remain nullptr. */ if (dh == nullptr || (dh->p == nullptr && p == nullptr) || (dh->g == nullptr && g == nullptr)) { diff --git a/folly/stats/Histogram.h b/folly/stats/Histogram.h index e8e8c97c..ca45ba3b 100644 --- a/folly/stats/Histogram.h +++ b/folly/stats/Histogram.h @@ -417,7 +417,7 @@ class Histogram { * Get the bucket that the specified percentile falls into * * The lowest and highest percentile data points in returned bucket will be - * returned in the lowPct and highPct arguments, if they are non-NULL. + * returned in the lowPct and highPct arguments, if they are not nullptr. */ size_t getPercentileBucketIdx( double pct, -- 2.34.1