Merge pull request #24445 from veblush/modernize-use-bool-literals

[Clang-Tidy] Enable modernize-use-bool-literals
pull/24409/head
Esun Kim 4 years ago committed by GitHub
commit b29700b798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .clang-tidy
  2. 8
      src/core/ext/filters/client_channel/resolver_registry.cc
  3. 2
      src/core/ext/filters/client_channel/subchannel.cc
  4. 2
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  5. 2
      src/core/ext/transport/chttp2/transport/parsing.cc
  6. 4
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  7. 2
      src/core/lib/iomgr/exec_ctx.cc
  8. 4
      src/core/lib/iomgr/timer_custom.cc
  9. 12
      src/core/lib/surface/call.cc
  10. 2
      src/core/lib/surface/completion_queue.cc
  11. 14
      src/core/tsi/ssl_transport_security.cc
  12. 2
      test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
  13. 2
      test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
  14. 4
      test/core/client_channel/resolvers/dns_resolver_test.cc
  15. 4
      test/core/client_channel/resolvers/sockaddr_resolver_test.cc
  16. 2
      test/core/end2end/fixtures/local_util.cc
  17. 2
      test/core/end2end/fuzzers/client_fuzzer.cc
  18. 2
      test/core/end2end/fuzzers/server_fuzzer.cc
  19. 4
      test/core/iomgr/fd_posix_test.cc
  20. 8
      test/core/iomgr/parse_address_test.cc
  21. 4
      test/core/iomgr/parse_address_with_named_scope_id_test.cc
  22. 2
      test/core/security/credentials_test.cc
  23. 2
      test/core/uri/uri_fuzzer_test.cc
  24. 8
      test/core/uri/uri_parser_test.cc
  25. 2
      test/core/util/passthru_endpoint.cc
  26. 2
      test/core/util/tracer_util.cc

@ -27,7 +27,7 @@ Checks: '-*,
-modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-shrink-to-fit,
-modernize-use-bool-literals,
modernize-use-bool-literals,
modernize-use-nullptr,
-modernize-use-override,
-readability-container-size-empty,

