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
4 changes: 2 additions & 2 deletions src/brpc/builtin/bad_method_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void BadMethodService::no_method(::google::protobuf::RpcController* cntl_base,
os << "Missing method name for service=" << request->service_name() << '.';
const Server::ServiceProperty* sp = ServerPrivateAccessor(server)
.FindServicePropertyAdaptively(request->service_name());
if (sp != NULL && sp->service != NULL) {
if (sp != nullptr && sp->service != nullptr) {
const google::protobuf::ServiceDescriptor* sd =
sp->service->GetDescriptor();
os << " Available methods are: " << newline << newline;
Expand All @@ -58,7 +58,7 @@ void BadMethodService::no_method(::google::protobuf::RpcController* cntl_base,
<< ");" << newline;
}
}
if (sp != NULL && sp->restful_map != NULL) {
if (sp != nullptr && sp->restful_map != nullptr) {
os << " This path is associated with a RestfulMap!";
}
cntl->SetFailed(ENOMETHOD, "%s", os.str().c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/builtin/bthreads_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ void BthreadsService::default_method(::google::protobuf::RpcController* cntl_bas
bool enable_trace = false;
#ifdef BRPC_BTHREAD_TRACER
const std::string* st = cntl->http_request().uri().GetQuery("st");
if (NULL != st && *st == "1") {
if (nullptr != st && *st == "1") {
enable_trace = true;
}
#endif // BRPC_BTHREAD_TRACER
char* endptr = NULL;
char* endptr = nullptr;
bthread_t tid = strtoull(constraint.c_str(), &endptr, 10);
if (*endptr == '\0' || *endptr == '/' || *endptr == '?') {
::bthread::print_task(os, tid, enable_trace);
Expand Down
10 changes: 5 additions & 5 deletions src/brpc/builtin/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ DEFINE_string(rpc_profiling_dir, "./rpc_data/profiling",

bool UseHTML(const HttpHeader& header) {
const std::string* console = header.uri().GetQuery(CONSOLE_STR);
if (console != NULL) {
if (console != nullptr) {
return atoi(console->c_str()) == 0;
}
// [curl header]
// User-Agent: curl/7.12.1 (x86_64-redhat-linux-gnu) libcurl/7.12.1 ...
const std::string* agent = header.GetHeader(USER_AGENT_STR);
if (agent == NULL) { // use text when user-agent is absent
if (agent == nullptr) { // use text when user-agent is absent
return false;
}
return agent->find("curl/") == std::string::npos;
Expand All @@ -50,8 +50,8 @@ bool UseHTML(const HttpHeader& header) {
// Written by Jack Handy
// <A href="mailto:jakkhandy@hotmail.com">jakkhandy@hotmail.com</A>
inline bool url_wildcmp(const char* wild, const char* str) {
const char* cp = NULL;
const char* mp = NULL;
const char* cp = nullptr;
const char* mp = nullptr;

while (*str && *wild != '*') {
if (*wild != *str && *wild != '$') {
Expand Down Expand Up @@ -384,7 +384,7 @@ const char* GetProgramChecksum() {
bool SupportGzip(Controller* cntl) {
const std::string* encodings =
cntl->http_request().GetHeader("Accept-Encoding");
if (encodings == NULL) {
if (encodings == nullptr) {
return false;
}
return encodings->find("gzip") != std::string::npos;
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/builtin/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::ostream& operator<<(std::ostream& os, const PrintedAsDateTime&);
struct Path {
static const butil::EndPoint *LOCAL;
Path(const char* uri2, const butil::EndPoint* html_addr2)
: uri(uri2), html_addr(html_addr2), text(NULL) {}
: uri(uri2), html_addr(html_addr2), text(nullptr) {}

Path(const char* uri2, const butil::EndPoint* html_addr2, const char* text2)
: uri(uri2), html_addr(html_addr2), text(text2) {}
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/builtin/connections_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void ConnectionsService::PrintConnections(
// Special treatment for nshead services. Notice that
// pref_index is comparable to ProtocolType after r31951
if (pref_index == (int)PROTOCOL_NSHEAD &&
server->options().nshead_service != NULL) {
server->options().nshead_service != nullptr) {
if (nshead_service_name.empty()) {
nshead_service_name = BriefName(butil::class_name_str(
*server->options().nshead_service));
Expand All @@ -244,7 +244,7 @@ void ConnectionsService::PrintConnections(
ptr->GetStat(&stat);
PrintRealDateTime(os, ptr->_reset_fd_real_us);
int rttfd = ptr->fd();
if (rttfd < 0 && first_sub != NULL) {
if (rttfd < 0 && first_sub != nullptr) {
rttfd = first_sub->fd();
}

Expand Down
8 changes: 4 additions & 4 deletions src/brpc/builtin/dir_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void DirService::default_method(::google::protobuf::RpcController* cntl_base,
open_path = "/";
}
DIR* dir = opendir(open_path.c_str());
if (NULL == dir) {
if (nullptr == dir) {
butil::fd_guard fd(open(open_path.c_str(), O_RDONLY));
if (fd < 0) {
cntl->SetFailed(errno, "Cannot open `%s'", open_path.c_str());
Expand Down Expand Up @@ -81,7 +81,7 @@ void DirService::default_method(::google::protobuf::RpcController* cntl_base,
cntl->http_response().set_content_type("text/plain");
} else {
const bool use_html = UseHTML(cntl->http_request());
const butil::EndPoint* const html_addr = (use_html ? Path::LOCAL : NULL);
const butil::EndPoint* const html_addr = (use_html ? Path::LOCAL : nullptr);
cntl->http_response().set_content_type(
use_html ? "text/html" : "text/plain");

Expand All @@ -90,10 +90,10 @@ void DirService::default_method(::google::protobuf::RpcController* cntl_base,
// readdir_r is marked as deprecated since glibc 2.24.
#if defined(__GLIBC__) && \
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 24))
for (struct dirent* p = NULL; (p = readdir(dir)) != NULL; ) {
for (struct dirent* p = nullptr; (p = readdir(dir)) != nullptr; ) {
#else
struct dirent entbuf;
for (struct dirent* p = NULL; readdir_r(dir, &entbuf, &p) == 0 && p; ) {
for (struct dirent* p = nullptr; readdir_r(dir, &entbuf, &p) == 0 && p; ) {
#endif
files.push_back(p->d_name);
}
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/builtin/flags_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void FlagsService::default_method(::google::protobuf::RpcController* cntl_base,
cntl->http_response().set_content_type(
use_html ? "text/html" : "text/plain");

if (value_str != NULL) {
if (value_str != nullptr) {
// reload value if ?setvalue=VALUE is present.
if (constraint.empty()) {
cntl->SetFailed(ENOMETHOD, "Require gflag name");
Expand Down Expand Up @@ -189,7 +189,7 @@ void FlagsService::default_method(::google::protobuf::RpcController* cntl_base,
std::vector<std::string> wildcards;
std::set<std::string> exact;
if (!constraint.empty()) {
for (butil::StringMultiSplitter sp(constraint.c_str(), ",;"); sp != NULL; ++sp) {
for (butil::StringMultiSplitter sp(constraint.c_str(), ",;"); sp != nullptr; ++sp) {
std::string name(sp.field(), sp.length());
if (name.find_first_of("$*") != std::string::npos) {
wildcards.push_back(name);
Expand Down
6 changes: 3 additions & 3 deletions src/brpc/builtin/flot_min_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
namespace brpc {

static pthread_once_t s_flot_min_buf_once = PTHREAD_ONCE_INIT;
static butil::IOBuf* s_flot_min_buf = NULL;
static butil::IOBuf* s_flot_min_buf_gzip = NULL;
static butil::IOBuf* s_flot_min_buf = nullptr;
static butil::IOBuf* s_flot_min_buf_gzip = nullptr;
static void InitFlotMinBuf() {
s_flot_min_buf = new butil::IOBuf;
s_flot_min_buf->append(flot_min_js());
s_flot_min_buf_gzip = new butil::IOBuf;
CHECK(policy::GzipCompress(*s_flot_min_buf, s_flot_min_buf_gzip, NULL));
CHECK(policy::GzipCompress(*s_flot_min_buf, s_flot_min_buf_gzip, nullptr));
}
const butil::IOBuf& flot_min_js_iobuf() {
pthread_once(&s_flot_min_buf_once, InitFlotMinBuf);
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/builtin/get_favicon_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static unsigned char s_favicon_array[] = {
};

static pthread_once_t s_favicon_buf_once = PTHREAD_ONCE_INIT;
static butil::IOBuf* s_favicon_buf = NULL;
static butil::IOBuf* s_favicon_buf = nullptr;
static void InitFavIcon() {
s_favicon_buf = new butil::IOBuf;
s_favicon_buf->append((const void *)s_favicon_array,
Expand Down
6 changes: 3 additions & 3 deletions src/brpc/builtin/get_js_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void GetJsService::jquery_min(

const std::string* ims =
cntl->http_request().GetHeader("If-Modified-Since");
if (ims != NULL && *ims == g_last_modified) {
if (ims != nullptr && *ims == g_last_modified) {
cntl->http_response().set_status_code(HTTP_STATUS_NOT_MODIFIED);
return;
}
Expand All @@ -89,7 +89,7 @@ void GetJsService::flot_min(

const std::string* ims =
cntl->http_request().GetHeader("If-Modified-Since");
if (ims != NULL && *ims == g_last_modified) {
if (ims != nullptr && *ims == g_last_modified) {
cntl->http_response().set_status_code(HTTP_STATUS_NOT_MODIFIED);
return;
}
Expand All @@ -115,7 +115,7 @@ void GetJsService::viz_min(

const std::string* ims =
cntl->http_request().GetHeader("If-Modified-Since");
if (ims != NULL && *ims == g_last_modified) {
if (ims != nullptr && *ims == g_last_modified) {
cntl->http_response().set_status_code(HTTP_STATUS_NOT_MODIFIED);
return;
}
Expand Down
Loading
Loading