THRIFT-5225: Use nullptr instead of NULL
Patch: Zezeng Wang
This closes #2168
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index 20fbcdb..5732996 100644
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -384,11 +384,11 @@
// create a C client
tsocket = (ThriftSocket *) g_object_new (THRIFT_TYPE_SOCKET,
"hostname", "localhost",
- "port", TEST_PORT, NULL);
+ "port", TEST_PORT, nullptr);
protocol = (ThriftBinaryProtocol *) g_object_new (THRIFT_TYPE_BINARY_PROTOCOL,
"transport",
- tsocket, NULL);
- client = (TTestThriftTestClient *) g_object_new (T_TEST_TYPE_THRIFT_TEST_CLIENT, "input_protocol", protocol, "output_protocol", protocol, NULL);
+ tsocket, nullptr);
+ client = (TTestThriftTestClient *) g_object_new (T_TEST_TYPE_THRIFT_TEST_CLIENT, "input_protocol", protocol, "output_protocol", protocol, nullptr);
iface = T_TEST_THRIFT_TEST_IF (client);
// open and send
diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp
index 800ba07..a30879a 100644
--- a/lib/cpp/src/thrift/TOutput.cpp
+++ b/lib/cpp/src/thrift/TOutput.cpp
@@ -122,8 +122,8 @@
#else // HAVE_STRERROR_R
#ifdef _WIN32
const size_t size = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, errno_copy, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- b_errbuf, sizeof(b_errbuf), NULL);
+ nullptr, errno_copy, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ b_errbuf, sizeof(b_errbuf), nullptr);
if (size > 2 && b_errbuf[size-2] == '\r' && b_errbuf[size-1] == '\n') {
b_errbuf[size-2] = '\0';
diff --git a/lib/cpp/src/thrift/VirtualProfiling.cpp b/lib/cpp/src/thrift/VirtualProfiling.cpp
index 6ce346b..4d752cf 100644
--- a/lib/cpp/src/thrift/VirtualProfiling.cpp
+++ b/lib/cpp/src/thrift/VirtualProfiling.cpp
@@ -112,7 +112,7 @@
void* getFrame(int index) const {
int adjusted_index = index + skip_;
if (adjusted_index < 0 || adjusted_index >= numCallers_) {
- return NULL;
+ return nullptr;
}
return callers_[adjusted_index];
}
@@ -151,7 +151,7 @@
};
Key(const Backtrace* bt, const std::type_info& type_info)
- : backtrace_(bt), typeName1_(type_info.name()), typeName2_(NULL) {}
+ : backtrace_(bt), typeName1_(type_info.name()), typeName2_(nullptr) {}
Key(const Backtrace* bt, const std::type_info& type_info1, const std::type_info& type_info2)
: backtrace_(bt), typeName1_(type_info1.name()), typeName2_(type_info2.name()) {}
@@ -189,7 +189,7 @@
*/
void cleanup() {
delete backtrace_;
- backtrace_ = NULL;
+ backtrace_ = nullptr;
}
int cmp(const Key& k) const {
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 26ffa68..ea394c8 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -1341,7 +1341,7 @@
FD_ZERO(&efds);
FD_SET(fd, &wfds);
FD_SET(fd, &efds);
- ret = select(static_cast<int>(fd + 1), NULL, &wfds, &efds, NULL);
+ ret = select(static_cast<int>(fd + 1), nullptr, &wfds, &efds, nullptr);
if (ret < 0) {
return false;
} else if (ret == 0) {
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index e44c7ee..65e569d 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -158,7 +158,7 @@
/// The optional user-provided event-base (for single-thread servers)
event_base* userEventBase_;
- /// For processing via thread pool, may be NULL
+ /// For processing via thread pool, may be nullptr
std::shared_ptr<ThreadManager> threadManager_;
/// Is thread pool processing?
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index 329d220..d8a1b3e 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -112,7 +112,7 @@
const uint8_t* TBufferedTransport::borrowSlow(uint8_t* buf, uint32_t* len) {
(void)buf;
(void)len;
- // Simply return NULL. We don't know if there is actually data available on
+ // Simply return nullptr. We don't know if there is actually data available on
// the underlying transport, so calling read() might block.
return nullptr;
}
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h
index df06586..86f0c5a 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.h
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.h
@@ -137,7 +137,7 @@
/**
* Slow path borrow.
*
- * POSTCONDITION: return == NULL || rBound_ - rBase_ >= *len
+ * POSTCONDITION: return == nullptr || rBound_ - rBase_ >= *len
*/
virtual const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len) = 0;
@@ -245,7 +245,7 @@
/**
* The following behavior is currently implemented by TBufferedTransport,
* but that may change in a future version:
- * 1/ If len is at most rBufSize_, borrow will never return NULL.
+ * 1/ If len is at most rBufSize_, borrow will never return nullptr.
* Depending on the underlying transport, it could throw an exception
* or hang forever.
* 2/ Some borrow requests may copy bytes internally. However,
diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
index f811328..e8997d7 100644
--- a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
@@ -49,7 +49,7 @@
* Gets a new dynamically allocated transport object and passes it to the
* caller. Note that it is the explicit duty of the caller to free the
* allocated object. The returned TTransport object must always be in the
- * opened state. NULL should never be returned, instead an Exception should
+ * opened state. nullptr should never be returned, instead an Exception should
* always be thrown.
*
* @return A new TTransport object
@@ -58,7 +58,7 @@
std::shared_ptr<TSocket> accept() {
std::shared_ptr<TSocket> result = acceptImpl();
if (!result) {
- throw TTransportException("accept() may not return NULL");
+ throw TTransportException("accept() may not return nullptr");
}
return result;
}
diff --git a/lib/cpp/src/thrift/transport/TPipe.cpp b/lib/cpp/src/thrift/transport/TPipe.cpp
index 72af4fc..4c2fea9 100644
--- a/lib/cpp/src/thrift/transport/TPipe.cpp
+++ b/lib/cpp/src/thrift/transport/TPipe.cpp
@@ -183,7 +183,7 @@
uint32_t written = 0;
while (written < len) {
- BOOL result = ::WriteFile(pipe, buf + written, len - written, NULL, &tempOverlap);
+ BOOL result = ::WriteFile(pipe, buf + written, len - written, nullptr, &tempOverlap);
if (result == FALSE && ::GetLastError() != ERROR_IO_PENDING) {
GlobalOutput.perror("TPipe ::WriteFile errored GLE=", ::GetLastError());
@@ -205,7 +205,7 @@
memset(&tempOverlap, 0, sizeof(tempOverlap));
tempOverlap.hEvent = event;
- BOOL result = ::ReadFile(pipe, buf, len, NULL, &tempOverlap);
+ BOOL result = ::ReadFile(pipe, buf, len, nullptr, &tempOverlap);
if (result == FALSE && ::GetLastError() != ERROR_IO_PENDING) {
GlobalOutput.perror("TPipe ::ReadFile errored GLE=", ::GetLastError());
@@ -255,7 +255,7 @@
// Transport callbacks
//---------------------------------------------------------
bool TPipe::isOpen() const {
- return impl_.get() != NULL;
+ return impl_.get() != nullptr;
}
bool TPipe::peek() {
@@ -272,10 +272,10 @@
hPipe.reset(CreateFileA(pipename_.c_str(),
GENERIC_READ | GENERIC_WRITE,
0, // no sharing
- NULL, // default security attributes
+ nullptr, // default security attributes
OPEN_EXISTING, // opens existing pipe
flags,
- NULL)); // no template file
+ nullptr)); // no template file
if (hPipe.h != INVALID_HANDLE_VALUE)
break; // success!
@@ -310,7 +310,7 @@
buf, // buffer to receive reply
len, // size of buffer
&cbRead, // number of bytes read
- NULL); // not overlapped
+ nullptr); // not overlapped
if (!fSuccess && GetLastError() != ERROR_MORE_DATA)
return 0; // No more data, possibly because client disconnected.
@@ -330,7 +330,7 @@
buf, // message
len, // message length
&cbWritten, // bytes written
- NULL); // not overlapped
+ nullptr); // not overlapped
if (!fSuccess)
throw TTransportException(TTransportException::NOT_OPEN, "Write to pipe failed");
diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp
index e1cee80..2763551 100644
--- a/lib/cpp/src/thrift/transport/TPipeServer.cpp
+++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp
@@ -50,7 +50,7 @@
virtual HANDLE getWrtPipeHandle() = 0;
virtual HANDLE getClientRdPipeHandle() = 0;
virtual HANDLE getClientWrtPipeHandle() = 0;
- virtual HANDLE getNativeWaitHandle() { return NULL; }
+ virtual HANDLE getNativeWaitHandle() { return nullptr; }
};
class TAnonPipeServer : public TPipeServerImpl {
@@ -155,7 +155,7 @@
HANDLE TPipeServer::getNativeWaitHandle() {
if (impl_)
return impl_->getNativeWaitHandle();
- return NULL;
+ return nullptr;
}
//---- Constructors ----
@@ -227,7 +227,7 @@
&buf, // buffer to receive reply
0, // size of buffer
&br, // number of bytes read
- NULL); // not overlapped
+ nullptr); // not overlapped
if (!fSuccess && GetLastError() != ERROR_MORE_DATA) {
GlobalOutput.perror("TPipeServer unable to initiate pipe comms, GLE=", GetLastError());
@@ -248,7 +248,7 @@
// The prior connection has been handled, so close the gate
ResetEvent(listen_event_.h);
- connectOverlap_.reset(NULL, 0, listen_event_.h);
+ connectOverlap_.reset(nullptr, 0, listen_event_.h);
connectOverlap_.h = Pipe_.h;
thread_->addWorkItem(&connectOverlap_);
@@ -283,7 +283,7 @@
shared_ptr<TTransport> TNamedPipeServer::acceptImpl() {
{
TAutoCrit lock(pipe_protect_);
- if (cached_client_.get() != NULL) {
+ if (cached_client_.get() != nullptr) {
shared_ptr<TPipe> client;
// zero out cached_client, since we are about to return it.
client.swap(cached_client_);
@@ -350,7 +350,7 @@
bool TNamedPipeServer::createNamedPipe(const TAutoCrit& /*lockProof*/) {
- PSECURITY_DESCRIPTOR psd = NULL;
+ PSECURITY_DESCRIPTOR psd = nullptr;
ULONG size = 0;
if (!ConvertStringSecurityDescriptorToSecurityDescriptorA(securityDescriptor_.c_str(),
@@ -404,7 +404,7 @@
GetLastError());
return false;
}
- if (!SetSecurityDescriptorDacl(&sd, true, NULL, false)) {
+ if (!SetSecurityDescriptorDacl(&sd, true, nullptr, false)) {
GlobalOutput.perror("TPipeServer SetSecurityDescriptorDacl (anon) failed, GLE=",
GetLastError());
return false;
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
index 64f08dd..aa76980 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
@@ -562,7 +562,7 @@
throw TSSLException("BIO_flush: Handshake is not completed");
BIO* bio = SSL_get_wbio(ssl_);
if (bio == nullptr) {
- throw TSSLException("SSL_get_wbio returns NULL");
+ throw TSSLException("SSL_get_wbio returns nullptr");
}
if (BIO_flush(bio) != 1) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
@@ -798,7 +798,7 @@
}
if (bio == nullptr) {
- throw TSSLException("SSL_get_?bio returned NULL");
+ throw TSSLException("SSL_get_?bio returned nullptr");
}
if (BIO_get_fd(bio, &fdSocket) <= 0) {
@@ -943,7 +943,7 @@
void TSSLSocketFactory::loadCertificate(const char* path, const char* format) {
if (path == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadCertificateChain: either <path> or <format> is NULL");
+ "loadCertificateChain: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
if (SSL_CTX_use_certificate_chain_file(ctx_->get(), path) == 0) {
@@ -960,12 +960,12 @@
void TSSLSocketFactory::loadCertificateFromBuffer(const char* aCertificate, const char* format) {
if (aCertificate == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadCertificate: either <path> or <format> is NULL");
+ "loadCertificate: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
BIO* mem = BIO_new(BIO_s_mem());
BIO_puts(mem, aCertificate);
- X509* cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ X509* cert = PEM_read_bio_X509(mem, nullptr, 0, nullptr);
BIO_free(mem);
if (SSL_CTX_use_certificate(ctx_->get(), cert) == 0) {
@@ -982,7 +982,7 @@
void TSSLSocketFactory::loadPrivateKey(const char* path, const char* format) {
if (path == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadPrivateKey: either <path> or <format> is NULL");
+ "loadPrivateKey: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
if (SSL_CTX_use_PrivateKey_file(ctx_->get(), path, SSL_FILETYPE_PEM) == 0) {
@@ -997,7 +997,7 @@
void TSSLSocketFactory::loadPrivateKeyFromBuffer(const char* aPrivateKey, const char* format) {
if (aPrivateKey == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadPrivateKey: either <path> or <format> is NULL");
+ "loadPrivateKey: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
BIO* mem = BIO_new(BIO_s_mem());
@@ -1019,7 +1019,7 @@
void TSSLSocketFactory::loadTrustedCertificates(const char* path, const char* capath) {
if (path == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadTrustedCertificates: <path> is NULL");
+ "loadTrustedCertificates: <path> is nullptr");
}
if (SSL_CTX_load_verify_locations(ctx_->get(), path, capath) == 0) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
@@ -1037,7 +1037,7 @@
X509_STORE* vX509Store = SSL_CTX_get_cert_store(ctx_->get());
BIO* mem = BIO_new(BIO_s_mem());
BIO_puts(mem, aCertificate);
- X509* cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ X509* cert = PEM_read_bio_X509(mem, nullptr, 0, nullptr);
BIO_free(mem);
if (X509_STORE_add_cert(vX509Store, cert) == 0) {
@@ -1050,7 +1050,7 @@
if (aChain) {
mem = BIO_new(BIO_s_mem());
BIO_puts(mem, aChain);
- cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ cert = PEM_read_bio_X509(mem, nullptr, 0, nullptr);
BIO_free(mem);
if (SSL_CTX_add_extra_chain_cert(ctx_->get(), cert) == 0) {
diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h
index 9e84850..0c56609 100644
--- a/lib/cpp/src/thrift/transport/TServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TServerTransport.h
@@ -54,7 +54,7 @@
* Gets a new dynamically allocated transport object and passes it to the
* caller. Note that it is the explicit duty of the caller to free the
* allocated object. The returned TTransport object must always be in the
- * opened state. NULL should never be returned, instead an Exception should
+ * opened state. nullptr should never be returned, instead an Exception should
* always be thrown.
*
* @return A new TTransport object
@@ -63,7 +63,7 @@
std::shared_ptr<TTransport> accept() {
std::shared_ptr<TTransport> result = acceptImpl();
if (!result) {
- throw TTransportException("accept() may not return NULL");
+ throw TTransportException("accept() may not return nullptr");
}
return result;
}
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index 3811279..a1a6dfb 100644
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -432,7 +432,7 @@
void TSocket::unix_open() {
if (!path_.empty()) {
- // Unix Domain SOcket does not need addrinfo struct, so we pass NULL
+ // Unix Domain SOcket does not need addrinfo struct, so we pass nullptr
openConnection(nullptr);
}
}
diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h
index 891bfe1..6397882 100644
--- a/lib/cpp/src/thrift/transport/TTransport.h
+++ b/lib/cpp/src/thrift/transport/TTransport.h
@@ -191,7 +191,7 @@
* @oaram buf A buffer where the data can be stored if needed.
* If borrow doesn't return buf, then the contents of
* buf after the call are undefined. This parameter may be
- * NULL to indicate that the caller is not supplying storage,
+ * nullptr to indicate that the caller is not supplying storage,
* but would like a pointer into an internal buffer, if
* available.
* @param len *len should initially contain the number of bytes to borrow.
diff --git a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
index 0a0292c..ac24124 100644
--- a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
+++ b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
@@ -51,7 +51,7 @@
int thrift_gettimeofday(struct timeval * tp, struct timezone * tzp)
{
// We don't fill it in so prove nobody is looking for the data
- assert(tzp == NULL);
+ assert(tzp == nullptr);
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
diff --git a/lib/cpp/src/thrift/windows/SocketPair.cpp b/lib/cpp/src/thrift/windows/SocketPair.cpp
index 7228832..2650b37 100644
--- a/lib/cpp/src/thrift/windows/SocketPair.cpp
+++ b/lib/cpp/src/thrift/windows/SocketPair.cpp
@@ -77,12 +77,12 @@
break;
if (listen(listener, 1) == SOCKET_ERROR)
break;
- sv[0] = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, flags);
+ sv[0] = WSASocket(AF_INET, SOCK_STREAM, 0, nullptr, 0, flags);
if (sv[0] == INVALID_SOCKET)
break;
if (connect(sv[0], &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
break;
- sv[1] = accept(listener, NULL, NULL);
+ sv[1] = accept(listener, nullptr, nullptr);
if (sv[1] == INVALID_SOCKET)
break;
diff --git a/lib/cpp/src/thrift/windows/Sync.h b/lib/cpp/src/thrift/windows/Sync.h
index 5d32199..a296d7e 100644
--- a/lib/cpp/src/thrift/windows/Sync.h
+++ b/lib/cpp/src/thrift/windows/Sync.h
@@ -55,8 +55,8 @@
HANDLE h;
TAutoResetEvent() {
- h = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (h == NULL) {
+ h = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ if (h == nullptr) {
GlobalOutput.perror("TAutoResetEvent unable to create event, GLE=", GetLastError());
throw apache::thrift::concurrency::SystemResourceException("CreateEvent failed");
}
@@ -68,8 +68,8 @@
HANDLE h;
TManualResetEvent() {
- h = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (h == NULL) {
+ h = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ if (h == nullptr) {
GlobalOutput.perror("TManualResetEvent unable to create event, GLE=", GetLastError());
throw apache::thrift::concurrency::SystemResourceException("CreateEvent failed");
}
diff --git a/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp b/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
index a502cbd..c3339f3 100644
--- a/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
+++ b/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
@@ -26,7 +26,7 @@
namespace thrift {
namespace transport {
-TWinsockSingleton::instance_ptr TWinsockSingleton::instance_ptr_(NULL);
+TWinsockSingleton::instance_ptr TWinsockSingleton::instance_ptr_(nullptr);
std::once_flag TWinsockSingleton::flags_;
//------------------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/WinFcntl.cpp b/lib/cpp/src/thrift/windows/WinFcntl.cpp
index c907e92..292ddfc 100644
--- a/lib/cpp/src/thrift/windows/WinFcntl.cpp
+++ b/lib/cpp/src/thrift/windows/WinFcntl.cpp
@@ -45,8 +45,8 @@
#if WINVER <= 0x0502 // XP, Server2003
int thrift_poll(THRIFT_POLLFD* fdArray, ULONG nfds, INT timeout) {
fd_set read_fds, write_fds;
- fd_set* read_fds_ptr = NULL;
- fd_set* write_fds_ptr = NULL;
+ fd_set* read_fds_ptr = nullptr;
+ fd_set* write_fds_ptr = nullptr;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
@@ -65,7 +65,7 @@
}
timeval time_out;
- timeval* time_out_ptr = NULL;
+ timeval* time_out_ptr = nullptr;
if (timeout >= 0) {
time_out.tv_sec = timeout / 1000;
time_out.tv_usec = (timeout % 1000) * 1000;
@@ -75,7 +75,7 @@
(void)timeout;
}
- int sktready = select(1, read_fds_ptr, write_fds_ptr, NULL, time_out_ptr);
+ int sktready = select(1, read_fds_ptr, write_fds_ptr, nullptr, time_out_ptr);
if (sktready > 0) {
for (ULONG i = 0; i < nfds; i++) {
fdArray[i].revents = 0;
diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp
index a751806..935a205 100644
--- a/lib/cpp/test/OpenSSLManualInitTest.cpp
+++ b/lib/cpp/test/OpenSSLManualInitTest.cpp
@@ -88,6 +88,6 @@
suite->add(BOOST_TEST_CASE(test_openssl_availability));
- return NULL;
+ return nullptr;
}
#endif
\ No newline at end of file
diff --git a/lib/cpp/test/TFileTransportTest.cpp b/lib/cpp/test/TFileTransportTest.cpp
index 21c1f3b..c116fdc 100644
--- a/lib/cpp/test/TFileTransportTest.cpp
+++ b/lib/cpp/test/TFileTransportTest.cpp
@@ -399,6 +399,6 @@
// Parse arguments
parse_args(argc, argv);
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
index a890aa8..085197a 100644
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -230,7 +230,7 @@
HANDLE hWrite;
CoupledPipeTransports() {
- BOOST_REQUIRE(CreatePipe(&hRead, &hWrite, NULL, 1048576 * 2));
+ BOOST_REQUIRE(CreatePipe(&hRead, &hWrite, nullptr, 1048576 * 2));
in.reset(new TPipe(hRead, hWrite));
in->open();
out = in;
@@ -707,7 +707,7 @@
uint8_t read_buf[16];
memset(write_buf, 'a', sizeof(write_buf));
- // Attemping to borrow 10 bytes when only 9 are available should return NULL
+ // Attemping to borrow 10 bytes when only 9 are available should return nullptr
// immediately.
transports.out->write(write_buf, 9);
transports.out->flush();
@@ -1075,7 +1075,7 @@
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
struct timeval tv;
- THRIFT_GETTIMEOFDAY(&tv, NULL);
+ THRIFT_GETTIMEOFDAY(&tv, nullptr);
int seed = tv.tv_sec ^ tv.tv_usec;
initrand(seed);
@@ -1084,6 +1084,6 @@
suite->p_name.value = "TransportTest";
TransportTestGen transport_test_generator(suite, 1);
transport_test_generator.generate();
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index 3e2eb81..274a243 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -454,7 +454,7 @@
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
- uint32_t seed = static_cast<uint32_t>(time(NULL));
+ uint32_t seed = static_cast<uint32_t>(time(nullptr));
#ifdef HAVE_INTTYPES_H
printf("seed: %" PRIu32 "\n", seed);
#endif
@@ -470,6 +470,6 @@
suite->add(BOOST_TEST_CASE(test_no_write));
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp
index a36ef3e..017fa89 100644
--- a/lib/cpp/test/processor/ProcessorTest.cpp
+++ b/lib/cpp/test/processor/ProcessorTest.cpp
@@ -924,6 +924,6 @@
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
::boost::unit_test::framework::master_test_suite().p_name.value = "ProcessorTest";
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
index e152d08..c8bc50e 100644
--- a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
+++ b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
@@ -414,7 +414,7 @@
object_and_properties_init(return_value, ce, nullptr);
zend_function* constructor = zend_std_get_constructor(Z_OBJ_P(return_value));
zval ctor_rv;
- zend_call_method(return_value, ce, &constructor, NULL, 0, &ctor_rv, nargs, arg1, arg2);
+ zend_call_method(return_value, ce, &constructor, nullptr, 0, &ctor_rv, nargs, arg1, arg2);
zval_dtor(&ctor_rv);
if (EG(exception)) {
zend_object *ex = EG(exception);
diff --git a/lib/py/src/ext/module.cpp b/lib/py/src/ext/module.cpp
index 7158b8f..f14ddae 100644
--- a/lib/py/src/ext/module.cpp
+++ b/lib/py/src/ext/module.cpp
@@ -48,20 +48,20 @@
template <typename T>
static PyObject* encode_impl(PyObject* args) {
if (!args)
- return NULL;
+ return nullptr;
- PyObject* enc_obj = NULL;
- PyObject* type_args = NULL;
+ PyObject* enc_obj = nullptr;
+ PyObject* type_args = nullptr;
if (!PyArg_ParseTuple(args, "OO", &enc_obj, &type_args)) {
- return NULL;
+ return nullptr;
}
if (!enc_obj || !type_args) {
- return NULL;
+ return nullptr;
}
T protocol;
if (!protocol.prepareEncodeBuffer() || !protocol.encodeValue(enc_obj, T_STRUCT, type_args)) {
- return NULL;
+ return nullptr;
}
return protocol.getEncodedValue();
@@ -79,11 +79,11 @@
template <typename T>
static PyObject* decode_impl(PyObject* args) {
- PyObject* output_obj = NULL;
- PyObject* oprot = NULL;
- PyObject* typeargs = NULL;
+ PyObject* output_obj = nullptr;
+ PyObject* oprot = nullptr;
+ PyObject* typeargs = nullptr;
if (!PyArg_ParseTuple(args, "OOO", &output_obj, &oprot, &typeargs)) {
- return NULL;
+ return nullptr;
}
T protocol;
@@ -96,16 +96,16 @@
default_limit));
ScopedPyObject transport(PyObject_GetAttr(oprot, INTERN_STRING(trans)));
if (!transport) {
- return NULL;
+ return nullptr;
}
StructTypeArgs parsedargs;
if (!parse_struct_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
if (!protocol.prepareDecodeBufferFromTransport(transport.get())) {
- return NULL;
+ return nullptr;
}
return protocol.readStruct(output_obj, parsedargs.klass, parsedargs.spec);
@@ -141,22 +141,22 @@
{"decode_binary", decode_binary, METH_VARARGS, ""},
{"encode_compact", encode_compact, METH_VARARGS, ""},
{"decode_compact", decode_compact, METH_VARARGS, ""},
- {NULL, NULL, 0, NULL} /* Sentinel */
+ {nullptr, nullptr, 0, nullptr} /* Sentinel */
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef ThriftFastBinaryDef = {PyModuleDef_HEAD_INIT,
"thrift.protocol.fastbinary",
- NULL,
+ nullptr,
0,
ThriftFastBinaryMethods,
- NULL,
- NULL,
- NULL,
- NULL};
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr};
-#define INITERROR return NULL;
+#define INITERROR return nullptr;
PyObject* PyInit_fastbinary() {
@@ -167,7 +167,7 @@
void initfastbinary() {
PycString_IMPORT;
- if (PycStringIO == NULL)
+ if (PycStringIO == nullptr)
INITERROR
#endif
@@ -193,7 +193,7 @@
#else
Py_InitModule("thrift.protocol.fastbinary", ThriftFastBinaryMethods);
#endif
- if (module == NULL)
+ if (module == nullptr)
INITERROR;
#if PY_MAJOR_VERSION >= 3
diff --git a/lib/py/src/ext/protocol.h b/lib/py/src/ext/protocol.h
index 521b7ee..c0cd437 100644
--- a/lib/py/src/ext/protocol.h
+++ b/lib/py/src/ext/protocol.h
@@ -35,7 +35,7 @@
ProtocolBase()
: stringLimit_((std::numeric_limits<int32_t>::max)()),
containerLimit_((std::numeric_limits<int32_t>::max)()),
- output_(NULL) {}
+ output_(nullptr) {}
inline virtual ~ProtocolBase();
bool prepareDecodeBufferFromTransport(PyObject* trans);
diff --git a/lib/py/src/ext/protocol.tcc b/lib/py/src/ext/protocol.tcc
index ede2bb4..03cfc9b 100644
--- a/lib/py/src/ext/protocol.tcc
+++ b/lib/py/src/ext/protocol.tcc
@@ -48,7 +48,7 @@
PycString_IMPORT;
}
if (!PycStringIO) {
- return NULL;
+ return nullptr;
}
return PycStringIO->NewOutput(size);
}
@@ -83,7 +83,7 @@
PycString_IMPORT;
}
if (!PycStringIO) {
- return NULL;
+ return nullptr;
}
return PycStringIO->cgetvalue(output_);
}
@@ -277,7 +277,7 @@
} else {
// using building functions as this is a rare codepath
ScopedPyObject newiobuf(PyObject_CallFunction(input_.refill_callable.get(), refill_signature,
- *output, rlen, len, NULL));
+ *output, rlen, len, nullptr));
if (!newiobuf) {
return false;
}
@@ -332,7 +332,7 @@
template <typename Impl>
bool ProtocolBase<Impl>::prepareEncodeBuffer() {
output_ = detail::new_encode_buffer(INIT_OUTBUF_SIZE);
- return output_ != NULL;
+ return output_ != nullptr;
}
template <typename Impl>
@@ -484,8 +484,8 @@
return false;
}
Py_ssize_t pos = 0;
- PyObject* k = NULL;
- PyObject* v = NULL;
+ PyObject* k = nullptr;
+ PyObject* v = nullptr;
// TODO(bmaurer): should support any mapping, not just dicts
while (PyDict_Next(value, &pos, &k, &v)) {
if (!encodeValue(k, parsedargs.ktag, parsedargs.ktypeargs)
@@ -647,7 +647,7 @@
case T_BOOL: {
bool v = 0;
if (!impl()->readBool(v)) {
- return NULL;
+ return nullptr;
}
if (v) {
Py_RETURN_TRUE;
@@ -658,21 +658,21 @@
case T_I08: {
int8_t v = 0;
if (!impl()->readI8(v)) {
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(v);
}
case T_I16: {
int16_t v = 0;
if (!impl()->readI16(v)) {
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(v);
}
case T_I32: {
int32_t v = 0;
if (!impl()->readI32(v)) {
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(v);
}
@@ -680,7 +680,7 @@
case T_I64: {
int64_t v = 0;
if (!impl()->readI64(v)) {
- return NULL;
+ return nullptr;
}
// TODO(dreiss): Find out if we can take this fastpath always when
// sizeof(long) == sizeof(long long).
@@ -693,16 +693,16 @@
case T_DOUBLE: {
double v = 0.0;
if (!impl()->readDouble(v)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(v);
}
case T_STRING: {
- char* buf = NULL;
+ char* buf = nullptr;
int len = impl()->readString(&buf);
if (len < 0) {
- return NULL;
+ return nullptr;
}
if (isUtf8(typeargs)) {
return PyUnicode_DecodeUTF8(buf, len, 0);
@@ -715,28 +715,28 @@
case T_SET: {
SetListTypeArgs parsedargs;
if (!parse_set_list_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
TType etype = T_STOP;
int32_t len = impl()->readListBegin(etype);
if (len < 0) {
- return NULL;
+ return nullptr;
}
if (len > 0 && !checkType(etype, parsedargs.element_type)) {
- return NULL;
+ return nullptr;
}
bool use_tuple = type == T_LIST && parsedargs.immutable;
ScopedPyObject ret(use_tuple ? PyTuple_New(len) : PyList_New(len));
if (!ret) {
- return NULL;
+ return nullptr;
}
for (int i = 0; i < len; i++) {
PyObject* item = decodeValue(etype, parsedargs.typeargs);
if (!item) {
- return NULL;
+ return nullptr;
}
if (use_tuple) {
PyTuple_SET_ITEM(ret.get(), i, item);
@@ -758,32 +758,32 @@
case T_MAP: {
MapTypeArgs parsedargs;
if (!parse_map_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
TType ktype = T_STOP;
TType vtype = T_STOP;
uint32_t len = impl()->readMapBegin(ktype, vtype);
if (len > 0 && (!checkType(ktype, parsedargs.ktag) || !checkType(vtype, parsedargs.vtag))) {
- return NULL;
+ return nullptr;
}
ScopedPyObject ret(PyDict_New());
if (!ret) {
- return NULL;
+ return nullptr;
}
for (uint32_t i = 0; i < len; i++) {
ScopedPyObject k(decodeValue(ktype, parsedargs.ktypeargs));
if (!k) {
- return NULL;
+ return nullptr;
}
ScopedPyObject v(decodeValue(vtype, parsedargs.vtypeargs));
if (!v) {
- return NULL;
+ return nullptr;
}
if (PyDict_SetItem(ret.get(), k.get(), v.get()) == -1) {
- return NULL;
+ return nullptr;
}
}
@@ -792,12 +792,12 @@
ThriftModule = PyImport_ImportModule("thrift.Thrift");
}
if (!ThriftModule) {
- return NULL;
+ return nullptr;
}
ScopedPyObject cls(PyObject_GetAttr(ThriftModule, INTERN_STRING(TFrozenDict)));
if (!cls) {
- return NULL;
+ return nullptr;
}
ScopedPyObject arg(PyTuple_New(1));
@@ -811,7 +811,7 @@
case T_STRUCT: {
StructTypeArgs parsedargs;
if (!parse_struct_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
return readStruct(Py_None, parsedargs.klass, parsedargs.spec);
}
@@ -823,7 +823,7 @@
case T_U64:
default:
PyErr_Format(PyExc_TypeError, "Unexpected TType for decodeValue: %d", type);
- return NULL;
+ return nullptr;
}
}
@@ -833,26 +833,26 @@
bool immutable = output == Py_None;
ScopedPyObject kwargs;
if (spec_seq_len == -1) {
- return NULL;
+ return nullptr;
}
if (immutable) {
kwargs.reset(PyDict_New());
if (!kwargs) {
PyErr_SetString(PyExc_TypeError, "failed to prepare kwargument storage");
- return NULL;
+ return nullptr;
}
}
detail::ReadStructScope<Impl> scope = detail::readStructScope(this);
if (!scope) {
- return NULL;
+ return nullptr;
}
while (true) {
TType type = T_STOP;
int16_t tag;
if (!impl()->readFieldBegin(type, tag)) {
- return NULL;
+ return nullptr;
}
if (type == T_STOP) {
break;
@@ -860,7 +860,7 @@
if (tag < 0 || tag >= spec_seq_len) {
if (!skip(type)) {
PyErr_SetString(PyExc_TypeError, "Error while skipping unknown field");
- return NULL;
+ return nullptr;
}
continue;
}
@@ -869,38 +869,38 @@
if (item_spec == Py_None) {
if (!skip(type)) {
PyErr_SetString(PyExc_TypeError, "Error while skipping unknown field");
- return NULL;
+ return nullptr;
}
continue;
}
StructItemSpec parsedspec;
if (!parse_struct_item_spec(&parsedspec, item_spec)) {
- return NULL;
+ return nullptr;
}
if (parsedspec.type != type) {
if (!skip(type)) {
PyErr_Format(PyExc_TypeError, "struct field had wrong type: expected %d but got %d",
parsedspec.type, type);
- return NULL;
+ return nullptr;
}
continue;
}
ScopedPyObject fieldval(decodeValue(parsedspec.type, parsedspec.typeargs));
if (!fieldval) {
- return NULL;
+ return nullptr;
}
if ((immutable && PyDict_SetItem(kwargs.get(), parsedspec.attrname, fieldval.get()) == -1)
|| (!immutable && PyObject_SetAttr(output, parsedspec.attrname, fieldval.get()) == -1)) {
- return NULL;
+ return nullptr;
}
}
if (immutable) {
ScopedPyObject args(PyTuple_New(0));
if (!args) {
PyErr_SetString(PyExc_TypeError, "failed to prepare argument storage");
- return NULL;
+ return nullptr;
}
return PyObject_Call(klass, args.get(), kwargs.get());
}
diff --git a/lib/py/src/ext/types.cpp b/lib/py/src/ext/types.cpp
index 68443fb..e8d6939 100644
--- a/lib/py/src/ext/types.cpp
+++ b/lib/py/src/ext/types.cpp
@@ -24,7 +24,7 @@
namespace thrift {
namespace py {
-PyObject* ThriftModule = NULL;
+PyObject* ThriftModule = nullptr;
#if PY_MAJOR_VERSION < 3
char refill_signature[] = {'s', '#', 'i'};
diff --git a/lib/py/src/ext/types.h b/lib/py/src/ext/types.h
index 5cd8dda..9b45dd0 100644
--- a/lib/py/src/ext/types.h
+++ b/lib/py/src/ext/types.h
@@ -83,7 +83,7 @@
// replace with unique_ptr when we're OK with C++11
class ScopedPyObject {
public:
- ScopedPyObject() : obj_(NULL) {}
+ ScopedPyObject() : obj_(nullptr) {}
explicit ScopedPyObject(PyObject* py_object) : obj_(py_object) {}
~ScopedPyObject() {
if (obj_)
@@ -98,7 +98,7 @@
}
PyObject* release() throw() {
PyObject* tmp = obj_;
- obj_ = NULL;
+ obj_ = nullptr;
return tmp;
}
void swap(ScopedPyObject& other) throw() {