@ -68,18 +68,18 @@ class RegistryState {
ResolverFactory* FindResolverFactory(const char* target, grpc_uri** uri,
std::string* canonical_target) const {
GPR_ASSERT(uri != nullptr);
*uri = grpc_uri_parse(target, 1);
*uri = grpc_uri_parse(target, true);
ResolverFactory* factory =
*uri == nullptr ? nullptr : LookupResolverFactory((*uri)->scheme);
if (factory == nullptr) {
grpc_uri_destroy(*uri);
*canonical_target = absl::StrCat(default_prefix_.get(), target);
*uri = grpc_uri_parse(canonical_target->c_str(), 1);
*uri = grpc_uri_parse(canonical_target->c_str(), true);
factory =
*uri == nullptr ? nullptr : LookupResolverFactory((*uri)->scheme);
if (factory == nullptr) {
grpc_uri_destroy(grpc_uri_parse(target, 0));
grpc_uri_destroy(grpc_uri_parse(canonical_target->c_str(), 0));
grpc_uri_destroy(grpc_uri_parse(target, false));
grpc_uri_destroy(grpc_uri_parse(canonical_target->c_str(), false));
gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target,
canonical_target->c_str());
}

@ -928,7 +928,7 @@ const char* Subchannel::GetUriFromSubchannelAddressArg(
namespace {
void UriToSockaddr(const char* uri_str, grpc_resolved_address* addr) {
grpc_uri* uri = grpc_uri_parse(uri_str, 0 /* suppress_errors */);
grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
GPR_ASSERT(uri != nullptr);
if (!grpc_parse_uri(uri, addr)) memset(addr, 0, sizeof(*addr));
grpc_uri_destroy(uri);

@ -1055,7 +1055,7 @@ static void queue_setting_update(grpc_chttp2_transport* t,
}
if (use_value != t->settings[GRPC_LOCAL_SETTINGS][id]) {
t->settings[GRPC_LOCAL_SETTINGS][id] = use_value;
t->dirtied_local_settings = 1;
t->dirtied_local_settings = true;
}
}

@ -748,7 +748,7 @@ static grpc_error* init_settings_frame_parser(grpc_chttp2_transport* t) {
&t->hpack_parser.table,
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
t->sent_local_settings = 0;
t->sent_local_settings = false;
}
t->parser = grpc_chttp2_settings_parser_parse;
t->parser_data = &t->simple.settings;

@ -128,10 +128,10 @@ struct read_state {
int received_bytes = 0;
int remaining_bytes = 0;
int length_field = 0;
bool compressed = 0;
bool compressed = false;
char grpc_header_bytes[GRPC_HEADER_SIZE_IN_BYTES] = {};
char* payload_field = nullptr;
bool read_stream_closed = 0;
bool read_stream_closed = false;
/* vars for holding data destined for the application */
grpc_core::ManualConstructor<grpc_core::SliceBufferByteStream> sbs;

@ -140,7 +140,7 @@ void ExecCtx::GlobalInit(void) {
}
bool ExecCtx::Flush() {
bool did_something = 0;
bool did_something = false;
GPR_TIMER_SCOPE("grpc_exec_ctx_flush", 0);
for (;;) {
if (!grpc_closure_list_empty(closure_list_)) {

@ -36,7 +36,7 @@ void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* /*error*/) {
grpc_core::ExecCtx exec_ctx;
grpc_timer* timer = t->original;
GPR_ASSERT(timer->pending);
timer->pending = 0;
timer->pending = false;
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure, GRPC_ERROR_NONE);
custom_timer_impl->stop(t);
gpr_free(t);
@ -68,7 +68,7 @@ static void timer_cancel(grpc_timer* timer) {
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
grpc_custom_timer* tw = (grpc_custom_timer*)timer->custom_timer;
if (timer->pending) {
timer->pending = 0;
timer->pending = false;
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure,
GRPC_ERROR_CANCELLED);
custom_timer_impl->stop(tw);

@ -412,7 +412,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
"without Census tracing propagation"));
}
if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
call->cancellation_is_inherited = 1;
call->cancellation_is_inherited = true;
if (gpr_atm_acq_load(&args->parent->received_final_op_atm)) {
immediately_cancel = true;
}
@ -595,7 +595,7 @@ void grpc_call_unref(grpc_call* c) {
}
GPR_ASSERT(!c->destroy_called);
c->destroy_called = 1;
c->destroy_called = true;
bool cancel = gpr_atm_acq_load(&c->any_ops_sent_atm) != 0 &&
gpr_atm_acq_load(&c->received_final_op_atm) == 0;
if (cancel) {
@ -1253,7 +1253,7 @@ static void continue_receiving_slices(batch_control* bctl) {
size_t remaining = call->receiving_stream->length() -
(*call->receiving_buffer)->data.raw.slice_buffer.length;
if (remaining == 0) {
call->receiving_message = 0;
call->receiving_message = false;
call->receiving_stream.reset();
finish_batch_step(bctl);
return;
@ -1267,7 +1267,7 @@ static void continue_receiving_slices(batch_control* bctl) {
call->receiving_stream.reset();
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
call->receiving_message = false;
finish_batch_step(bctl);
GRPC_ERROR_UNREF(error);
return;
@ -1303,7 +1303,7 @@ static void receiving_slice_ready(void* bctlp, grpc_error* error) {
call->receiving_stream.reset();
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
call->receiving_message = false;
finish_batch_step(bctl);
if (release_error) {
GRPC_ERROR_UNREF(error);
@ -1315,7 +1315,7 @@ static void process_data_after_md(batch_control* bctl) {
grpc_call* call = bctl->call;
if (call->receiving_stream == nullptr) {
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
call->receiving_message = false;
finish_batch_step(bctl);
} else {
call->test_only_last_message_flags = call->receiving_stream->flags();

@ -1329,7 +1329,7 @@ static void cq_finish_shutdown_pluck(grpc_completion_queue* cq) {
GPR_ASSERT(cqd->shutdown_called);
GPR_ASSERT(!cqd->shutdown.Load(grpc_core::MemoryOrder::RELAXED));
cqd->shutdown.Store(1, grpc_core::MemoryOrder::RELAXED);
cqd->shutdown.Store(true, grpc_core::MemoryOrder::RELAXED);
cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
}

@ -463,7 +463,7 @@ static tsi_result peer_from_x509(X509* cert, int include_certificate_type,
&current_insert_index);
if (result != TSI_OK) break;
}
} while (0);
} while (false);
if (subject_alt_names != nullptr) {
sk_GENERAL_NAME_pop_free(subject_alt_names, GENERAL_NAME_free);
@ -561,7 +561,7 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
result = TSI_INVALID_ARGUMENT;
break;
}
while (1) {
while (true) {
X509* certificate_authority =
PEM_read_bio_X509(pem, nullptr, nullptr, (void*)"");
if (certificate_authority == nullptr) {
@ -578,7 +578,7 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
though.
*/
}
} while (0);
} while (false);
if (certificate != nullptr) X509_free(certificate);
BIO_free(pem);
@ -679,7 +679,7 @@ static tsi_result ssl_ctx_use_pem_private_key(SSL_CTX* context,
result = TSI_INVALID_ARGUMENT;
break;
}
} while (0);
} while (false);
if (private_key != nullptr) EVP_PKEY_free(private_key);
BIO_free(pem);
return result;
@ -719,7 +719,7 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store,
if (*root_names == nullptr) return TSI_OUT_OF_RESOURCES;
}
while (1) {
while (true) {
root = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)"");
if (root == nullptr) {
ERR_clear_error();
@ -1962,7 +1962,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options(
SSL_CTX_set_next_proto_select_cb(
ssl_context, client_handshaker_factory_npn_callback, impl);
}
} while (0);
} while (false);
if (result != TSI_OK) {
tsi_ssl_handshaker_factory_unref(&impl->base);
return result;
@ -2149,7 +2149,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options(
SSL_CTX_set_next_protos_advertised_cb(
impl->ssl_contexts[i],
server_handshaker_factory_npn_advertised_callback, impl);
} while (0);
} while (false);
if (result != TSI_OK) {
tsi_ssl_handshaker_factory_unref(&impl->base);

@ -95,7 +95,7 @@ static grpc_core::OrphanablePtr<grpc_core::Resolver> create_resolver(
std::unique_ptr<grpc_core::Resolver::ResultHandler> result_handler) {
grpc_core::ResolverFactory* factory =
grpc_core::ResolverRegistry::LookupResolverFactory("dns");
grpc_uri* uri = grpc_uri_parse(name, 0);
grpc_uri* uri = grpc_uri_parse(name, false);
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;

@ -280,7 +280,7 @@ static void start_test_under_work_serializer(void* arg) {
res_cb_arg->result_handler = new ResultHandler();
grpc_core::ResolverFactory* factory =
grpc_core::ResolverRegistry::LookupResolverFactory("dns");
grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, 0);
grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, false);
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", res_cb_arg->uri_str,
factory->scheme());
GPR_ASSERT(uri != nullptr);

@ -40,7 +40,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
factory->scheme());
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_uri* uri = grpc_uri_parse(string, false);
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
@ -57,7 +57,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
factory->scheme());
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_uri* uri = grpc_uri_parse(string, false);
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;

@ -42,7 +42,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
factory->scheme());
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_uri* uri = grpc_uri_parse(string, false);
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
@ -63,7 +63,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
factory->scheme());
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_uri* uri = grpc_uri_parse(string, false);
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;

@ -63,7 +63,7 @@ void grpc_end2end_local_chttp2_init_client_fullstack(
*/
static bool fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
if (server_args == nullptr) return 0;
if (server_args == nullptr) return false;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {

@ -116,7 +116,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
grpc_event ev;
while (1) {
while (true) {
grpc_core::ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);

@ -74,7 +74,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
requested_calls++;
grpc_event ev;
while (1) {
while (true) {
grpc_core::ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);

@ -132,7 +132,7 @@ static void session_read_cb(void* arg, /*session */
ssize_t read_total = 0;
if (error != GRPC_ERROR_NONE) {
session_shutdown_cb(arg, 1);
session_shutdown_cb(arg, true);
return;
}
@ -147,7 +147,7 @@ static void session_read_cb(void* arg, /*session */
It is possible to read nothing due to spurious edge event or data has
been drained, In such a case, read() returns -1 and set errno to EAGAIN. */
if (read_once == 0) {
session_shutdown_cb(arg, 1);
session_shutdown_cb(arg, true);
} else if (read_once == -1) {
if (errno == EAGAIN) {
/* An edge triggered event is cached in the kernel until next poll.

@ -36,7 +36,7 @@
static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
grpc_resolved_address addr;
GPR_ASSERT(1 == grpc_parse_unix(uri, &addr));
@ -57,7 +57,7 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {}
static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
unsigned short port) {
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
grpc_resolved_address addr;
char ntop_buf[GRPC_INET_ADDRSTRLEN];
@ -75,7 +75,7 @@ static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
unsigned short port, uint32_t scope_id) {
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
grpc_resolved_address addr;
char ntop_buf[GRPC_INET6_ADDRSTRLEN];
@ -94,7 +94,7 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
/* Test parsing invalid ipv6 addresses (valid uri_text but invalid ipv6 addr) */
static void test_grpc_parse_ipv6_invalid(const char* uri_text) {
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
grpc_resolved_address addr;
GPR_ASSERT(!grpc_parse_ipv6(uri, &addr));
grpc_uri_destroy(uri);

@ -41,7 +41,7 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
const char* target, const struct sockaddr_in6 result_from_getaddrinfo) {
// Get the sockaddr that gRPC's ipv6 resolver resolves this too.
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(target, 0);
grpc_uri* uri = grpc_uri_parse(target, false);
grpc_resolved_address addr;
GPR_ASSERT(1 == grpc_parse_ipv6(uri, &addr));
grpc_sockaddr_in6* result_from_grpc_parser =
@ -61,7 +61,7 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
}
struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) {
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
std::string host;
std::string port;
grpc_core::SplitHostPort(uri->path, &host, &port);

@ -493,7 +493,7 @@ static void test_oauth2_google_iam_composite_creds(void) {
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
"authorization", test_oauth2_bearer_token, 0);
"authorization", test_oauth2_bearer_token, false);
/* Check security level of fake credentials. */
GPR_ASSERT(oauth2_creds->min_security_level() == GRPC_SECURITY_NONE);

@ -39,7 +39,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
{
grpc_core::ExecCtx exec_ctx;
grpc_uri* x;
if ((x = grpc_uri_parse(s, 1))) {
if ((x = grpc_uri_parse(s, true))) {
grpc_uri_destroy(x);
}

@ -30,7 +30,7 @@ static void test_succeeds(const char* uri_text, const char* scheme,
const char* authority, const char* path,
const char* query, const char* fragment) {
grpc_core::ExecCtx exec_ctx;
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp(scheme, uri->scheme));
GPR_ASSERT(0 == strcmp(authority, uri->authority));
@ -50,7 +50,7 @@ static void test_query_parts() {
{
grpc_core::ExecCtx exec_ctx;
const char* uri_text = "http://foo/path?a&b=B&c=&#frag";
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@ -84,7 +84,7 @@ static void test_query_parts() {
/* test the current behavior of multiple query part values */
grpc_core::ExecCtx exec_ctx;
const char* uri_text = "http://auth/path?foo=bar=baz&foobar==";
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@ -102,7 +102,7 @@ static void test_query_parts() {
/* empty query */
grpc_core::ExecCtx exec_ctx;
const char* uri_text = "http://foo/path";
grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_uri* uri = grpc_uri_parse(uri_text, false);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));

@ -209,7 +209,7 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client,
passthru_endpoint* m =
static_cast<passthru_endpoint*>(gpr_malloc(sizeof(*m)));
m->halves = 2;
m->shutdown = 0;
m->shutdown = false;
if (stats == nullptr) {
m->stats = grpc_passthru_endpoint_stats_create();
} else {

@ -24,7 +24,7 @@ namespace grpc_core {
namespace testing {
void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag) {
flag->set_enabled(1);
flag->set_enabled(true);
}
} // namespace testing

Loading…
Cancel
Save