diff --git a/example/asynchronous_echo_c++/client.cpp b/example/asynchronous_echo_c++/client.cpp index b52297b4b5..1fff48a33d 100644 --- a/example/asynchronous_echo_c++/client.cpp +++ b/example/asynchronous_echo_c++/client.cpp @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) { // Send a request and wait for the response every 1 second. int log_id = 0; while (!brpc::IsAskedToQuit()) { - // Since we are sending asynchronous RPC (`done' is not NULL), + // Since we are sending asynchronous RPC (`done' is not nullptr), // these objects MUST remain valid until `done' is called. // As a result, we allocate these objects on heap example::EchoResponse* response = new example::EchoResponse(); diff --git a/example/asynchronous_echo_c++/server.cpp b/example/asynchronous_echo_c++/server.cpp index dcce19a80b..8c6921b298 100644 --- a/example/asynchronous_echo_c++/server.cpp +++ b/example/asynchronous_echo_c++/server.cpp @@ -78,8 +78,8 @@ class EchoServiceImpl : public example::EchoService { // at this time res is already sent to client, but cntl/req/res is not destructed std::string req_str; std::string res_str; - json2pb::ProtoMessageToJson(*req, &req_str, NULL); - json2pb::ProtoMessageToJson(*res, &res_str, NULL); + json2pb::ProtoMessageToJson(*req, &req_str, nullptr); + json2pb::ProtoMessageToJson(*res, &res_str, nullptr); LOG(INFO) << "req:" << req_str << " res:" << res_str; } diff --git a/example/auto_concurrency_limiter/client.cpp b/example/auto_concurrency_limiter/client.cpp index af293af9ad..6b0bce6e5a 100644 --- a/example/auto_concurrency_limiter/client.cpp +++ b/example/auto_concurrency_limiter/client.cpp @@ -186,7 +186,7 @@ void RunCase(test::ControlService_Stub &cntl_stub, test::NotifyResponse cntl_rsp; brpc::Controller cntl; cntl_req.set_message("StartCase"); - cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, NULL); + cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, nullptr); CHECK(!cntl.Failed()) << "control failed"; TestCaseContext context(test_case); @@ -208,7 +208,7 @@ void RunCase(test::ControlService_Stub &cntl_stub, ::sleep(FLAGS_case_interval); cntl.Reset(); cntl_req.set_message("StopCase"); - cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, NULL); + cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, nullptr); CHECK(!cntl.Failed()) << "control failed"; LOG(INFO) << "Case `" << test_case.case_name() << "' finshed:"; } @@ -237,7 +237,7 @@ int main(int argc, char* argv[]) { test::NotifyRequest cntl_req; test::NotifyResponse cntl_rsp; cntl_req.set_message("ResetCaseSet"); - cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, NULL); + cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, nullptr); CHECK(!cntl.Failed()) << "Cntl Failed"; for (int i = 0; i < case_set.test_case_size(); ++i) { RunCase(cntl_stub, case_set.test_case(i)); diff --git a/example/auto_concurrency_limiter/server.cpp b/example/auto_concurrency_limiter/server.cpp index a161b188ed..06d1e47498 100644 --- a/example/auto_concurrency_limiter/server.cpp +++ b/example/auto_concurrency_limiter/server.cpp @@ -197,7 +197,7 @@ class ControlServiceImpl : public test::ControlService { brpc::SERVER_OWNS_SERVICE) != 0) { LOG(FATAL) << "Fail to add service"; } - g_timer_thread.start(NULL); + g_timer_thread.start(nullptr); } virtual ~ControlServiceImpl() { _echo_service->StopTestCase(); @@ -284,7 +284,7 @@ int main(int argc, char* argv[]) { return -1; } - if (server.Start(FLAGS_cntl_port, NULL) != 0) { + if (server.Start(FLAGS_cntl_port, nullptr) != 0) { LOG(ERROR) << "Fail to start EchoServer"; return -1; } diff --git a/example/backup_request_c++/client.cpp b/example/backup_request_c++/client.cpp index 07005e3770..f14a6992c1 100644 --- a/example/backup_request_c++/client.cpp +++ b/example/backup_request_c++/client.cpp @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -68,9 +68,9 @@ int main(int argc, char* argv[]) { request.set_index(++counter); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { LOG(INFO) << "Received response[index=" << response.index() << "] from " << cntl.remote_side() diff --git a/example/baidu_proxy_and_generic_call/client.cpp b/example/baidu_proxy_and_generic_call/client.cpp index b8fd3101bb..3ec262d3df 100644 --- a/example/baidu_proxy_and_generic_call/client.cpp +++ b/example/baidu_proxy_and_generic_call/client.cpp @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_BAIDU_STD; options.connection_type = FLAGS_connection_type; @@ -73,9 +73,9 @@ int main(int argc, char* argv[]) { // being serialized into protobuf messages. cntl.request_attachment().append(FLAGS_attachment); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { LOG(INFO) << "Received response from " << cntl.remote_side() << " to " << cntl.local_side() diff --git a/example/baidu_proxy_and_generic_call/proxy.cpp b/example/baidu_proxy_and_generic_call/proxy.cpp index a7f24fbcc5..f6866532b1 100644 --- a/example/baidu_proxy_and_generic_call/proxy.cpp +++ b/example/baidu_proxy_and_generic_call/proxy.cpp @@ -55,7 +55,7 @@ class BaiduMasterServiceImpl : public brpc::BaiduMasterService { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_BAIDU_STD; options.connection_type = FLAGS_connection_type; @@ -84,7 +84,7 @@ class BaiduMasterServiceImpl : public brpc::BaiduMasterService { call_cntl.set_request_compress_type(cntl->request_compress_type()); call_cntl.reset_sampled_request(cntl->release_sampled_request()); // It is ok to use request and response for sync rpc. - channel.CallMethod(NULL, &call_cntl, request, response, NULL); + channel.CallMethod(nullptr, &call_cntl, request, response, nullptr); (*cntl->response_user_fields())["x-bd-proxy-error-code"] = butil::IntToString(call_cntl.ErrorCode()); if (call_cntl.Failed()) { diff --git a/example/bthread_tag_echo_c++/client.cpp b/example/bthread_tag_echo_c++/client.cpp index 2b5a9e0bb5..24310a9c40 100644 --- a/example/bthread_tag_echo_c++/client.cpp +++ b/example/bthread_tag_echo_c++/client.cpp @@ -63,9 +63,9 @@ static void* sender(void* arg) { // being serialized into protobuf messages. cntl.request_attachment().append(g_attachment); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); } else { @@ -79,7 +79,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -90,7 +90,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -144,9 +144,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/cancel_c++/client.cpp b/example/cancel_c++/client.cpp index dd23b679e9..dd37bb56d8 100644 --- a/example/cancel_c++/client.cpp +++ b/example/cancel_c++/client.cpp @@ -51,7 +51,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; diff --git a/example/cascade_echo_c++/client.cpp b/example/cascade_echo_c++/client.cpp index 25a1b52fa7..b2aa665e2a 100644 --- a/example/cascade_echo_c++/client.cpp +++ b/example/cascade_echo_c++/client.cpp @@ -70,9 +70,9 @@ void* sender(void* arg) { // being serialized into protobuf messages. cntl.request_attachment().append(FLAGS_attachment); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (cntl.Failed()) { //LOG_EVERY_SECOND(WARNING) << "Fail to send EchoRequest, " << cntl.ErrorText(); } else { @@ -82,7 +82,7 @@ void* sender(void* arg) { bthread_usleep(FLAGS_sleep_ms * 1000L); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) { options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; options.max_retry = FLAGS_max_retry; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. // options, see `brpc/channel.h'. if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) { LOG(ERROR) << "Fail to initialize channel"; @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -140,9 +140,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } return 0; diff --git a/example/cascade_echo_c++/server.cpp b/example/cascade_echo_c++/server.cpp index c329073c56..8aaa7e622e 100644 --- a/example/cascade_echo_c++/server.cpp +++ b/example/cascade_echo_c++/server.cpp @@ -62,7 +62,7 @@ class CascadeEchoService : public EchoService { cntl2.set_timeout_ms(FLAGS_timeout_ms); cntl2.set_max_retry(FLAGS_max_retry); - stub.Echo(&cntl2, &request2, &response2, NULL); + stub.Echo(&cntl2, &request2, &response2, nullptr); if (cntl2.Failed()) { CLOGE(&cntl2) << "Fail to send EchoRequest, " << cntl2.ErrorText(); cntl->SetFailed(cntl2.ErrorCode(), "%s", cntl2.ErrorText().c_str()); @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) { coption.protocol = brpc::PROTOCOL_HTTP; } - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. // options, see `brpc/channel.h'. if (FLAGS_server.empty()) { if (channel.Init("localhost", FLAGS_port, &coption) != 0) { diff --git a/example/coroutine/coroutine_server.cpp b/example/coroutine/coroutine_server.cpp index 51ef7fcba0..f3f1040f86 100644 --- a/example/coroutine/coroutine_server.cpp +++ b/example/coroutine/coroutine_server.cpp @@ -81,7 +81,7 @@ class EchoServiceImpl : public EchoService { brpc::ClosureGuard done_guard(done); EchoService_Stub stub(&_channel); brpc::Controller cntl; - stub.Echo(&cntl, request, response, NULL); + stub.Echo(&cntl, request, response, nullptr); if (cntl.Failed()) { response->set_message(cntl.ErrorText()); } diff --git a/example/couchbase_c++/multithreaded_couchbase_client.cpp b/example/couchbase_c++/multithreaded_couchbase_client.cpp index d6dd9e56be..43879629cc 100644 --- a/example/couchbase_c++/multithreaded_couchbase_client.cpp +++ b/example/couchbase_c++/multithreaded_couchbase_client.cpp @@ -186,7 +186,7 @@ void* thread_worker(void* arg) { if (!auth_result.success) { std::cout << RED << "Thread " << args->thread_id << ": Auth failed - " << auth_result.error_message << RESET << std::endl; - return NULL; + return nullptr; } // // Select bucket @@ -197,7 +197,7 @@ void* thread_worker(void* arg) { // std::cout << RED << "Thread " << args->thread_id // << ": Bucket selection failed - " << bucket_result.error_message // << RESET << std::endl; - // return NULL; + // return nullptr; // } std::cout << GREEN << "Thread " << args->thread_id << " connected to bucket " @@ -228,7 +228,7 @@ void* thread_worker(void* arg) { << " operations successful, " << failed << " failed" << RESET << std::endl; - return NULL; + return nullptr; } void* shared_object_thread_worker(void *arg){ @@ -246,7 +246,7 @@ void* shared_object_thread_worker(void *arg){ // Small delay between operations bthread_usleep(10000); // 10ms } - return NULL; + return nullptr; } // Print simple statistics @@ -319,7 +319,7 @@ int main(int argc, char* argv[]) { // Start all threads for (int i = 0; i < NUM_THREADS; ++i) { - if (bthread_start_background(&threads[i], NULL, thread_worker, &args[i]) != + if (bthread_start_background(&threads[i], nullptr, thread_worker, &args[i]) != 0) { std::cout << RED << "Failed to create thread " << i << RESET << std::endl; return -1; @@ -332,7 +332,7 @@ int main(int argc, char* argv[]) { std::cout << YELLOW << "Waiting for all threads to complete..." << RESET << std::endl; for (int i = 0; i < NUM_THREADS; ++i) { - bthread_join(threads[i], NULL); + bthread_join(threads[i], nullptr); } std::cout << GREEN << "All threads completed!" << RESET << std::endl; @@ -357,14 +357,14 @@ int main(int argc, char* argv[]) { } for(int i = 0; i < NUM_THREADS; ++i){ - if (bthread_start_background(&threads[i], NULL, shared_object_thread_worker, &args[i]) != + if (bthread_start_background(&threads[i], nullptr, shared_object_thread_worker, &args[i]) != 0) { std::cout << RED << "Failed to create shared object thread " << i << RESET << std::endl; return -1; } } for(int i = 0; i < NUM_THREADS; ++i){ - bthread_join(threads[i], NULL); + bthread_join(threads[i], nullptr); } std::cout << GREEN << "All shared object threads completed!" << RESET << std::endl; diff --git a/example/couchbase_c++/traditional_brpc_couchbase_client.cpp b/example/couchbase_c++/traditional_brpc_couchbase_client.cpp index c63c98cd4f..0e2bb6b667 100644 --- a/example/couchbase_c++/traditional_brpc_couchbase_client.cpp +++ b/example/couchbase_c++/traditional_brpc_couchbase_client.cpp @@ -42,7 +42,7 @@ int main() { brpc::CouchbaseOperations::CouchbaseResponse res; uint64_t cas; req.authenticateRequest("Administrator", "password"); - channel.CallMethod(NULL, &cntl, &req, &res, NULL); + channel.CallMethod(nullptr, &cntl, &req, &res, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Unable to authenticate: Something went wrong" << cntl.ErrorText(); @@ -63,7 +63,7 @@ int main() { req.Clear(); res.Clear(); req.selectBucketRequest("testing"); - channel.CallMethod(NULL, &cntl, &req, &res, NULL); + channel.CallMethod(nullptr, &cntl, &req, &res, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Unable to select bucket: Something went wrong" << cntl.ErrorText(); @@ -92,7 +92,7 @@ int main() { "sample_key", R"({"name": "John Doe", "age": 30, "email": "john@example.com"})", 0 /*flags*/, 0 /*exptime*/, 0 /*cas*/); - channel.CallMethod(NULL, &cntl, &req, &res, NULL); + channel.CallMethod(nullptr, &cntl, &req, &res, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Unable to add key-value: Something went wrong" << cntl.ErrorText(); @@ -118,7 +118,7 @@ int main() { req.Clear(); res.Clear(); req.getRequest("sample_key"); - channel.CallMethod(NULL, &cntl, &req, &res, NULL); + channel.CallMethod(nullptr, &cntl, &req, &res, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Unable to get value for key: Something went wrong" << cntl.ErrorText(); @@ -147,7 +147,7 @@ int main() { req.Clear(); res.Clear(); req.deleteRequest("sample_key"); - channel.CallMethod(NULL, &cntl, &req, &res, NULL); + channel.CallMethod(nullptr, &cntl, &req, &res, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Unable to delete key-value: Something went wrong" << cntl.ErrorText(); diff --git a/example/dynamic_partition_echo_c++/client.cpp b/example/dynamic_partition_echo_c++/client.cpp index fd25514ccd..e370a53480 100644 --- a/example/dynamic_partition_echo_c++/client.cpp +++ b/example/dynamic_partition_echo_c++/client.cpp @@ -53,7 +53,7 @@ static void* sender(void* arg) { // a stub Service wrapping it. stub can be shared by all threads as well. example::EchoService_Stub stub(static_cast(arg)); - SenderInfo* info = NULL; + SenderInfo* info = nullptr; { BAIDU_SCOPED_LOCK(g_latency_mutex); g_sender_info.push_back(SenderInfo()); @@ -76,9 +76,9 @@ static void* sender(void* arg) { cntl.request_attachment().append(g_attachment); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { info->latency_sum += cntl.latency_us(); ++info->nsuccess; @@ -92,7 +92,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } class MyPartitionParser : public brpc::PartitionParser { @@ -104,7 +104,7 @@ class MyPartitionParser : public brpc::PartitionParser { LOG(ERROR) << "Invalid tag=" << tag; return false; } - char* endptr = NULL; + char* endptr = nullptr; out->index = strtol(tag.c_str(), &endptr, 10); if (endptr != tag.data() + pos) { LOG(ERROR) << "Invalid index=" << butil::StringPiece(tag.data(), pos); @@ -156,7 +156,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -165,7 +165,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -203,9 +203,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/dynamic_partition_echo_c++/server.cpp b/example/dynamic_partition_echo_c++/server.cpp index eda57b4243..4cf5e923c3 100644 --- a/example/dynamic_partition_echo_c++/server.cpp +++ b/example/dynamic_partition_echo_c++/server.cpp @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) { butil::StringSplitter sp(FLAGS_sleep_us.c_str(), ','); std::vector sleep_list; for (; sp; ++sp) { - sleep_list.push_back(strtoll(sp.field(), NULL, 10)); + sleep_list.push_back(strtoll(sp.field(), nullptr, 10)); } if (sleep_list.empty()) { sleep_list.push_back(0); diff --git a/example/echo_c++/client.cpp b/example/echo_c++/client.cpp index 4a3aee9c88..1c05523e09 100644 --- a/example/echo_c++/client.cpp +++ b/example/echo_c++/client.cpp @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -77,9 +77,9 @@ int main(int argc, char* argv[]) { cntl.set_request_checksum_type(brpc::CHECKSUM_TYPE_CRC32C); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { LOG(INFO) << "Received response from " << cntl.remote_side() << " to " << cntl.local_side() diff --git a/example/echo_c++/server.cpp b/example/echo_c++/server.cpp index 4113114629..f27b519f04 100644 --- a/example/echo_c++/server.cpp +++ b/example/echo_c++/server.cpp @@ -90,8 +90,8 @@ class EchoServiceImpl : public EchoService { // at this time res is already sent to client, but cntl/req/res is not destructed std::string req_str; std::string res_str; - json2pb::ProtoMessageToJson(*req, &req_str, NULL); - json2pb::ProtoMessageToJson(*res, &res_str, NULL); + json2pb::ProtoMessageToJson(*req, &req_str, nullptr); + json2pb::ProtoMessageToJson(*res, &res_str, nullptr); LOG(INFO) << "req:" << req_str << " res:" << res_str; } diff --git a/example/grpc_c++/client.cpp b/example/grpc_c++/client.cpp index 4318ed885e..b92299ce81 100644 --- a/example/grpc_c++/client.cpp +++ b/example/grpc_c++/client.cpp @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; @@ -68,9 +68,9 @@ int main(int argc, char* argv[]) { if (FLAGS_gzip) { cntl.set_request_compress_type(brpc::COMPRESS_TYPE_GZIP); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.SayHello(&cntl, &request, &response, NULL); + stub.SayHello(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { LOG(INFO) << "Received response from " << cntl.remote_side() << " to " << cntl.local_side() diff --git a/example/http_c++/benchmark_http.cpp b/example/http_c++/benchmark_http.cpp index 7fc879d190..13ba74e5eb 100644 --- a/example/http_c++/benchmark_http.cpp +++ b/example/http_c++/benchmark_http.cpp @@ -54,9 +54,9 @@ static void* sender(void* arg) { cntl.request_attachment().append(FLAGS_data); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - channel->CallMethod(NULL, &cntl, NULL, NULL, NULL); + channel->CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); } else { @@ -69,7 +69,7 @@ static void* sender(void* arg) { bthread_usleep(100000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. // options, see `brpc/channel.h'. if (channel.Init(FLAGS_url.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) { LOG(ERROR) << "Fail to initialize channel"; @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -125,9 +125,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "benchmark_http is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/http_c++/http_client.cpp b/example/http_c++/http_client.cpp index 23222dee9b..5c2c94b4a9 100644 --- a/example/http_c++/http_client.cpp +++ b/example/http_c++/http_client.cpp @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; options.max_retry = FLAGS_max_retry; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. // options, see `brpc/channel.h'. if (channel.Init(url, FLAGS_load_balancer.c_str(), &options) != 0) { LOG(ERROR) << "Fail to initialize channel"; @@ -71,9 +71,9 @@ int main(int argc, char* argv[]) { cntl.request_attachment().append(FLAGS_d); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr); if (cntl.Failed()) { std::cerr << cntl.ErrorText() << std::endl; return -1; diff --git a/example/http_c++/http_server.cpp b/example/http_c++/http_server.cpp index 05c9a0ee4c..9f905dbb84 100644 --- a/example/http_c++/http_server.cpp +++ b/example/http_c++/http_server.cpp @@ -74,8 +74,8 @@ class HttpServiceImpl : public HttpService { // at this time res is already sent to client, but cntl/req/res is not destructed std::string req_str; std::string res_str; - json2pb::ProtoMessageToJson(*req, &req_str, NULL); - json2pb::ProtoMessageToJson(*res, &res_str, NULL); + json2pb::ProtoMessageToJson(*req, &req_str, nullptr); + json2pb::ProtoMessageToJson(*res, &res_str, nullptr); LOG(INFO) << "req:" << req_str << " res:" << res_str; } @@ -93,9 +93,9 @@ class FileServiceImpl : public FileService { static void* SendLargeFile(void* raw_args) { std::unique_ptr args(static_cast(raw_args)); - if (args->pa == NULL) { + if (args->pa == nullptr) { LOG(ERROR) << "ProgressiveAttachment is NULL"; - return NULL; + return nullptr; } for (int i = 0; i < 100; ++i) { char buf[16]; @@ -105,7 +105,7 @@ class FileServiceImpl : public FileService { // sleep a while to send another part. bthread_usleep(10000); } - return NULL; + return nullptr; } void default_method(google::protobuf::RpcController* cntl_base, @@ -121,7 +121,7 @@ class FileServiceImpl : public FileService { std::unique_ptr args(new Args); args->pa = cntl->CreateProgressiveAttachment(); bthread_t th; - bthread_start_background(&th, NULL, SendLargeFile, args.release()); + bthread_start_background(&th, nullptr, SendLargeFile, args.release()); } else { cntl->response_attachment().append("Getting file: "); cntl->response_attachment().append(filename); @@ -183,9 +183,9 @@ class HttpSSEServiceImpl : public HttpSSEService { static void* Predict(void* raw_args) { std::unique_ptr args(static_cast(raw_args)); - if (args->pa == NULL) { + if (args->pa == nullptr) { LOG(ERROR) << "ProgressiveAttachment is NULL"; - return NULL; + return nullptr; } for (int i = 0; i < 100; ++i) { char buf[48]; @@ -195,7 +195,7 @@ class HttpSSEServiceImpl : public HttpSSEService { // sleep a while to send another part. bthread_usleep(10000 * 10); } - return NULL; + return nullptr; } void stream(google::protobuf::RpcController* cntl_base, @@ -217,7 +217,7 @@ class HttpSSEServiceImpl : public HttpSSEService { args->pa = cntl->CreateProgressiveAttachment(); args->input_ids = {101, 102}; bthread_t th; - bthread_start_background(&th, NULL, Predict, args.release()); + bthread_start_background(&th, nullptr, Predict, args.release()); } }; diff --git a/example/memcache_c++/client.cpp b/example/memcache_c++/client.cpp index 5f32198867..6f8ddc3a64 100644 --- a/example/memcache_c++/client.cpp +++ b/example/memcache_c++/client.cpp @@ -67,18 +67,18 @@ static void* sender(void* arg) { brpc::MemcacheResponse response; brpc::Controller cntl; - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - channel->CallMethod(NULL, &cntl, &request, &response, NULL); + channel->CallMethod(nullptr, &cntl, &request, &response, nullptr); const int64_t elp = cntl.latency_us(); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); for (int i = 0; i < FLAGS_batch; ++i) { uint32_t flags; - if (!response.PopGet(&value, &flags, NULL)) { + if (!response.PopGet(&value, &flags, nullptr)) { LOG(INFO) << "Fail to GET the key, " << response.LastError(); brpc::AskToQuit(); - return NULL; + return nullptr; } CHECK(flags == 0xdeadbeef + base_index + i) << "flags=" << flags; @@ -96,7 +96,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_MEMCACHE; options.connection_type = FLAGS_connection_type; @@ -141,13 +141,13 @@ int main(int argc, char* argv[]) { return -1; } } - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to access memcache, " << cntl.ErrorText(); return -1; } for (int i = 0; i < FLAGS_batch * FLAGS_thread_num; ++i) { - if (!response.PopSet(NULL)) { + if (!response.PopSet(nullptr)) { LOG(ERROR) << "Fail to SET memcache, i=" << i << ", " << response.LastError(); return -1; @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -175,7 +175,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -191,9 +191,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "memcache_client is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } if (options.auth) { diff --git a/example/multi_threaded_echo_c++/client.cpp b/example/multi_threaded_echo_c++/client.cpp index fa9768c726..7a12f79510 100644 --- a/example/multi_threaded_echo_c++/client.cpp +++ b/example/multi_threaded_echo_c++/client.cpp @@ -64,9 +64,9 @@ static void* sender(void* arg) { // being serialized into protobuf messages. cntl.request_attachment().append(g_attachment); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); } else { @@ -80,7 +80,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; if (FLAGS_enable_ssl) { options.mutable_ssl_options(); @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -149,9 +149,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/multi_threaded_echo_fns_c++/client.cpp b/example/multi_threaded_echo_fns_c++/client.cpp index 895b3e5523..a16214fc37 100644 --- a/example/multi_threaded_echo_fns_c++/client.cpp +++ b/example/multi_threaded_echo_fns_c++/client.cpp @@ -68,9 +68,9 @@ static void* sender(void* arg) { // being serialized into protobuf messages. cntl.request_attachment().append(g_attachment); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { CHECK(response.value() == request.value() + 1); g_latency_recorder << cntl.latency_us(); @@ -86,7 +86,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.backup_request_ms = FLAGS_backup_timeout_ms; options.protocol = FLAGS_protocol; @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -147,9 +147,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/multi_threaded_echo_fns_c++/server.cpp b/example/multi_threaded_echo_fns_c++/server.cpp index a25ef96e81..cb94260e05 100644 --- a/example/multi_threaded_echo_fns_c++/server.cpp +++ b/example/multi_threaded_echo_fns_c++/server.cpp @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) { butil::StringSplitter sp(FLAGS_sleep_us.c_str(), ','); std::vector sleep_list; for (; sp; ++sp) { - sleep_list.push_back(strtoll(sp.field(), NULL, 10)); + sleep_list.push_back(strtoll(sp.field(), nullptr, 10)); } if (sleep_list.empty()) { sleep_list.push_back(0); diff --git a/example/mysql_c++/mysql_cli.cpp b/example/mysql_c++/mysql_cli.cpp index e1de452cec..93a6705c16 100644 --- a/example/mysql_c++/mysql_cli.cpp +++ b/example/mysql_c++/mysql_cli.cpp @@ -54,7 +54,7 @@ static bool access_mysql(brpc::Channel& channel, const char* command) { } brpc::MysqlResponse response; brpc::Controller cntl; - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (!cntl.Failed()) { std::cout << response << std::endl; } else { @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_MYSQL; options.connection_type = FLAGS_connection_type; @@ -127,7 +127,7 @@ int main(int argc, char* argv[]) { char prompt[128]; snprintf(prompt, sizeof(prompt), "mysql %s> ", FLAGS_server.c_str()); std::unique_ptr command(readline(prompt)); - if (command == NULL || *command == '\0') { + if (command == nullptr || *command == '\0') { if (g_canceled) { // No input after the prompt and user pressed Ctrl-C, // quit the CLI. diff --git a/example/mysql_c++/mysql_press.cpp b/example/mysql_c++/mysql_press.cpp index 62dbd73618..378d64fd38 100644 --- a/example/mysql_c++/mysql_press.cpp +++ b/example/mysql_c++/mysql_press.cpp @@ -81,13 +81,13 @@ static void* sender(void* void_args) { brpc::MysqlRequest request; if (!request.Query(command.str())) { LOG(ERROR) << "Fail to execute command"; - return NULL; + return nullptr; } while (!brpc::IsAskedToQuit()) { brpc::MysqlResponse response; brpc::Controller cntl; - args->mysql_channel->CallMethod(NULL, &cntl, &request, &response, NULL); + args->mysql_channel->CallMethod(nullptr, &cntl, &request, &response, nullptr); const int64_t elp = cntl.latency_us(); if (!cntl.Failed()) { g_latency_recorder << elp; @@ -109,7 +109,7 @@ static void* sender(void* void_args) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_MYSQL; options.connection_type = FLAGS_connection_type; @@ -146,7 +146,7 @@ int main(int argc, char* argv[]) { } brpc::MysqlResponse response; brpc::Controller cntl; - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (!cntl.Failed()) { std::cout << response << std::endl; } else { @@ -164,7 +164,7 @@ int main(int argc, char* argv[]) { } brpc::MysqlResponse response; brpc::Controller cntl; - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (!cntl.Failed()) { std::cout << response << std::endl; } else { @@ -183,7 +183,7 @@ int main(int argc, char* argv[]) { } brpc::MysqlResponse response; brpc::Controller cntl; - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << cntl.ErrorText(); return -1; @@ -210,12 +210,12 @@ int main(int argc, char* argv[]) { args[i].base_index = i; args[i].mysql_channel = &channel; if (!FLAGS_use_bthread) { - if (pthread_create(&pids[i], NULL, sender, &args[i]) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &args[i]) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } } else { - if (bthread_start_background(&bids[i], NULL, sender, &args[i]) != 0) { + if (bthread_start_background(&bids[i], nullptr, sender, &args[i]) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -232,9 +232,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "mysql_client is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/mysql_c++/mysql_stmt.cpp b/example/mysql_c++/mysql_stmt.cpp index d1289c1fbc..af2ac132fa 100644 --- a/example/mysql_c++/mysql_stmt.cpp +++ b/example/mysql_c++/mysql_stmt.cpp @@ -60,69 +60,69 @@ static void* access_mysql(void* void_args) { brpc::MysqlRequest request(stmt); for (size_t i = 1; i < commands.size(); i += 2) { if (commands[i] == "int8") { - int8_t val = strtol(commands[i + 1].c_str(), NULL, 10); + int8_t val = strtol(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add int8 param"; - return NULL; + return nullptr; } } else if (commands[i] == "uint8") { - uint8_t val = strtoul(commands[i + 1].c_str(), NULL, 10); + uint8_t val = strtoul(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add uint8 param"; - return NULL; + return nullptr; } } else if (commands[i] == "int16") { - int16_t val = strtol(commands[i + 1].c_str(), NULL, 10); + int16_t val = strtol(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add uint16 param"; - return NULL; + return nullptr; } } else if (commands[i] == "uint16") { - uint16_t val = strtoul(commands[i + 1].c_str(), NULL, 10); + uint16_t val = strtoul(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add uint16 param"; - return NULL; + return nullptr; } } else if (commands[i] == "int32") { - int32_t val = strtol(commands[i + 1].c_str(), NULL, 10); + int32_t val = strtol(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add int32 param"; - return NULL; + return nullptr; } } else if (commands[i] == "uint32") { - uint32_t val = strtoul(commands[i + 1].c_str(), NULL, 10); + uint32_t val = strtoul(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add uint32 param"; - return NULL; + return nullptr; } } else if (commands[i] == "int64") { - int64_t val = strtol(commands[i + 1].c_str(), NULL, 10); + int64_t val = strtol(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add int64 param"; - return NULL; + return nullptr; } } else if (commands[i] == "uint64") { - uint64_t val = strtoul(commands[i + 1].c_str(), NULL, 10); + uint64_t val = strtoul(commands[i + 1].c_str(), nullptr, 10); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add uint64 param"; - return NULL; + return nullptr; } } else if (commands[i] == "float") { - float val = strtof(commands[i + 1].c_str(), NULL); + float val = strtof(commands[i + 1].c_str(), nullptr); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add float param"; - return NULL; + return nullptr; } } else if (commands[i] == "double") { - double val = strtod(commands[i + 1].c_str(), NULL); + double val = strtod(commands[i + 1].c_str(), nullptr); if (!request.AddParam(val)) { LOG(ERROR) << "Fail to add double param"; - return NULL; + return nullptr; } } else if (commands[i] == "string") { if (!request.AddParam(commands[i + 1])) { LOG(ERROR) << "Fail to add string param"; - return NULL; + return nullptr; } } else { LOG(ERROR) << "Wrong param type " << commands[i]; @@ -131,16 +131,16 @@ static void* access_mysql(void* void_args) { brpc::MysqlResponse response; brpc::Controller cntl; - channel->CallMethod(NULL, &cntl, &request, &response, NULL); + channel->CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to access mysql, " << cntl.ErrorText(); - return NULL; + return nullptr; } std::cout << response << std::endl; } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -151,7 +151,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_MYSQL; options.connection_type = FLAGS_connection_type; @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) { commands.push_back(argv[i]); } auto stmt(brpc::NewMysqlStatement(channel, commands[0])); - if (stmt == NULL) { + if (stmt == nullptr) { LOG(ERROR) << "Fail to create mysql statement"; return -1; } @@ -188,14 +188,14 @@ int main(int argc, char* argv[]) { args[i].mysql_channel = &channel; args[i].mysql_stmt = stmt.get(); args[i].commands = commands; - if (bthread_start_background(&bids[i], NULL, access_mysql, &args[i]) != 0) { + if (bthread_start_background(&bids[i], nullptr, access_mysql, &args[i]) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } } for (int i = 0; i < FLAGS_thread_num; ++i) { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/mysql_c++/mysql_tx.cpp b/example/mysql_c++/mysql_tx.cpp index c1d74dc2ff..b978593e9c 100644 --- a/example/mysql_c++/mysql_tx.cpp +++ b/example/mysql_c++/mysql_tx.cpp @@ -48,7 +48,7 @@ static bool access_mysql(brpc::Channel& channel, const std::vector& options.readonly = FLAGS_readonly; options.isolation_level = brpc::MysqlIsolationLevel(FLAGS_isolation_level); auto tx(brpc::NewMysqlTransaction(channel, options)); - if (tx == NULL) { + if (tx == nullptr) { LOG(ERROR) << "Fail to create transaction"; return false; } @@ -62,7 +62,7 @@ static bool access_mysql(brpc::Channel& channel, const std::vector& } brpc::MysqlResponse response; brpc::Controller cntl; - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to access mysql, " << cntl.ErrorText(); tx->rollback(); @@ -89,7 +89,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_MYSQL; options.connection_type = FLAGS_connection_type; diff --git a/example/mysql_c++/mysqlclient_press.cpp b/example/mysql_c++/mysqlclient_press.cpp index a0aa45ef59..5c5024717b 100644 --- a/example/mysql_c++/mysqlclient_press.cpp +++ b/example/mysql_c++/mysqlclient_press.cpp @@ -88,7 +88,7 @@ static void* sender(void* void_args) { CHECK_EQ(mysql_affected_rows(args->mysql_conn), 1); } else if (FLAGS_op_type == 1) { MYSQL_RES* res = mysql_store_result(args->mysql_conn); - if (res == NULL) { + if (res == nullptr) { LOG(INFO) << "not found"; } else { CHECK_EQ(mysql_num_rows(res), 1); @@ -115,7 +115,7 @@ static void* sender(void* void_args) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -126,14 +126,14 @@ int main(int argc, char* argv[]) { brpc::StartDummyServerAt(FLAGS_dummy_port); } - MYSQL* conn = mysql_init(NULL); + MYSQL* conn = mysql_init(nullptr); if (!mysql_real_connect(conn, FLAGS_server.c_str(), FLAGS_user.c_str(), FLAGS_password.c_str(), FLAGS_schema.c_str(), FLAGS_port, - NULL, + nullptr, 0)) { LOG(ERROR) << mysql_error(conn); return -1; @@ -197,14 +197,14 @@ int main(int argc, char* argv[]) { std::vector args; args.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - MYSQL* conn = mysql_init(NULL); + MYSQL* conn = mysql_init(nullptr); if (!mysql_real_connect(conn, FLAGS_server.c_str(), FLAGS_user.c_str(), FLAGS_password.c_str(), FLAGS_schema.c_str(), FLAGS_port, - NULL, + nullptr, 0)) { LOG(ERROR) << mysql_error(conn); return -1; @@ -212,12 +212,12 @@ int main(int argc, char* argv[]) { args[i].base_index = i; args[i].mysql_conn = conn; if (!FLAGS_use_bthread) { - if (pthread_create(&pids[i], NULL, sender, &args[i]) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &args[i]) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } } else { - if (bthread_start_background(&bids[i], NULL, sender, &args[i]) != 0) { + if (bthread_start_background(&bids[i], nullptr, sender, &args[i]) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -234,9 +234,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "mysql_client is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/nshead_extension_c++/client.cpp b/example/nshead_extension_c++/client.cpp index bfc48b6f7e..52290cf78e 100644 --- a/example/nshead_extension_c++/client.cpp +++ b/example/nshead_extension_c++/client.cpp @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_NSHEAD; options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; @@ -63,9 +63,9 @@ int main(int argc, char* argv[]) { cntl.set_log_id(log_id ++); // set by user - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to send nshead request, " << cntl.ErrorText(); sleep(1); // Remove this sleep in production code. diff --git a/example/nshead_pb_extension_c++/client.cpp b/example/nshead_pb_extension_c++/client.cpp index bfc48b6f7e..52290cf78e 100644 --- a/example/nshead_pb_extension_c++/client.cpp +++ b/example/nshead_pb_extension_c++/client.cpp @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_NSHEAD; options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; @@ -63,9 +63,9 @@ int main(int argc, char* argv[]) { cntl.set_log_id(log_id ++); // set by user - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to send nshead request, " << cntl.ErrorText(); sleep(1); // Remove this sleep in production code. diff --git a/example/parallel_echo_c++/client.cpp b/example/parallel_echo_c++/client.cpp index 54ce661dd8..b5b3bbd987 100644 --- a/example/parallel_echo_c++/client.cpp +++ b/example/parallel_echo_c++/client.cpp @@ -46,7 +46,7 @@ std::string g_request; std::string g_attachment; bvar::LatencyRecorder g_latency_recorder("client"); bvar::Adder g_error_count("client_error_count"); -bvar::LatencyRecorder* g_sub_channel_latency = NULL; +bvar::LatencyRecorder* g_sub_channel_latency = nullptr; static void* sender(void* arg) { // Normally, you should not call a Channel directly, but instead construct @@ -68,9 +68,9 @@ static void* sender(void* arg) { cntl.request_attachment().append(g_attachment); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); for (int i = 0; i < cntl.sub_count(); ++i) { @@ -89,7 +89,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) { // For brpc >= 1.0.155.31351, a sub channel can be added into // a ParallelChannel more than once. brpc::Channel* sub_channel = new brpc::Channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. // options, see `brpc/channel.h'. if (sub_channel->Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &sub_options) != 0) { LOG(ERROR) << "Fail to initialize sub_channel"; @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) { } for (int i = 0; i < FLAGS_channel_num; ++i) { if (channel.AddChannel(sub_channel, brpc::OWNS_CHANNEL, - NULL, NULL) != 0) { + nullptr, nullptr) != 0) { LOG(ERROR) << "Fail to AddChannel, i=" << i; return -1; } @@ -133,14 +133,14 @@ int main(int argc, char* argv[]) { } else { for (int i = 0; i < FLAGS_channel_num; ++i) { brpc::Channel* sub_channel = new brpc::Channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. // options, see `brpc/channel.h'. if (sub_channel->Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &sub_options) != 0) { LOG(ERROR) << "Fail to initialize sub_channel[" << i << "]"; return -1; } if (channel.AddChannel(sub_channel, brpc::OWNS_CHANNEL, - NULL, NULL) != 0) { + nullptr, nullptr) != 0) { LOG(ERROR) << "Fail to AddChannel, i=" << i; return -1; } @@ -173,7 +173,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -182,7 +182,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -204,9 +204,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/partition_echo_c++/client.cpp b/example/partition_echo_c++/client.cpp index b60a63d032..bf6e1c39b5 100644 --- a/example/partition_echo_c++/client.cpp +++ b/example/partition_echo_c++/client.cpp @@ -54,7 +54,7 @@ static void* sender(void* arg) { // a stub Service wrapping it. stub can be shared by all threads as well. example::EchoService_Stub stub(static_cast(arg)); - SenderInfo* info = NULL; + SenderInfo* info = nullptr; { BAIDU_SCOPED_LOCK(g_latency_mutex); g_sender_info.push_back(SenderInfo()); @@ -77,9 +77,9 @@ static void* sender(void* arg) { cntl.request_attachment().append(g_attachment); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { info->latency_sum += cntl.latency_us(); ++info->nsuccess; @@ -93,7 +93,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } class MyPartitionParser : public brpc::PartitionParser { @@ -105,7 +105,7 @@ class MyPartitionParser : public brpc::PartitionParser { LOG(ERROR) << "Invalid tag=`" << tag << '\''; return false; } - char* endptr = NULL; + char* endptr = nullptr; out->index = strtol(tag.c_str(), &endptr, 10); if (endptr != tag.data() + pos) { LOG(ERROR) << "Invalid index=" << butil::StringPiece(tag.data(), pos); @@ -158,7 +158,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -167,7 +167,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -205,9 +205,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/partition_echo_c++/server.cpp b/example/partition_echo_c++/server.cpp index 7dbcf8f519..531a1b9a8e 100644 --- a/example/partition_echo_c++/server.cpp +++ b/example/partition_echo_c++/server.cpp @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) { butil::StringSplitter sp(FLAGS_sleep_us.c_str(), ','); std::vector sleep_list; for (; sp; ++sp) { - sleep_list.push_back(strtoll(sp.field(), NULL, 10)); + sleep_list.push_back(strtoll(sp.field(), nullptr, 10)); } if (sleep_list.empty()) { sleep_list.push_back(0); diff --git a/example/rdma_performance/client.cpp b/example/rdma_performance/client.cpp index 2e8acc4051..8c07eca236 100644 --- a/example/rdma_performance/client.cpp +++ b/example/rdma_performance/client.cpp @@ -71,14 +71,14 @@ static void* GenerateToken(void* arg) { accumulative_token += delta; } } - return NULL; + return nullptr; } class PerformanceTest { public: PerformanceTest(int attachment_size, bool echo_attachment) - : _addr(NULL) - , _channel(NULL) + : _addr(nullptr) + , _channel(nullptr) , _start_time(0) , _iterations(0) , _stop(false) @@ -118,7 +118,7 @@ class PerformanceTest { test::PerfTestRequest request; request.set_echo_attachment(_echo_attachment); test::PerfTestService_Stub stub(_channel); - stub.Test(&cntl, &request, &response, NULL); + stub.Test(&cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "RPC call failed: " << cntl.ErrorText(); return -1; @@ -167,8 +167,8 @@ class PerformanceTest { g_total_bytes.fetch_add(closure->cntl->request_attachment().size(), butil::memory_order_relaxed); g_total_cnt.fetch_add(1, butil::memory_order_relaxed); - cntl_guard.reset(NULL); - response_guard.reset(NULL); + cntl_guard.reset(nullptr); + response_guard.reset(nullptr); if (closure->test->_iterations == 0 && FLAGS_test_iterations > 0) { closure->test->_stop = true; @@ -199,7 +199,7 @@ class PerformanceTest { test->SendRequest(); } - return NULL; + return nullptr; } private: @@ -215,7 +215,7 @@ class PerformanceTest { static void* DeleteTest(void* arg) { PerformanceTest* test = (PerformanceTest*)arg; delete test; - return NULL; + return nullptr; } void Test(int thread_num, int attachment_size) { @@ -239,7 +239,7 @@ void Test(int thread_num, int attachment_size) { bthread_t tid[thread_num]; if (FLAGS_expected_qps > 0) { bthread_t tid; - bthread_start_background(&tid, &BTHREAD_ATTR_NORMAL, GenerateToken, NULL); + bthread_start_background(&tid, &BTHREAD_ATTR_NORMAL, GenerateToken, nullptr); } for (int k = 0; k < thread_num; ++k) { bthread_start_background(&tid[k], &BTHREAD_ATTR_NORMAL, diff --git a/example/redis_c++/redis_cli.cpp b/example/redis_c++/redis_cli.cpp index 02124aa34e..ebe6408410 100644 --- a/example/redis_c++/redis_cli.cpp +++ b/example/redis_c++/redis_cli.cpp @@ -44,7 +44,7 @@ static bool access_redis(brpc::Channel& channel, const char* command) { } brpc::RedisResponse response; brpc::Controller cntl; - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to access redis, " << cntl.ErrorText(); return false; @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_REDIS; options.connection_type = FLAGS_connection_type; @@ -113,7 +113,7 @@ int main(int argc, char* argv[]) { char prompt[64]; snprintf(prompt, sizeof(prompt), "redis %s> ", FLAGS_server.c_str()); std::unique_ptr command(readline(prompt)); - if (command == NULL || *command == '\0') { + if (command == nullptr || *command == '\0') { if (g_canceled) { // No input after the prompt and user pressed Ctrl-C, // quit the CLI. diff --git a/example/redis_c++/redis_cluster_client.cpp b/example/redis_c++/redis_cluster_client.cpp index 2a9f43b46f..cc219ec4c1 100644 --- a/example/redis_c++/redis_cluster_client.cpp +++ b/example/redis_c++/redis_cluster_client.cpp @@ -87,7 +87,7 @@ int main(int argc, char* argv[]) { CHECK(request.AddCommand("set %s v1", key1.c_str())); CHECK(request.AddCommand("set %s v2", key2.c_str())); CHECK(request.AddCommand("mget %s %s", key1.c_str(), key2.c_str())); - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Sync call failed: " << cntl.ErrorText(); return -1; @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) { bthread::CountdownEvent event(1); Done done(&event); - channel.CallMethod(NULL, &async_cntl, &async_request, &async_response, &done); + channel.CallMethod(nullptr, &async_cntl, &async_request, &async_response, &done); event.wait(); if (async_cntl.Failed()) { LOG(ERROR) << "Async call failed: " << async_cntl.ErrorText(); diff --git a/example/redis_c++/redis_press.cpp b/example/redis_c++/redis_press.cpp index 165b8bf1f9..56a817a840 100644 --- a/example/redis_c++/redis_press.cpp +++ b/example/redis_c++/redis_press.cpp @@ -70,9 +70,9 @@ static void* sender(void* void_args) { brpc::RedisResponse response; brpc::Controller cntl; - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - args->redis_channel->CallMethod(NULL, &cntl, &request, &response, NULL); + args->redis_channel->CallMethod(nullptr, &cntl, &request, &response, nullptr); const int64_t elp = cntl.latency_us(); if (!cntl.Failed()) { g_latency_recorder << elp; @@ -92,7 +92,7 @@ static void* sender(void* void_args) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -103,7 +103,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_REDIS; options.connection_type = FLAGS_connection_type; @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) { return -1; } } - channel.CallMethod(NULL, &cntl, &request, &response, NULL); + channel.CallMethod(nullptr, &cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to access redis, " << cntl.ErrorText(); return -1; @@ -156,13 +156,13 @@ int main(int argc, char* argv[]) { args[i].base_index = i * FLAGS_batch; args[i].redis_channel = &channel; if (!FLAGS_use_bthread) { - if (pthread_create(&pids[i], NULL, sender, &args[i]) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &args[i]) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } } else { if (bthread_start_background( - &bids[i], NULL, sender, &args[i]) != 0) { + &bids[i], nullptr, sender, &args[i]) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -179,9 +179,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "redis_client is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } return 0; diff --git a/example/rpcz_echo_c++/client.cpp b/example/rpcz_echo_c++/client.cpp index 8cb86866fe..90eb592661 100644 --- a/example/rpcz_echo_c++/client.cpp +++ b/example/rpcz_echo_c++/client.cpp @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -75,9 +75,9 @@ int main(int argc, char* argv[]) { // being serialized into protobuf messages. cntl.request_attachment().append(FLAGS_attachment); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { LOG(INFO) << "Received response from " << cntl.remote_side() << " to " << cntl.local_side() diff --git a/example/rpcz_echo_c++/server.cpp b/example/rpcz_echo_c++/server.cpp index 8503e99583..17fdac2bff 100644 --- a/example/rpcz_echo_c++/server.cpp +++ b/example/rpcz_echo_c++/server.cpp @@ -43,7 +43,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); namespace example { static const bthread_attr_t BTHREAD_ATTR_NORMAL_WITH_SPAN = { - BTHREAD_STACKTYPE_NORMAL, BTHREAD_INHERIT_SPAN, NULL, BTHREAD_TAG_INVALID}; + BTHREAD_STACKTYPE_NORMAL, BTHREAD_INHERIT_SPAN, nullptr, BTHREAD_TAG_INVALID}; void* RunThreadFunc(void*) { TRACEPRINTF("RunThreadFunc %lu", bthread_self()); @@ -51,7 +51,7 @@ void* RunThreadFunc(void*) { // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -69,9 +69,9 @@ void* RunThreadFunc(void*) { brpc::Controller cntl; request.set_message("hello world"); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { LOG(INFO) << "Received response from " << cntl.remote_side() << " to " << cntl.local_side() << ": " << response.message() << " (attached=" << cntl.response_attachment() diff --git a/example/selective_echo_c++/client.cpp b/example/selective_echo_c++/client.cpp index 6f0c413a2b..be3d84dc9d 100644 --- a/example/selective_echo_c++/client.cpp +++ b/example/selective_echo_c++/client.cpp @@ -65,9 +65,9 @@ static void* sender(void* arg) { cntl.request_attachment().append(g_attachment); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); const int64_t elp = cntl.latency_us(); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); @@ -81,7 +81,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -144,7 +144,7 @@ int main(int argc, char* argv[]) { LOG(ERROR) << "Fail to init sub channel[" << i << "] of pchan"; return -1; } - if (sub_channel2->AddChannel(c, brpc::OWNS_CHANNEL, NULL, NULL) != 0) { + if (sub_channel2->AddChannel(c, brpc::OWNS_CHANNEL, nullptr, nullptr) != 0) { LOG(ERROR) << "Fail to add sub channel[" << i << "] into pchan"; return -1; } @@ -153,7 +153,7 @@ int main(int argc, char* argv[]) { // Add another selective channel with default options. brpc::SelectiveChannel* sub_channel3 = new brpc::SelectiveChannel; - if (sub_channel3->Init(FLAGS_load_balancer.c_str(), NULL) != 0) { + if (sub_channel3->Init(FLAGS_load_balancer.c_str(), nullptr) != 0) { LOG(ERROR) << "Fail to init schan"; return -1; } @@ -176,7 +176,7 @@ int main(int argc, char* argv[]) { return -1; } } - if (sub_channel3->AddChannel(c, NULL)) { + if (sub_channel3->AddChannel(c, nullptr)) { LOG(ERROR) << "Fail to add sub channel[" << i << "] into schan"; return -1; } @@ -186,7 +186,7 @@ int main(int argc, char* argv[]) { // Add all sub channels into schan. for (size_t i = 0; i < sub_channels.size(); ++i) { // note: we don't need the handle for channel removal; - if (channel.AddChannel(sub_channels[i], NULL/*note*/) != 0) { + if (channel.AddChannel(sub_channels[i], nullptr/*note*/) != 0) { LOG(ERROR) << "Fail to add sub_channel[" << i << "]"; return -1; } @@ -205,7 +205,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -214,7 +214,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -230,9 +230,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/selective_echo_c++/server.cpp b/example/selective_echo_c++/server.cpp index d1ed8bb940..87c95bd0fe 100644 --- a/example/selective_echo_c++/server.cpp +++ b/example/selective_echo_c++/server.cpp @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) { butil::StringSplitter sp(FLAGS_sleep_us.c_str(), ','); std::vector sleep_list; for (; sp; ++sp) { - sleep_list.push_back(strtoll(sp.field(), NULL, 10)); + sleep_list.push_back(strtoll(sp.field(), nullptr, 10)); } if (sleep_list.empty()) { sleep_list.push_back(0); diff --git a/example/session_data_and_thread_local/client.cpp b/example/session_data_and_thread_local/client.cpp index f075e70451..601ff64018 100644 --- a/example/session_data_and_thread_local/client.cpp +++ b/example/session_data_and_thread_local/client.cpp @@ -62,10 +62,10 @@ static void* sender(void* arg) { cntl.request_attachment().append(g_attachment); } - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). const int64_t start_time = butil::cpuwide_time_us(); - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); const int64_t end_time = butil::cpuwide_time_us(); const int64_t elp = end_time - start_time; if (!cntl.Failed()) { @@ -80,7 +80,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = FLAGS_protocol; options.connection_type = FLAGS_connection_type; @@ -116,7 +116,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -141,9 +141,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/session_data_and_thread_local/server.cpp b/example/session_data_and_thread_local/server.cpp index c196c33edc..20893f07f4 100644 --- a/example/session_data_and_thread_local/server.cpp +++ b/example/session_data_and_thread_local/server.cpp @@ -96,7 +96,7 @@ struct AsyncJob { static void* process_thread(void* args) { AsyncJob* job = static_cast(args); job->run_and_delete(); - return NULL; + return nullptr; } // Your implementation of example::EchoService @@ -120,7 +120,7 @@ class EchoServiceWithThreadAndSessionLocal : public example::EchoService { // and reused between different RPC. All session-local data are // destroyed upon server destruction. MySessionLocalData* sd = static_cast(cntl->session_local_data()); - if (sd == NULL) { + if (sd == nullptr) { cntl->SetFailed("Require ServerOptions.session_local_data_factory to be" " set with a correctly implemented instance"); LOG(ERROR) << cntl->ErrorText(); @@ -135,7 +135,7 @@ class EchoServiceWithThreadAndSessionLocal : public example::EchoService { // "tls" is short for "thread local storage". MyThreadLocalData* tls = static_cast(brpc::thread_local_data()); - if (tls == NULL) { + if (tls == nullptr) { cntl->SetFailed("Require ServerOptions.thread_local_data_factory " "to be set with a correctly implemented instance"); LOG(ERROR) << cntl->ErrorText(); @@ -151,7 +151,7 @@ class EchoServiceWithThreadAndSessionLocal : public example::EchoService { // pthread_setspecific -> bthread_setspecific MyThreadLocalData* tls2 = static_cast(bthread_getspecific(_tls2_key)); - if (tls2 == NULL) { + if (tls2 == nullptr) { tls2 = new MyThreadLocalData; CHECK_EQ(0, bthread_setspecific(_tls2_key, tls2)); } @@ -176,7 +176,7 @@ class EchoServiceWithThreadAndSessionLocal : public example::EchoService { job->response = response; job->done = done; bthread_t th; - CHECK_EQ(0, bthread_start_background(&th, NULL, process_thread, job)); + CHECK_EQ(0, bthread_start_background(&th, nullptr, process_thread, job)); // We don't want to call done->Run() here, release the guard. done_guard.release(); diff --git a/example/streaming_batch_echo_c++/client.cpp b/example/streaming_batch_echo_c++/client.cpp index 23f2b06d3a..33daf6af00 100644 --- a/example/streaming_batch_echo_c++/client.cpp +++ b/example/streaming_batch_echo_c++/client.cpp @@ -61,13 +61,13 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_BAIDU_STD; options.connection_type = FLAGS_connection_type; options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; options.max_retry = FLAGS_max_retry; - if (channel.Init(FLAGS_server.c_str(), NULL) != 0) { + if (channel.Init(FLAGS_server.c_str(), nullptr) != 0) { LOG(ERROR) << "Fail to initialize channel"; return -1; } @@ -90,7 +90,7 @@ int main(int argc, char* argv[]) { example::EchoRequest request; example::EchoResponse response; request.set_message("I'm a RPC to connect stream"); - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to connect stream, " << cntl.ErrorText(); return -1; diff --git a/example/streaming_echo_c++/client.cpp b/example/streaming_echo_c++/client.cpp index 619f579a61..1a3c5ed6b2 100644 --- a/example/streaming_echo_c++/client.cpp +++ b/example/streaming_echo_c++/client.cpp @@ -37,13 +37,13 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_BAIDU_STD; options.connection_type = FLAGS_connection_type; options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; options.max_retry = FLAGS_max_retry; - if (channel.Init(FLAGS_server.c_str(), NULL) != 0) { + if (channel.Init(FLAGS_server.c_str(), nullptr) != 0) { LOG(ERROR) << "Fail to initialize channel"; return -1; } @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { example::EchoService_Stub stub(&channel); brpc::Controller cntl; brpc::StreamId stream; - if (brpc::StreamCreate(&stream, cntl, NULL) != 0) { + if (brpc::StreamCreate(&stream, cntl, nullptr) != 0) { LOG(ERROR) << "Fail to create stream"; return -1; } @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) { example::EchoRequest request; example::EchoResponse response; request.set_message("I'm a RPC to connect stream"); - stub.Echo(&cntl, &request, &response, NULL); + stub.Echo(&cntl, &request, &response, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to connect stream, " << cntl.ErrorText(); return -1; diff --git a/example/thrift_extension_c++/client.cpp b/example/thrift_extension_c++/client.cpp index b358792434..745163177b 100755 --- a/example/thrift_extension_c++/client.cpp +++ b/example/thrift_extension_c++/client.cpp @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_THRIFT; options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) { req.__set_data("hello"); req.__set_need_by_proxy(10); - stub.CallMethod("Echo", &cntl, &req, &res, NULL); + stub.CallMethod("Echo", &cntl, &req, &res, nullptr); if (cntl.Failed()) { LOG(ERROR) << "Fail to send thrift request, " << cntl.ErrorText(); diff --git a/example/thrift_extension_c++/client2.cpp b/example/thrift_extension_c++/client2.cpp index c6caa0a890..b4b917cbaf 100644 --- a/example/thrift_extension_c++/client2.cpp +++ b/example/thrift_extension_c++/client2.cpp @@ -58,9 +58,9 @@ static void* sender(void* arg) { req.__set_data(g_request); req.__set_need_by_proxy(10); - // Because `done'(last parameter) is NULL, this function waits until + // Because `done'(last parameter) is nullptr, this function waits until // the response comes back or error occurs(including timedout). - stub.CallMethod("Echo", &cntl, &req, &res, NULL); + stub.CallMethod("Echo", &cntl, &req, &res, nullptr); if (!cntl.Failed()) { g_latency_recorder << cntl.latency_us(); } else { @@ -74,7 +74,7 @@ static void* sender(void* arg) { bthread_usleep(50000); } } - return NULL; + return nullptr; } int main(int argc, char* argv[]) { @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) { // Channel is thread-safe and can be shared by all threads in your program. brpc::Channel channel; - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_THRIFT; options.connection_type = FLAGS_connection_type; @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) { if (!FLAGS_use_bthread) { pids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { - if (pthread_create(&pids[i], NULL, sender, &channel) != 0) { + if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create pthread"; return -1; } @@ -121,7 +121,7 @@ int main(int argc, char* argv[]) { bids.resize(FLAGS_thread_num); for (int i = 0; i < FLAGS_thread_num; ++i) { if (bthread_start_background( - &bids[i], NULL, sender, &channel) != 0) { + &bids[i], nullptr, sender, &channel) != 0) { LOG(ERROR) << "Fail to create bthread"; return -1; } @@ -137,9 +137,9 @@ int main(int argc, char* argv[]) { LOG(INFO) << "EchoClient is going to quit"; for (int i = 0; i < FLAGS_thread_num; ++i) { if (!FLAGS_use_bthread) { - pthread_join(pids[i], NULL); + pthread_join(pids[i], nullptr); } else { - bthread_join(bids[i], NULL); + bthread_join(bids[i], nullptr); } } diff --git a/example/thrift_extension_c++/server2.cpp b/example/thrift_extension_c++/server2.cpp index 920605331c..1960dc8b60 100755 --- a/example/thrift_extension_c++/server2.cpp +++ b/example/thrift_extension_c++/server2.cpp @@ -34,7 +34,7 @@ DEFINE_int32(max_concurrency, 0, "Limit of request processing in parallel"); class EchoServiceImpl : public brpc::ThriftService { public: EchoServiceImpl() { - // Initialize the channel, NULL means using default options. + // Initialize the channel, nullptr means using default options. brpc::ChannelOptions options; options.protocol = brpc::PROTOCOL_THRIFT; if (_channel.Init("0.0.0.0", FLAGS_port , &options) != 0) { @@ -55,7 +55,7 @@ class EchoServiceImpl : public brpc::ThriftService { // TODO: Following Cast<> drops data field from ProxyRequest which // does not recognize the field, should be debugged further. // LOG(INFO) << "req=" << *req->Cast(); - stub.CallMethod("RealEcho", &cntl, req, res, NULL); + stub.CallMethod("RealEcho", &cntl, req, res, nullptr); done->Run(); } else if (cntl->thrift_method_name() == "RealEcho") { return RealEcho(cntl, req->Cast(), diff --git a/example/ubring_performance/client.cpp b/example/ubring_performance/client.cpp index 9c26ea85b3..24a786f8f1 100644 --- a/example/ubring_performance/client.cpp +++ b/example/ubring_performance/client.cpp @@ -71,14 +71,14 @@ static void* GenerateToken(void* arg) { accumulative_token += delta; } } - return NULL; + return nullptr; } class PerformanceTest { public: PerformanceTest(int attachment_size, bool echo_attachment) - : _addr(NULL) - , _channel(NULL) + : _addr(nullptr) + , _channel(nullptr) , _start_time(0) , _iterations(0) , _stop(false) @@ -124,7 +124,7 @@ class PerformanceTest { test::PerfTestRequest request; request.set_echo_attachment(_echo_attachment); test::PerfTestService_Stub stub(_channel); - stub.Test(&cntl, &request, &response, NULL); + stub.Test(&cntl, &request, &response, nullptr); if (!cntl.Failed()) { return 0; } @@ -179,8 +179,8 @@ class PerformanceTest { g_total_bytes.fetch_add(closure->cntl->request_attachment().size(), butil::memory_order_relaxed); g_total_cnt.fetch_add(1, butil::memory_order_relaxed); - cntl_guard.reset(NULL); - response_guard.reset(NULL); + cntl_guard.reset(nullptr); + response_guard.reset(nullptr); if (closure->test->_iterations == 0 && FLAGS_test_iterations > 0) { closure->test->_stop = true; @@ -211,7 +211,7 @@ class PerformanceTest { test->SendRequest(); } - return NULL; + return nullptr; } private: @@ -227,7 +227,7 @@ class PerformanceTest { static void* DeleteTest(void* arg) { PerformanceTest* test = (PerformanceTest*)arg; delete test; - return NULL; + return nullptr; } void Test(int thread_num, int attachment_size) { @@ -251,7 +251,7 @@ void Test(int thread_num, int attachment_size) { bthread_t tid[thread_num]; if (FLAGS_expected_qps > 0) { bthread_t tid; - bthread_start_background(&tid, &BTHREAD_ATTR_NORMAL, GenerateToken, NULL); + bthread_start_background(&tid, &BTHREAD_ATTR_NORMAL, GenerateToken, nullptr); } for (int k = 0; k < thread_num; ++k) { bthread_start_background(&tid[k], &BTHREAD_ATTR_NORMAL, @@ -282,7 +282,7 @@ void Test(int thread_num, int attachment_size) { bthread_start_background(&tid[k], &BTHREAD_ATTR_NORMAL, DeleteTest, tests[k]); } for (int k = 0; k < thread_num; ++k) { - bthread_join(tid[k], NULL); + bthread_join(tid[k], nullptr); } }