Replacing NULL with nullptr in core/
[ Merge of http://go/wvgerrit/84647 ] [ Merge of http://go/wvgerrit/84648 ] Replacing most instances of C's NULL with C++'s nullptr. Also changed how a NULL check is performed on smart pointers. They provided an implicit boolean operator for null checks, meaning the underlying pointer does not need to be compared directly (as it was in some places before). Note that clang-format has performed additional changes to some of the test files that have not yet been formatted. Bug: 120602075 Test: Linux and Android unittests Change-Id: I06ddebe34b0ea6dfecedb5527e7e808e32f5269a
This commit is contained in:
@@ -105,15 +105,15 @@ bool SocketWait(int fd, bool for_read, int timeout_in_ms) {
|
||||
tv.tv_sec = timeout_in_ms / 1000;
|
||||
tv.tv_usec = (timeout_in_ms % 1000) * 1000;
|
||||
|
||||
fd_set* read_fds = NULL;
|
||||
fd_set* write_fds = NULL;
|
||||
fd_set* read_fds = nullptr;
|
||||
fd_set* write_fds = nullptr;
|
||||
if (for_read) {
|
||||
read_fds = &fds;
|
||||
} else {
|
||||
write_fds = &fds;
|
||||
}
|
||||
|
||||
int ret = select(fd + 1, read_fds, write_fds, NULL, &tv);
|
||||
int ret = select(fd + 1, read_fds, write_fds, nullptr, &tv);
|
||||
if (ret == 0) {
|
||||
LOGE("socket timed out");
|
||||
return false;
|
||||
@@ -209,7 +209,7 @@ bool HttpSocket::ParseUrl(const std::string& url, std::string* scheme,
|
||||
}
|
||||
|
||||
HttpSocket::HttpSocket(const std::string& url)
|
||||
: socket_fd_(-1), ssl_(NULL), ssl_ctx_(NULL) {
|
||||
: socket_fd_(-1), ssl_(nullptr), ssl_ctx_(nullptr) {
|
||||
valid_url_ = ParseUrl(url, &scheme_, &secure_connect_, &domain_name_, &port_,
|
||||
&resource_path_);
|
||||
SSL_library_init();
|
||||
@@ -228,11 +228,11 @@ void HttpSocket::CloseSocket() {
|
||||
}
|
||||
if (ssl_) {
|
||||
SSL_free(ssl_);
|
||||
ssl_ = NULL;
|
||||
ssl_ = nullptr;
|
||||
}
|
||||
if (ssl_ctx_) {
|
||||
SSL_CTX_free(ssl_ctx_);
|
||||
ssl_ctx_ = NULL;
|
||||
ssl_ctx_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ bool HttpSocket::Connect(int timeout_in_ms) {
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
|
||||
|
||||
struct addrinfo* addr_info = NULL;
|
||||
struct addrinfo* addr_info = nullptr;
|
||||
int ret = getaddrinfo(domain_name_.c_str(), port_.c_str(), &hints,
|
||||
&addr_info);
|
||||
if (ret != 0) {
|
||||
@@ -413,7 +413,7 @@ int HttpSocket::Read(char* data, int len, int timeout_in_ms) {
|
||||
if (ssl_error == SSL_ERROR_SYSCALL) {
|
||||
LOGE(" errno = %d = %s", GetError(), GetErrorString());
|
||||
}
|
||||
ERR_print_errors_cb(LogBoringSslError, NULL);
|
||||
ERR_print_errors_cb(LogBoringSslError, nullptr);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user