Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/brpc/acceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Acceptor::Acceptor(bthread_keytable_pool_t* pool)
, _acception_id(0)
, _empty_cond(&_map_mutex)
, _force_ssl(false)
, _ssl_ctx(NULL)
, _ssl_ctx(nullptr)
, _socket_mode(SOCKET_MODE_TCP)
, _bthread_tag(BTHREAD_TAG_DEFAULT) {
}
Expand Down Expand Up @@ -120,7 +120,7 @@ void* Acceptor::CloseIdleConnections(void* arg) {
}
}
}
return NULL;
return nullptr;
}

void Acceptor::StopAccept(int /*closewait_ms*/) {
Expand Down Expand Up @@ -190,7 +190,7 @@ void Acceptor::Join() {
// Join the bthread outside lock.
if (saved_idle_timeout_sec > 0) {
bthread_stop(saved_close_idle_tid);
bthread_join(saved_close_idle_tid, NULL);
bthread_join(saved_close_idle_tid, nullptr);
}

{
Expand All @@ -207,7 +207,7 @@ size_t Acceptor::ConnectionCount() const {

void Acceptor::ListConnections(std::vector<SocketId>* conn_list,
size_t max_copied) {
if (conn_list == NULL) {
if (conn_list == nullptr) {
LOG(FATAL) << "Param[conn_list] is NULL";
return;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ void Acceptor::OnNewConnectionsUntilEAGAIN(Socket* acception) {
}

Acceptor* am = dynamic_cast<Acceptor*>(acception->user());
if (NULL == am) {
if (nullptr == am) {
LOG(FATAL) << "Impossible! acception->user() MUST be Acceptor";
acception->SetFailed(EINVAL, "Impossible! acception->user() MUST be Acceptor");
return;
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/acceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ friend class Server;
};

public:
explicit Acceptor(bthread_keytable_pool_t* pool = NULL);
explicit Acceptor(bthread_keytable_pool_t* pool = nullptr);
~Acceptor();

// [thread-safe] Accept connections from `listened_fd'. Ownership of
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/adaptive_max_concurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AdaptiveMaxConcurrency::AdaptiveMaxConcurrency(

inline bool CompareStringPieceWithoutCase(
const butil::StringPiece& s1, const char* s2) {
DCHECK(s2 != NULL);
DCHECK(s2 != nullptr);
if (std::strlen(s2) != s1.size()) {
return false;
}
Expand Down
22 changes: 11 additions & 11 deletions src/brpc/amf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,21 @@ void AMFField::SlowerClear() {
break;
case AMF_MARKER_STRICT_ARRAY:
delete _arr;
_arr = NULL;
_arr = nullptr;
break;
case AMF_MARKER_STRING:
case AMF_MARKER_LONG_STRING:
if (!_is_shortstr) {
free(_str);
_str = NULL;
_str = nullptr;
}
_strsize = 0;
_is_shortstr = false;
break;
case AMF_MARKER_OBJECT:
case AMF_MARKER_ECMA_ARRAY:
delete _obj;
_obj = NULL;
_obj = nullptr;
break;
}
_type = AMF_MARKER_UNDEFINED;
Expand All @@ -173,7 +173,7 @@ const AMFField* AMFObject::Find(const char* name) const {
if (it != _fields.end()) {
return &it->second;
}
return NULL;
return nullptr;
}

void AMFField::SetString(const butil::StringPiece& str) {
Expand Down Expand Up @@ -433,7 +433,7 @@ static bool ReadAMFObjectField(AMFInputStream* stream,
if (!CheckAMFDepth(depth)) {
return false;
}
const google::protobuf::Reflection* reflection = NULL;
const google::protobuf::Reflection* reflection = nullptr;
if (field) {
reflection = message->GetReflection();
}
Expand Down Expand Up @@ -570,7 +570,7 @@ static bool ReadAMFObjectBody(google::protobuf::Message* message,
break;
}
const google::protobuf::FieldDescriptor* field = desc->FindFieldByName(name);
RPC_VLOG_IF(field == NULL) << "Unknown field=" << desc->full_name()
RPC_VLOG_IF(field == nullptr) << "Unknown field=" << desc->full_name()
<< "." << name;
if (!ReadAMFObjectField(stream, message, field, depth)) {
return false;
Expand Down Expand Up @@ -598,7 +598,7 @@ static bool SkipAMFObjectBody(AMFInputStream* stream, int depth) {
}
break;
}
if (!ReadAMFObjectField(stream, NULL, NULL, depth)) {
if (!ReadAMFObjectField(stream, nullptr, nullptr, depth)) {
return false;
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ static bool ReadAMFEcmaArrayBody(google::protobuf::Message* message,
return false;
}
const google::protobuf::FieldDescriptor* field = desc->FindFieldByName(name);
RPC_VLOG_IF(field == NULL) << "Unknown field=" << desc->full_name()
RPC_VLOG_IF(field == nullptr) << "Unknown field=" << desc->full_name()
<< "." << name;
if (!ReadAMFObjectField(stream, message, field, depth)) {
return false;
Expand All @@ -651,7 +651,7 @@ bool ReadAMFObject(google::protobuf::Message* msg, AMFInputStream* stream) {
return false;
}
} else if ((AMFMarker)marker != AMF_MARKER_NULL) {
// Notice that NULL is treated as an object w/o any fields.
// Notice that nullptr is treated as an object w/o any fields.
LOG(ERROR) << "Expected object/null, actually " << marker2str(marker);
return false;
}
Expand Down Expand Up @@ -826,7 +826,7 @@ bool ReadAMFObject(AMFObject* obj, AMFInputStream* stream) {
return false;
}
} else if ((AMFMarker)marker != AMF_MARKER_NULL) {
// NOTE: NULL is treated as an object w/o any fields.
// NOTE: nullptr is treated as an object w/o any fields.
LOG(ERROR) << "Expected object/null, actually " << marker2str(marker);
return false;
}
Expand Down Expand Up @@ -952,7 +952,7 @@ bool ReadAMFArray(AMFArray* arr, AMFInputStream* stream) {
return false;
}
} else if ((AMFMarker)marker != AMF_MARKER_NULL) {
// NOTE: NULL is treated as an array w/o any items.
// NOTE: nullptr is treated as an array w/o any items.
LOG(ERROR) << "Expected array/null, actually " << marker2str(marker);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/amf.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AMFInputStream {
AMFInputStream(google::protobuf::io::ZeroCopyInputStream* stream)
: _good(true)
, _size(0)
, _data(NULL)
, _data(nullptr)
, _zc_stream(stream)
, _popped_bytes(0)
{}
Expand Down Expand Up @@ -81,7 +81,7 @@ class AMFOutputStream {
AMFOutputStream(google::protobuf::io::ZeroCopyOutputStream* stream)
: _good(true)
, _size(0)
, _data(NULL)
, _data(nullptr)
, _zc_stream(stream)
, _pushed_bytes(0)
{}
Expand Down
6 changes: 3 additions & 3 deletions src/brpc/amf_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline size_t AMFInputStream::cutn(void* out, size_t n) {
n -= _size;
}
} while (_zc_stream->Next(&_data, &_size));
_data = NULL;
_data = nullptr;
_size = 0;
_popped_bytes += saved_n - n;
return saved_n - n;
Expand Down Expand Up @@ -127,7 +127,7 @@ inline void AMFOutputStream::putn(const void* data, int n) {
data = (const char*)data + _size;
n -= _size;
} while (_zc_stream->Next(&_data, &_size));
_data = NULL;
_data = nullptr;
_size = 0;
_pushed_bytes += (saved_n - n);
if (n) {
Expand All @@ -145,7 +145,7 @@ inline void AMFOutputStream::put_u8(uint8_t val) {
return;
}
} while (_zc_stream->Next(&_data, &_size));
_data = NULL;
_data = nullptr;
_size = 0;
set_bad();
}
Expand Down
10 changes: 5 additions & 5 deletions src/brpc/backup_request_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,30 +144,30 @@ BackupRequestPolicy* CreateRateLimitedBackupPolicy(
if (options.backup_request_ms < -1) {
LOG(ERROR) << "Invalid backup_request_ms=" << options.backup_request_ms
<< ", must be >= -1 (-1 means inherit from ChannelOptions)";
return NULL;
return nullptr;
}
if (options.max_backup_ratio <= 0 || options.max_backup_ratio > 1.0) {
LOG(ERROR) << "Invalid max_backup_ratio=" << options.max_backup_ratio
<< ", must be in (0, 1]";
return NULL;
return nullptr;
}
if (options.window_size_seconds < 1 || options.window_size_seconds > 3600) {
LOG(ERROR) << "Invalid window_size_seconds=" << options.window_size_seconds
<< ", must be in [1, 3600]";
return NULL;
return nullptr;
}
if (options.update_interval_seconds < 1) {
LOG(ERROR) << "Invalid update_interval_seconds="
<< options.update_interval_seconds << ", must be >= 1";
return NULL;
return nullptr;
}
if (options.update_interval_seconds > options.window_size_seconds) {
LOG(WARNING) << "update_interval_seconds=" << options.update_interval_seconds
<< " exceeds window_size_seconds=" << options.window_size_seconds
<< "; the ratio window will rarely refresh within its own period";
}
// Plain new (without std::nothrow): brpc follows the project-wide convention
// of letting OOM throw/abort rather than returning NULL. NULL return from
// of letting OOM throw/abort rather than returning nullptr. nullptr return from
// this factory already signals invalid parameters, not allocation failure.
return new RateLimitedBackupPolicy(
options.backup_request_ms, options.max_backup_ratio,
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/backup_request_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct RateLimitedBackupPolicyOptions {
// NOTE: Backup decisions are counted immediately at DoBackup() time for
// fast feedback. Total RPCs are counted on completion (OnRPCEnd). During
// latency spikes the ratio may temporarily lag until RPCs complete.
// Returns NULL on invalid parameters.
// Returns nullptr on invalid parameters.
// The caller owns the returned pointer.
BackupRequestPolicy* CreateRateLimitedBackupPolicy(
const RateLimitedBackupPolicyOptions& options);
Expand Down
10 changes: 3 additions & 7 deletions src/brpc/baidu_master_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
namespace brpc {

BaiduMasterService::BaiduMasterService()
: _status(new (std::nothrow) MethodStatus), _ignore_eovercrowded(false) {
LOG_IF(FATAL, NULL == _status) << "Fail to new MethodStatus";
}
: _status(new MethodStatus)
, _ignore_eovercrowded(false) {}

BaiduMasterService::~BaiduMasterService() {
delete _status;
_status = NULL;
_status = nullptr;
}

void BaiduMasterService::Describe(std::ostream &os,
Expand All @@ -37,9 +36,6 @@ void BaiduMasterService::Describe(std::ostream &os,
}

void BaiduMasterService::Expose(const butil::StringPiece& prefix) {
if (NULL == _status) {
return;
}
std::string s;
const std::string& cached_name = butil::class_name_str(*this);
s.reserve(prefix.size() + 1 + cached_name.size());
Expand Down
Loading
Loading