Added GRPC_ERROR_IS_NONE (#29937)

* Added GRPC_ERROR_IS_NONE

* Convert

* Fix
pull/29778/head
Esun Kim 3 years ago committed by GitHub
parent 372d48b389
commit c6ebbb5482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/ext/filters/channel_idle/channel_idle_filter.cc
  2. 2
      src/core/ext/filters/client_channel/backup_poller.cc
  3. 2
      src/core/ext/filters/client_channel/channel_connectivity.cc
  4. 45
      src/core/ext/filters/client_channel/client_channel.cc
  5. 8
      src/core/ext/filters/client_channel/dynamic_filters.cc
  6. 4
      src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
  7. 12
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  8. 6
      src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc
  9. 8
      src/core/ext/filters/client_channel/lb_policy/priority/priority.cc
  10. 24
      src/core/ext/filters/client_channel/lb_policy/rls/rls.cc
  11. 6
      src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc
  12. 4
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  13. 6
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc
  14. 6
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc
  15. 6
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
  16. 4
      src/core/ext/filters/client_channel/lb_policy_registry.cc
  17. 2
      src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc
  18. 10
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  19. 10
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  20. 10
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  21. 6
      src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc
  22. 2
      src/core/ext/filters/client_channel/resolver/polling_resolver.cc
  23. 10
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  24. 14
      src/core/ext/filters/client_channel/resolver_result_parsing.cc
  25. 24
      src/core/ext/filters/client_channel/retry_filter.cc
  26. 8
      src/core/ext/filters/client_channel/retry_service_config.cc
  27. 2
      src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc
  28. 4
      src/core/ext/filters/client_channel/subchannel.cc
  29. 8
      src/core/ext/filters/client_channel/subchannel_stream_client.cc
  30. 4
      src/core/ext/filters/fault_injection/service_config_parser.cc
  31. 2
      src/core/ext/filters/http/message_compress/message_compress_filter.cc
  32. 8
      src/core/ext/filters/http/message_compress/message_decompress_filter.cc
  33. 2
      src/core/ext/filters/message_size/message_size_filter.cc
  34. 4
      src/core/ext/filters/rbac/rbac_filter.cc
  35. 4
      src/core/ext/filters/rbac/rbac_service_config_parser.cc
  36. 2
      src/core/ext/filters/server_config_selector/server_config_selector_filter.cc
  37. 8
      src/core/ext/transport/binder/transport/binder_transport.cc
  38. 6
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  39. 28
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  40. 92
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  41. 12
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  42. 22
      src/core/ext/transport/chttp2/transport/parsing.cc
  43. 2
      src/core/ext/transport/chttp2/transport/writing.cc
  44. 2
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  45. 36
      src/core/ext/transport/inproc/inproc_transport.cc
  46. 2
      src/core/ext/xds/xds_api.cc
  47. 30
      src/core/ext/xds/xds_bootstrap.cc
  48. 4
      src/core/ext/xds/xds_certificate_provider.cc
  49. 22
      src/core/ext/xds/xds_client.cc
  50. 8
      src/core/ext/xds/xds_cluster.cc
  51. 4
      src/core/ext/xds/xds_cluster_specifier_plugin.cc
  52. 12
      src/core/ext/xds/xds_common_types.cc
  53. 10
      src/core/ext/xds/xds_endpoint.cc
  54. 2
      src/core/ext/xds/xds_lb_policy_registry.cc
  55. 34
      src/core/ext/xds/xds_listener.cc
  56. 22
      src/core/ext/xds/xds_route_config.cc
  57. 10
      src/core/ext/xds/xds_server_config_fetcher.cc
  58. 4
      src/core/lib/address_utils/parse_address.cc
  59. 8
      src/core/lib/channel/channel_stack.cc
  60. 2
      src/core/lib/channel/channel_stack_builder_impl.cc
  61. 2
      src/core/lib/channel/channelz.cc
  62. 8
      src/core/lib/channel/promise_based_filter.cc
  63. 12
      src/core/lib/http/httpcli.cc
  64. 8
      src/core/lib/http/parser.cc
  65. 4
      src/core/lib/iomgr/call_combiner.cc
  66. 2
      src/core/lib/iomgr/endpoint.h
  67. 4
      src/core/lib/iomgr/endpoint_cfstream.cc
  68. 16
      src/core/lib/iomgr/error.cc
  69. 14
      src/core/lib/iomgr/error.h
  70. 6
      src/core/lib/iomgr/ev_epoll1_linux.cc
  71. 12
      src/core/lib/iomgr/ev_poll_posix.cc
  72. 2
      src/core/lib/iomgr/load_file.cc
  73. 2
      src/core/lib/iomgr/resolve_address_posix.cc
  74. 2
      src/core/lib/iomgr/resolve_address_windows.cc
  75. 4
      src/core/lib/iomgr/tcp_client_cfstream.cc
  76. 20
      src/core/lib/iomgr/tcp_client_posix.cc
  77. 6
      src/core/lib/iomgr/tcp_client_windows.cc
  78. 8
      src/core/lib/iomgr/tcp_posix.cc
  79. 14
      src/core/lib/iomgr/tcp_server_posix.cc
  80. 24
      src/core/lib/iomgr/tcp_server_utils_posix_common.cc
  81. 4
      src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
  82. 14
      src/core/lib/iomgr/tcp_server_windows.cc
  83. 10
      src/core/lib/iomgr/tcp_windows.cc
  84. 4
      src/core/lib/iomgr/unix_sockets_posix.cc
  85. 4
      src/core/lib/iomgr/wakeup_fd_pipe.cc
  86. 2
      src/core/lib/security/authorization/evaluate_args.cc
  87. 2
      src/core/lib/security/authorization/grpc_authorization_policy_provider.cc
  88. 2
      src/core/lib/security/authorization/matchers.cc
  89. 2
      src/core/lib/security/authorization/rbac_translator.cc
  90. 18
      src/core/lib/security/credentials/external/aws_external_account_credentials.cc
  91. 18
      src/core/lib/security/credentials/external/external_account_credentials.cc
  92. 7
      src/core/lib/security/credentials/external/file_external_account_credentials.cc
  93. 8
      src/core/lib/security/credentials/external/url_external_account_credentials.cc
  94. 12
      src/core/lib/security/credentials/google_default/google_default_credentials.cc
  95. 2
      src/core/lib/security/credentials/jwt/jwt_credentials.cc
  96. 4
      src/core/lib/security/credentials/jwt/jwt_verifier.cc
  97. 16
      src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
  98. 5
      src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc
  99. 14
      src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc
  100. 2
      src/core/lib/security/security_connector/load_system_roots_linux.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -216,7 +216,7 @@ ArenaPromise<ServerMetadataHandle> ChannelIdleFilter::MakeCallPromise(
bool ChannelIdleFilter::StartTransportOp(grpc_transport_op* op) { bool ChannelIdleFilter::StartTransportOp(grpc_transport_op* op) {
// Catch the disconnect_with_error transport op. // Catch the disconnect_with_error transport op.
if (op->disconnect_with_error != GRPC_ERROR_NONE) Shutdown(); if (!GRPC_ERROR_IS_NONE(op->disconnect_with_error)) Shutdown();
// Pass the op to the next filter. // Pass the op to the next filter.
return false; return false;
} }

@ -117,7 +117,7 @@ static void g_poller_unref() {
static void run_poller(void* arg, grpc_error_handle error) { static void run_poller(void* arg, grpc_error_handle error) {
backup_poller* p = static_cast<backup_poller*>(arg); backup_poller* p = static_cast<backup_poller*>(arg);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (error != GRPC_ERROR_CANCELLED) { if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("run_poller", GRPC_ERROR_REF(error)); GRPC_LOG_IF_ERROR("run_poller", GRPC_ERROR_REF(error));
} }

@ -179,7 +179,7 @@ class StateWatcher : public DualRefCounted<StateWatcher> {
static void TimeoutComplete(void* arg, grpc_error_handle error) { static void TimeoutComplete(void* arg, grpc_error_handle error) {
auto* self = static_cast<StateWatcher*>(arg); auto* self = static_cast<StateWatcher*>(arg);
self->timer_fired_ = error == GRPC_ERROR_NONE; self->timer_fired_ = GRPC_ERROR_IS_NONE(error);
// If this is a client channel (not a lame channel), cancel the watch. // If this is a client channel (not a lame channel), cancel the watch.
ClientChannel* client_channel = ClientChannel* client_channel =
ClientChannel::GetFromChannel(self->channel_.get()); ClientChannel::GetFromChannel(self->channel_.get());

@ -954,7 +954,7 @@ class ClientChannel::ClientChannelControlHelper
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_) { ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_) {
if (chand_->resolver_ == nullptr) return; // Shutting down. if (chand_->resolver_ == nullptr) return; // Shutting down.
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
const char* extra = chand_->disconnect_error_ == GRPC_ERROR_NONE const char* extra = GRPC_ERROR_IS_NONE(chand_->disconnect_error_)
? "" ? ""
: " (ignoring -- channel shutting down)"; : " (ignoring -- channel shutting down)";
gpr_log(GPR_INFO, "chand=%p: update: state=%s status=(%s) picker=%p%s", gpr_log(GPR_INFO, "chand=%p: update: state=%s status=(%s) picker=%p%s",
@ -962,7 +962,7 @@ class ClientChannel::ClientChannelControlHelper
picker.get(), extra); picker.get(), extra);
} }
// Do update only if not shutting down. // Do update only if not shutting down.
if (chand_->disconnect_error_ == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(chand_->disconnect_error_)) {
chand_->UpdateStateAndPickerLocked(state, status, "helper", chand_->UpdateStateAndPickerLocked(state, status, "helper",
std::move(picker)); std::move(picker));
} }
@ -1080,7 +1080,7 @@ ClientChannel::ClientChannel(grpc_channel_element_args* args,
*error = GRPC_ERROR_NONE; *error = GRPC_ERROR_NONE;
default_service_config_ = default_service_config_ =
ServiceConfigImpl::Create(args->channel_args, service_config_json, error); ServiceConfigImpl::Create(args->channel_args, service_config_json, error);
if (*error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(*error)) {
default_service_config_.reset(); default_service_config_.reset();
return; return;
} }
@ -1213,7 +1213,7 @@ RefCountedPtr<LoadBalancingPolicy::Config> ChooseLbPolicy(
// and accepts an empty config. If not, we revert to using pick_first // and accepts an empty config. If not, we revert to using pick_first
// lb_policy // lb_policy
GPR_ASSERT(lb_policy_config != nullptr); GPR_ASSERT(lb_policy_config != nullptr);
GPR_ASSERT(parse_error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(parse_error));
return lb_policy_config; return lb_policy_config;
} }
@ -1736,7 +1736,7 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
// Ping. // Ping.
if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) { if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
grpc_error_handle error = DoPingLocked(op); grpc_error_handle error = DoPingLocked(op);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_initiate, ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_initiate,
GRPC_ERROR_REF(error)); GRPC_ERROR_REF(error));
ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_ack, error); ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_ack, error);
@ -1752,7 +1752,7 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
} }
} }
// Disconnect or enter IDLE. // Disconnect or enter IDLE.
if (op->disconnect_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->disconnect_with_error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: disconnect_with_error: %s", this, gpr_log(GPR_INFO, "chand=%p: disconnect_with_error: %s", this,
grpc_error_std_string(op->disconnect_with_error).c_str()); grpc_error_std_string(op->disconnect_with_error).c_str());
@ -1762,7 +1762,7 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
if (grpc_error_get_int(op->disconnect_with_error, if (grpc_error_get_int(op->disconnect_with_error,
GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, &value) && GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, &value) &&
static_cast<grpc_connectivity_state>(value) == GRPC_CHANNEL_IDLE) { static_cast<grpc_connectivity_state>(value) == GRPC_CHANNEL_IDLE) {
if (disconnect_error_ == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(disconnect_error_)) {
// Enter IDLE state. // Enter IDLE state.
UpdateStateAndPickerLocked(GRPC_CHANNEL_IDLE, absl::Status(), UpdateStateAndPickerLocked(GRPC_CHANNEL_IDLE, absl::Status(),
"channel entering IDLE", nullptr); "channel entering IDLE", nullptr);
@ -1770,7 +1770,7 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
GRPC_ERROR_UNREF(op->disconnect_with_error); GRPC_ERROR_UNREF(op->disconnect_with_error);
} else { } else {
// Disconnect. // Disconnect.
GPR_ASSERT(disconnect_error_ == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(disconnect_error_));
disconnect_error_ = op->disconnect_with_error; disconnect_error_ = op->disconnect_with_error;
UpdateStateAndPickerLocked( UpdateStateAndPickerLocked(
GRPC_CHANNEL_SHUTDOWN, absl::Status(), "shutdown from API", GRPC_CHANNEL_SHUTDOWN, absl::Status(), "shutdown from API",
@ -1965,7 +1965,7 @@ void ClientChannel::CallData::StartTransportStreamOpBatch(
// We do not yet have a dynamic call. // We do not yet have a dynamic call.
// //
// If we've previously been cancelled, immediately fail any new batches. // If we've previously been cancelled, immediately fail any new batches.
if (GPR_UNLIKELY(calld->cancel_error_ != GRPC_ERROR_NONE)) { if (GPR_UNLIKELY(!GRPC_ERROR_IS_NONE(calld->cancel_error_))) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s", gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s",
chand, calld, chand, calld,
@ -2077,7 +2077,7 @@ void ClientChannel::CallData::FailPendingBatchInCallCombiner(
void ClientChannel::CallData::PendingBatchesFail( void ClientChannel::CallData::PendingBatchesFail(
grpc_call_element* elem, grpc_error_handle error, grpc_call_element* elem, grpc_error_handle error,
YieldCallCombinerPredicate yield_call_combiner_predicate) { YieldCallCombinerPredicate yield_call_combiner_predicate) {
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
size_t num_batches = 0; size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
@ -2181,7 +2181,8 @@ class ClientChannel::CallData::ResolverQueuedCallCanceller {
chand, calld, grpc_error_std_string(error).c_str(), self, chand, calld, grpc_error_std_string(error).c_str(), self,
calld->resolver_call_canceller_); calld->resolver_call_canceller_);
} }
if (calld->resolver_call_canceller_ == self && error != GRPC_ERROR_NONE) { if (calld->resolver_call_canceller_ == self &&
!GRPC_ERROR_IS_NONE(error)) {
// Remove pick from list of queued picks. // Remove pick from list of queued picks.
calld->MaybeRemoveCallFromResolverQueuedCallsLocked(self->elem_); calld->MaybeRemoveCallFromResolverQueuedCallsLocked(self->elem_);
// Fail pending batches on the call. // Fail pending batches on the call.
@ -2239,7 +2240,7 @@ grpc_error_handle ClientChannel::CallData::ApplyServiceConfigToCallLocked(
// Use the ConfigSelector to determine the config for the call. // Use the ConfigSelector to determine the config for the call.
ConfigSelector::CallConfig call_config = ConfigSelector::CallConfig call_config =
config_selector->GetCallConfig({&path_, initial_metadata, arena_}); config_selector->GetCallConfig({&path_, initial_metadata, arena_});
if (call_config.error != GRPC_ERROR_NONE) return call_config.error; if (!GRPC_ERROR_IS_NONE(call_config.error)) return call_config.error;
// Create a ClientChannelServiceConfigCallData for the call. This stores // Create a ClientChannelServiceConfigCallData for the call. This stores
// a ref to the ServiceConfig and caches the right set of parsed configs // a ref to the ServiceConfig and caches the right set of parsed configs
// to use for the call. The ClientChannelServiceConfigCallData will store // to use for the call. The ClientChannelServiceConfigCallData will store
@ -2324,7 +2325,7 @@ void ClientChannel::CallData::ResolutionDone(void* arg,
grpc_call_element* elem = static_cast<grpc_call_element*>(arg); grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
ClientChannel* chand = static_cast<ClientChannel*>(elem->channel_data); ClientChannel* chand = static_cast<ClientChannel*>(elem->channel_data);
CallData* calld = static_cast<CallData*>(elem->call_data); CallData* calld = static_cast<CallData*>(elem->call_data);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"chand=%p calld=%p: error applying config to call: error=%s", "chand=%p calld=%p: error applying config to call: error=%s",
@ -2443,7 +2444,7 @@ void ClientChannel::CallData::CreateDynamicCall(grpc_call_element* elem) {
chand, this, channel_stack); chand, this, channel_stack);
} }
dynamic_call_ = channel_stack->CreateCall(std::move(args), &error); dynamic_call_ = channel_stack->CreateCall(std::move(args), &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"chand=%p calld=%p: failed to create dynamic call: error=%s", "chand=%p calld=%p: failed to create dynamic call: error=%s",
@ -2703,7 +2704,7 @@ void ClientChannel::LoadBalancedCall::FailPendingBatchInCallCombiner(
void ClientChannel::LoadBalancedCall::PendingBatchesFail( void ClientChannel::LoadBalancedCall::PendingBatchesFail(
grpc_error_handle error, grpc_error_handle error,
YieldCallCombinerPredicate yield_call_combiner_predicate) { YieldCallCombinerPredicate yield_call_combiner_predicate) {
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
GRPC_ERROR_UNREF(failure_error_); GRPC_ERROR_UNREF(failure_error_);
failure_error_ = error; failure_error_ = error;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
@ -2859,7 +2860,7 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch(
// We do not yet have a subchannel call. // We do not yet have a subchannel call.
// //
// If we've previously been cancelled, immediately fail any new batches. // If we've previously been cancelled, immediately fail any new batches.
if (GPR_UNLIKELY(cancel_error_ != GRPC_ERROR_NONE)) { if (GPR_UNLIKELY(!GRPC_ERROR_IS_NONE(cancel_error_))) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: failing batch with error: %s", gpr_log(GPR_INFO, "chand=%p lb_call=%p: failing batch with error: %s",
chand_, this, grpc_error_std_string(cancel_error_).c_str()); chand_, this, grpc_error_std_string(cancel_error_).c_str());
@ -2936,7 +2937,7 @@ void ClientChannel::LoadBalancedCall::RecvInitialMetadataReady(
"chand=%p lb_call=%p: got recv_initial_metadata_ready: error=%s", "chand=%p lb_call=%p: got recv_initial_metadata_ready: error=%s",
self->chand_, self, grpc_error_std_string(error).c_str()); self->chand_, self, grpc_error_std_string(error).c_str());
} }
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
// recv_initial_metadata_flags is not populated for clients // recv_initial_metadata_flags is not populated for clients
self->call_attempt_tracer_->RecordReceivedInitialMetadata( self->call_attempt_tracer_->RecordReceivedInitialMetadata(
self->recv_initial_metadata_, 0 /* recv_initial_metadata_flags */); self->recv_initial_metadata_, 0 /* recv_initial_metadata_flags */);
@ -2976,7 +2977,7 @@ void ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(
self->lb_subchannel_call_tracker_ != nullptr) { self->lb_subchannel_call_tracker_ != nullptr) {
// Get the call's status. // Get the call's status.
absl::Status status; absl::Status status;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// Get status from error. // Get status from error.
grpc_status_code code; grpc_status_code code;
std::string message; std::string message;
@ -2999,7 +3000,7 @@ void ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(
self->RecordCallCompletion(status); self->RecordCallCompletion(status);
} }
// Chain to original callback. // Chain to original callback.
if (self->failure_error_ != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(self->failure_error_)) {
error = self->failure_error_; error = self->failure_error_;
self->failure_error_ = GRPC_ERROR_NONE; self->failure_error_ = GRPC_ERROR_NONE;
} else { } else {
@ -3046,7 +3047,7 @@ void ClientChannel::LoadBalancedCall::CreateSubchannelCall() {
subchannel_call_->SetAfterCallStackDestroy(on_call_destruction_complete_); subchannel_call_->SetAfterCallStackDestroy(on_call_destruction_complete_);
on_call_destruction_complete_ = nullptr; on_call_destruction_complete_ = nullptr;
} }
if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { if (GPR_UNLIKELY(!GRPC_ERROR_IS_NONE(error))) {
PendingBatchesFail(error, YieldCallCombiner); PendingBatchesFail(error, YieldCallCombiner);
} else { } else {
PendingBatchesResume(); PendingBatchesResume();
@ -3083,7 +3084,7 @@ class ClientChannel::LoadBalancedCall::LbQueuedCallCanceller {
chand, lb_call, grpc_error_std_string(error).c_str(), self, chand, lb_call, grpc_error_std_string(error).c_str(), self,
lb_call->lb_call_canceller_); lb_call->lb_call_canceller_);
} }
if (lb_call->lb_call_canceller_ == self && error != GRPC_ERROR_NONE) { if (lb_call->lb_call_canceller_ == self && !GRPC_ERROR_IS_NONE(error)) {
lb_call->call_dispatch_controller_->Commit(); lb_call->call_dispatch_controller_->Commit();
// Remove pick from list of queued picks. // Remove pick from list of queued picks.
lb_call->MaybeRemoveCallFromLbQueuedCallsLocked(); lb_call->MaybeRemoveCallFromLbQueuedCallsLocked();
@ -3134,7 +3135,7 @@ void ClientChannel::LoadBalancedCall::AsyncPickDone(grpc_error_handle error) {
void ClientChannel::LoadBalancedCall::PickDone(void* arg, void ClientChannel::LoadBalancedCall::PickDone(void* arg,
grpc_error_handle error) { grpc_error_handle error) {
auto* self = static_cast<LoadBalancedCall*>(arg); auto* self = static_cast<LoadBalancedCall*>(arg);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"chand=%p lb_call=%p: failed to pick subchannel: error=%s", "chand=%p lb_call=%p: failed to pick subchannel: error=%s",

@ -63,7 +63,7 @@ DynamicFilters::Call::Call(Args args, grpc_error_handle* error)
}; };
*error = grpc_call_stack_init(channel_stack_->channel_stack_, 1, Destroy, *error = grpc_call_stack_init(channel_stack_->channel_stack_, 1, Destroy,
this, &call_args); this, &call_args);
if (GPR_UNLIKELY(*error != GRPC_ERROR_NONE)) { if (GPR_UNLIKELY(!GRPC_ERROR_IS_NONE(*error))) {
gpr_log(GPR_ERROR, "error: %s", grpc_error_std_string(*error).c_str()); gpr_log(GPR_ERROR, "error: %s", grpc_error_std_string(*error).c_str());
return; return;
} }
@ -152,7 +152,7 @@ std::pair<grpc_channel_stack*, grpc_error_handle> CreateChannelStack(
grpc_error_handle error = grpc_channel_stack_init( grpc_error_handle error = grpc_channel_stack_init(
/*initial_refs=*/1, DestroyChannelStack, channel_stack, filters.data(), /*initial_refs=*/1, DestroyChannelStack, channel_stack, filters.data(),
filters.size(), args, "DynamicFilters", channel_stack); filters.size(), args, "DynamicFilters", channel_stack);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "error initializing client internal stack: %s", gpr_log(GPR_ERROR, "error initializing client internal stack: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
grpc_channel_stack_destroy(channel_stack); grpc_channel_stack_destroy(channel_stack);
@ -169,7 +169,7 @@ RefCountedPtr<DynamicFilters> DynamicFilters::Create(
std::vector<const grpc_channel_filter*> filters) { std::vector<const grpc_channel_filter*> filters) {
// Attempt to create channel stack from requested filters. // Attempt to create channel stack from requested filters.
auto p = CreateChannelStack(args, std::move(filters)); auto p = CreateChannelStack(args, std::move(filters));
if (p.second != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(p.second)) {
// Channel stack creation failed with requested filters. // Channel stack creation failed with requested filters.
// Create with lame filter instead. // Create with lame filter instead.
grpc_error_handle error = p.second; grpc_error_handle error = p.second;
@ -178,7 +178,7 @@ RefCountedPtr<DynamicFilters> DynamicFilters::Create(
grpc_channel_args_copy_and_add(args, &error_arg, 1); grpc_channel_args_copy_and_add(args, &error_arg, 1);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
p = CreateChannelStack(new_args, {&LameClientFilter::kFilter}); p = CreateChannelStack(new_args, {&LameClientFilter::kFilter});
GPR_ASSERT(p.second == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(p.second));
grpc_channel_args_destroy(new_args); grpc_channel_args_destroy(new_args);
} }
return MakeRefCounted<DynamicFilters>(p.first); return MakeRefCounted<DynamicFilters>(p.first);

@ -61,7 +61,7 @@ struct call_data {
static void on_complete_for_send(void* arg, grpc_error_handle error) { static void on_complete_for_send(void* arg, grpc_error_handle error) {
call_data* calld = static_cast<call_data*>(arg); call_data* calld = static_cast<call_data*>(arg);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
calld->send_initial_metadata_succeeded = true; calld->send_initial_metadata_succeeded = true;
} }
grpc_core::Closure::Run(DEBUG_LOCATION, calld->original_on_complete_for_send, grpc_core::Closure::Run(DEBUG_LOCATION, calld->original_on_complete_for_send,
@ -70,7 +70,7 @@ static void on_complete_for_send(void* arg, grpc_error_handle error) {
static void recv_initial_metadata_ready(void* arg, grpc_error_handle error) { static void recv_initial_metadata_ready(void* arg, grpc_error_handle error) {
call_data* calld = static_cast<call_data*>(arg); call_data* calld = static_cast<call_data*>(arg);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
calld->recv_initial_metadata_succeeded = true; calld->recv_initial_metadata_succeeded = true;
} }
grpc_core::Closure::Run(DEBUG_LOCATION, grpc_core::Closure::Run(DEBUG_LOCATION,

@ -1089,7 +1089,7 @@ void GrpcLb::BalancerCallState::ClientLoadReportDoneLocked(
grpc_error_handle error) { grpc_error_handle error) {
grpc_byte_buffer_destroy(send_message_payload_); grpc_byte_buffer_destroy(send_message_payload_);
send_message_payload_ = nullptr; send_message_payload_ = nullptr;
if (error != GRPC_ERROR_NONE || this != grpclb_policy()->lb_calld_.get()) { if (!GRPC_ERROR_IS_NONE(error) || this != grpclb_policy()->lb_calld_.get()) {
Unref(DEBUG_LOCATION, "client_load_report"); Unref(DEBUG_LOCATION, "client_load_report");
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return; return;
@ -1675,7 +1675,7 @@ void GrpcLb::OnBalancerCallRetryTimer(void* arg, grpc_error_handle error) {
void GrpcLb::OnBalancerCallRetryTimerLocked(grpc_error_handle error) { void GrpcLb::OnBalancerCallRetryTimerLocked(grpc_error_handle error) {
retry_timer_callback_pending_ = false; retry_timer_callback_pending_ = false;
if (!shutting_down_ && error == GRPC_ERROR_NONE && lb_calld_ == nullptr) { if (!shutting_down_ && GRPC_ERROR_IS_NONE(error) && lb_calld_ == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", this); gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", this);
} }
@ -1719,7 +1719,7 @@ void GrpcLb::OnFallbackTimerLocked(grpc_error_handle error) {
// If we receive a serverlist after the timer fires but before this callback // If we receive a serverlist after the timer fires but before this callback
// actually runs, don't fall back. // actually runs, don't fall back.
if (fallback_at_startup_checks_pending_ && !shutting_down_ && if (fallback_at_startup_checks_pending_ && !shutting_down_ &&
error == GRPC_ERROR_NONE) { GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[grpclb %p] No response from balancer after fallback timeout; " "[grpclb %p] No response from balancer after fallback timeout; "
"entering fallback mode", "entering fallback mode",
@ -1840,7 +1840,7 @@ void GrpcLb::OnSubchannelCacheTimer(void* arg, grpc_error_handle error) {
} }
void GrpcLb::OnSubchannelCacheTimerLocked(grpc_error_handle error) { void GrpcLb::OnSubchannelCacheTimerLocked(grpc_error_handle error) {
if (subchannel_cache_timer_pending_ && error == GRPC_ERROR_NONE) { if (subchannel_cache_timer_pending_ && GRPC_ERROR_IS_NONE(error)) {
auto it = cached_subchannels_.begin(); auto it = cached_subchannels_.begin();
if (it != cached_subchannels_.end()) { if (it != cached_subchannels_.end()) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
@ -1875,7 +1875,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
return MakeRefCounted<GrpcLbConfig>(nullptr, ""); return MakeRefCounted<GrpcLbConfig>(nullptr, "");
} }
@ -1906,7 +1906,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_config = RefCountedPtr<LoadBalancingPolicy::Config> child_policy_config =
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
*child_policy_config_json, &parse_error); *child_policy_config_json, &parse_error);
if (parse_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parse_error)) {
std::vector<grpc_error_handle> child_errors; std::vector<grpc_error_handle> child_errors;
child_errors.push_back(parse_error); child_errors.push_back(parse_error);
error_list.push_back( error_list.push_back(

@ -784,7 +784,7 @@ void OutlierDetectionLb::EjectionTimer::OnTimer(void* arg,
} }
void OutlierDetectionLb::EjectionTimer::OnTimerLocked(grpc_error_handle error) { void OutlierDetectionLb::EjectionTimer::OnTimerLocked(grpc_error_handle error) {
if (error == GRPC_ERROR_NONE && timer_pending_) { if (GRPC_ERROR_IS_NONE(error) && timer_pending_) {
std::map<SubchannelState*, double> success_rate_ejection_candidates; std::map<SubchannelState*, double> success_rate_ejection_candidates;
std::map<SubchannelState*, double> failure_percentage_ejection_candidates; std::map<SubchannelState*, double> failure_percentage_ejection_candidates;
size_t ejected_host_count = 0; size_t ejected_host_count = 0;
@ -917,7 +917,7 @@ class OutlierDetectionLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// This policy was configured in the deprecated loadBalancingPolicy // This policy was configured in the deprecated loadBalancingPolicy
// field or in the client API. // field or in the client API.
@ -1001,7 +1001,7 @@ class OutlierDetectionLbFactory : public LoadBalancingPolicyFactory {
child_policy = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( child_policy = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
it->second, &parse_error); it->second, &parse_error);
if (child_policy == nullptr) { if (child_policy == nullptr) {
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(parse_error));
std::vector<grpc_error_handle> child_errors; std::vector<grpc_error_handle> child_errors;
child_errors.push_back(parse_error); child_errors.push_back(parse_error);
error_list.push_back( error_list.push_back(

@ -646,7 +646,7 @@ void PriorityLb::ChildPriority::DeactivationTimer::OnTimer(
void PriorityLb::ChildPriority::DeactivationTimer::OnTimerLocked( void PriorityLb::ChildPriority::DeactivationTimer::OnTimerLocked(
grpc_error_handle error) { grpc_error_handle error) {
if (error == GRPC_ERROR_NONE && timer_pending_) { if (GRPC_ERROR_IS_NONE(error) && timer_pending_) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_priority_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_priority_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[priority_lb %p] child %s (%p): deactivation timer fired, " "[priority_lb %p] child %s (%p): deactivation timer fired, "
@ -710,7 +710,7 @@ void PriorityLb::ChildPriority::FailoverTimer::OnTimer(
void PriorityLb::ChildPriority::FailoverTimer::OnTimerLocked( void PriorityLb::ChildPriority::FailoverTimer::OnTimerLocked(
grpc_error_handle error) { grpc_error_handle error) {
if (error == GRPC_ERROR_NONE && timer_pending_) { if (GRPC_ERROR_IS_NONE(error) && timer_pending_) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_priority_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_priority_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[priority_lb %p] child %s (%p): failover timer fired, " "[priority_lb %p] child %s (%p): failover timer fired, "
@ -933,7 +933,7 @@ class PriorityLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// priority was mentioned as a policy in the deprecated // priority was mentioned as a policy in the deprecated
// loadBalancingPolicy field or in the client API. // loadBalancingPolicy field or in the client API.
@ -988,7 +988,7 @@ class PriorityLbFactory : public LoadBalancingPolicyFactory {
} }
} }
if (config == nullptr) { if (config == nullptr) {
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(parse_error));
error_list.push_back( error_list.push_back(
GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING( GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(
absl::StrCat("field:children key:", child_name).c_str(), absl::StrCat("field:children key:", child_name).c_str(),

@ -783,7 +783,7 @@ void RlsLb::ChildPolicyWrapper::StartUpdate() {
grpc_error_handle error = InsertOrUpdateChildPolicyField( grpc_error_handle error = InsertOrUpdateChildPolicyField(
lb_policy_->config_->child_policy_config_target_field_name(), target_, lb_policy_->config_->child_policy_config_target_field_name(), target_,
&child_policy_config); &child_policy_config);
GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(error));
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) {
gpr_log( gpr_log(
GPR_INFO, GPR_INFO,
@ -794,7 +794,7 @@ void RlsLb::ChildPolicyWrapper::StartUpdate() {
pending_config_ = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( pending_config_ = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
child_policy_config, &error); child_policy_config, &error);
// Returned RLS target fails the validation. // Returned RLS target fails the validation.
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[rlslb %p] ChildPolicyWrapper=%p [%s]: config failed to parse: " "[rlslb %p] ChildPolicyWrapper=%p [%s]: config failed to parse: "
@ -1777,7 +1777,7 @@ void RlsLb::RlsRequest::OnRlsCallCompleteLocked(grpc_error_handle error) {
} }
// Parse response. // Parse response.
ResponseInfo response; ResponseInfo response;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_status_code code; grpc_status_code code;
std::string message; std::string message;
grpc_error_get_status(error, deadline_, &code, &message, grpc_error_get_status(error, deadline_, &code, &message,
@ -2231,7 +2231,7 @@ grpc_error_handle ParseGrpcKeybuilder(
grpc_error_handle child_error = GRPC_ERROR_NONE; grpc_error_handle child_error = GRPC_ERROR_NONE;
std::string name = std::string name =
ParseJsonMethodName(name_idx++, name_json, &child_error); ParseJsonMethodName(name_idx++, name_json, &child_error);
if (child_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(child_error)) {
error_list.push_back(child_error); error_list.push_back(child_error);
} else { } else {
bool inserted = names.insert(name).second; bool inserted = names.insert(name).second;
@ -2267,7 +2267,7 @@ grpc_error_handle ParseGrpcKeybuilder(
std::vector<std::string> headers; std::vector<std::string> headers;
grpc_error_handle child_error = grpc_error_handle child_error =
ParseJsonHeaders(header_idx++, header_json, &key, &headers); ParseJsonHeaders(header_idx++, header_json, &key, &headers);
if (child_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(child_error)) {
error_list.push_back(child_error); error_list.push_back(child_error);
} else { } else {
duplicate_key_check_func(key); duplicate_key_check_func(key);
@ -2360,7 +2360,7 @@ RlsLbConfig::KeyBuilderMap ParseGrpcKeybuilders(
for (const Json& key_builder : key_builder_list) { for (const Json& key_builder : key_builder_list) {
grpc_error_handle child_error = grpc_error_handle child_error =
ParseGrpcKeybuilder(idx++, key_builder, &key_builder_map); ParseGrpcKeybuilder(idx++, key_builder, &key_builder_map);
if (child_error != GRPC_ERROR_NONE) error_list.push_back(child_error); if (!GRPC_ERROR_IS_NONE(child_error)) error_list.push_back(child_error);
} }
*error = GRPC_ERROR_CREATE_FROM_VECTOR("field:grpcKeybuilders", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("field:grpcKeybuilders", &error_list);
return key_builder_map; return key_builder_map;
@ -2377,7 +2377,7 @@ RlsLbConfig::RouteLookupConfig ParseRouteLookupConfig(
grpc_error_handle child_error = GRPC_ERROR_NONE; grpc_error_handle child_error = GRPC_ERROR_NONE;
route_lookup_config.key_builder_map = route_lookup_config.key_builder_map =
ParseGrpcKeybuilders(*keybuilder_list, &child_error); ParseGrpcKeybuilders(*keybuilder_list, &child_error);
if (child_error != GRPC_ERROR_NONE) error_list.push_back(child_error); if (!GRPC_ERROR_IS_NONE(child_error)) error_list.push_back(child_error);
} }
// Parse lookupService. // Parse lookupService.
if (ParseJsonObjectField(json, "lookupService", if (ParseJsonObjectField(json, "lookupService",
@ -2453,12 +2453,12 @@ grpc_error_handle ValidateChildPolicyList(
default_target.empty() ? kFakeTargetFieldValue : default_target; default_target.empty() ? kFakeTargetFieldValue : default_target;
grpc_error_handle error = InsertOrUpdateChildPolicyField( grpc_error_handle error = InsertOrUpdateChildPolicyField(
child_policy_config_target_field_name, target, child_policy_config); child_policy_config_target_field_name, target, child_policy_config);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
// Parse the config. // Parse the config.
RefCountedPtr<LoadBalancingPolicy::Config> parsed_config = RefCountedPtr<LoadBalancingPolicy::Config> parsed_config =
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
*child_policy_config, &error); *child_policy_config, &error);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
// Find the chosen config and return it in JSON form. // Find the chosen config and return it in JSON form.
// We remove all non-selected configs, and in the selected config, we leave // We remove all non-selected configs, and in the selected config, we leave
// the target field in place, set to the default value. This slightly // the target field in place, set to the default value. This slightly
@ -2501,7 +2501,7 @@ class RlsLbFactory : public LoadBalancingPolicyFactory {
grpc_error_handle child_error = GRPC_ERROR_NONE; grpc_error_handle child_error = GRPC_ERROR_NONE;
route_lookup_config = route_lookup_config =
ParseRouteLookupConfig(*route_lookup_config_json, &child_error); ParseRouteLookupConfig(*route_lookup_config_json, &child_error);
if (child_error != GRPC_ERROR_NONE) error_list.push_back(child_error); if (!GRPC_ERROR_IS_NONE(child_error)) error_list.push_back(child_error);
} }
// Parse routeLookupChannelServiceConfig. // Parse routeLookupChannelServiceConfig.
std::string rls_channel_service_config; std::string rls_channel_service_config;
@ -2517,7 +2517,7 @@ class RlsLbFactory : public LoadBalancingPolicyFactory {
auto service_config = MakeRefCounted<ServiceConfigImpl>( auto service_config = MakeRefCounted<ServiceConfigImpl>(
/*args=*/nullptr, rls_channel_service_config, /*args=*/nullptr, rls_channel_service_config,
std::move(rls_channel_service_config_json), &child_error); std::move(rls_channel_service_config_json), &child_error);
if (child_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(child_error)) {
error_list.push_back(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( error_list.push_back(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"field:routeLookupChannelServiceConfig", &child_error, 1)); "field:routeLookupChannelServiceConfig", &child_error, 1));
GRPC_ERROR_UNREF(child_error); GRPC_ERROR_UNREF(child_error);
@ -2549,7 +2549,7 @@ class RlsLbFactory : public LoadBalancingPolicyFactory {
it->second, child_policy_config_target_field_name, it->second, child_policy_config_target_field_name,
route_lookup_config.default_target, &child_policy_config, route_lookup_config.default_target, &child_policy_config,
&default_child_policy_parsed_config); &default_child_policy_parsed_config);
if (child_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(child_error)) {
error_list.push_back(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( error_list.push_back(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"field:childPolicy", &child_error, 1)); "field:childPolicy", &child_error, 1));
GRPC_ERROR_UNREF(child_error); GRPC_ERROR_UNREF(child_error);

@ -476,7 +476,7 @@ void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::OnTimer(
void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::OnTimerLocked( void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::OnTimerLocked(
grpc_error_handle error) { grpc_error_handle error) {
if (error == GRPC_ERROR_NONE && timer_pending_) { if (GRPC_ERROR_IS_NONE(error) && timer_pending_) {
timer_pending_ = false; timer_pending_ = false;
weighted_child_->weighted_target_policy_->targets_.erase( weighted_child_->weighted_target_policy_->targets_.erase(
weighted_child_->name_); weighted_child_->name_);
@ -695,7 +695,7 @@ class WeightedTargetLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// weighted_target was mentioned as a policy in the deprecated // weighted_target was mentioned as a policy in the deprecated
// loadBalancingPolicy field or in the client API. // loadBalancingPolicy field or in the client API.
@ -773,7 +773,7 @@ class WeightedTargetLbFactory : public LoadBalancingPolicyFactory {
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(it->second, LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(it->second,
&parse_error); &parse_error);
if (child_config->config == nullptr) { if (child_config->config == nullptr) {
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(parse_error));
std::vector<grpc_error_handle> child_errors; std::vector<grpc_error_handle> child_errors;
child_errors.push_back(parse_error); child_errors.push_back(parse_error);
error_list.push_back( error_list.push_back(

@ -521,7 +521,7 @@ void CdsLb::OnClusterChanged(const std::string& name,
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
RefCountedPtr<LoadBalancingPolicy::Config> config = RefCountedPtr<LoadBalancingPolicy::Config> config =
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error); LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
OnError(name, absl::UnavailableError(grpc_error_std_string(error))); OnError(name, absl::UnavailableError(grpc_error_std_string(error)));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return; return;
@ -733,7 +733,7 @@ class CdsLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// xds was mentioned as a policy in the deprecated loadBalancingPolicy // xds was mentioned as a policy in the deprecated loadBalancingPolicy
// field or in the client API. // field or in the client API.

@ -708,7 +708,7 @@ class XdsClusterImplLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// This policy was configured in the deprecated loadBalancingPolicy // This policy was configured in the deprecated loadBalancingPolicy
// field or in the client API. // field or in the client API.
@ -730,7 +730,7 @@ class XdsClusterImplLbFactory : public LoadBalancingPolicyFactory {
child_policy = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( child_policy = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
it->second, &parse_error); it->second, &parse_error);
if (child_policy == nullptr) { if (child_policy == nullptr) {
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(parse_error));
std::vector<grpc_error_handle> child_errors; std::vector<grpc_error_handle> child_errors;
child_errors.push_back(parse_error); child_errors.push_back(parse_error);
error_list.push_back( error_list.push_back(
@ -771,7 +771,7 @@ class XdsClusterImplLbFactory : public LoadBalancingPolicyFactory {
grpc_error_handle parser_error; grpc_error_handle parser_error;
lrs_load_reporting_server = XdsBootstrap::XdsServer::Parse( lrs_load_reporting_server = XdsBootstrap::XdsServer::Parse(
it->second.object_value(), &parser_error); it->second.object_value(), &parser_error);
if (parser_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parser_error)) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING( error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrCat("errors parsing lrs_load_reporting_server"))); absl::StrCat("errors parsing lrs_load_reporting_server")));
error_list.push_back(parser_error); error_list.push_back(parser_error);

@ -535,7 +535,7 @@ void XdsClusterManagerLb::ClusterChild::OnDelayedRemovalTimer(
void XdsClusterManagerLb::ClusterChild::OnDelayedRemovalTimerLocked( void XdsClusterManagerLb::ClusterChild::OnDelayedRemovalTimerLocked(
grpc_error_handle error) { grpc_error_handle error) {
delayed_removal_timer_callback_pending_ = false; delayed_removal_timer_callback_pending_ = false;
if (error == GRPC_ERROR_NONE && !shutdown_) { if (GRPC_ERROR_IS_NONE(error) && !shutdown_) {
xds_cluster_manager_policy_->children_.erase(name_); xds_cluster_manager_policy_->children_.erase(name_);
} }
Unref(DEBUG_LOCATION, "ClusterChild+timer"); Unref(DEBUG_LOCATION, "ClusterChild+timer");
@ -634,7 +634,7 @@ class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// xds_cluster_manager was mentioned as a policy in the deprecated // xds_cluster_manager was mentioned as a policy in the deprecated
// loadBalancingPolicy field or in the client API. // loadBalancingPolicy field or in the client API.
@ -705,7 +705,7 @@ class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory {
*child_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( *child_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
it->second, &parse_error); it->second, &parse_error);
if (*child_config == nullptr) { if (*child_config == nullptr) {
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(parse_error));
std::vector<grpc_error_handle> child_errors; std::vector<grpc_error_handle> child_errors;
child_errors.push_back(parse_error); child_errors.push_back(parse_error);
error_list.push_back( error_list.push_back(

@ -933,7 +933,7 @@ XdsClusterResolverLb::CreateChildPolicyConfigLocked() {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
RefCountedPtr<LoadBalancingPolicy::Config> config = RefCountedPtr<LoadBalancingPolicy::Config> config =
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error); LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// This should never happen, but if it does, we basically have no // This should never happen, but if it does, we basically have no
// way to fix it, so we put the channel in TRANSIENT_FAILURE. // way to fix it, so we put the channel in TRANSIENT_FAILURE.
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
@ -1032,7 +1032,7 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) const override { const Json& json, grpc_error_handle* error) const override {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (json.type() == Json::Type::JSON_NULL) { if (json.type() == Json::Type::JSON_NULL) {
// xds_cluster_resolver was mentioned as a policy in the deprecated // xds_cluster_resolver was mentioned as a policy in the deprecated
// loadBalancingPolicy field or in the client API. // loadBalancingPolicy field or in the client API.
@ -1152,7 +1152,7 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
grpc_error_handle parse_error; grpc_error_handle parse_error;
discovery_mechanism->lrs_load_reporting_server.emplace( discovery_mechanism->lrs_load_reporting_server.emplace(
XdsBootstrap::XdsServer::Parse(it->second, &parse_error)); XdsBootstrap::XdsServer::Parse(it->second, &parse_error));
if (parse_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parse_error)) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING( error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrCat("errors parsing lrs_load_reporting_server"))); absl::StrCat("errors parsing lrs_load_reporting_server")));
error_list.push_back(parse_error); error_list.push_back(parse_error);

@ -170,11 +170,11 @@ grpc_error_handle ParseLoadBalancingConfigHelper(
RefCountedPtr<LoadBalancingPolicy::Config> RefCountedPtr<LoadBalancingPolicy::Config>
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
const Json& json, grpc_error_handle* error) { const Json& json, grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
GPR_ASSERT(g_state != nullptr); GPR_ASSERT(g_state != nullptr);
Json::Object::const_iterator policy; Json::Object::const_iterator policy;
*error = ParseLoadBalancingConfigHelper(json, &policy); *error = ParseLoadBalancingConfigHelper(json, &policy);
if (*error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(*error)) {
return nullptr; return nullptr;
} }
// Find factory. // Find factory.

@ -126,7 +126,7 @@ class BinderResolverFactory : public ResolverFactory {
return false; return false;
} }
grpc_error_handle error = BinderAddrPopulate(uri.path(), &addr); grpc_error_handle error = BinderAddrPopulate(uri.path(), &addr);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str()); gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return false; return false;

@ -200,7 +200,7 @@ bool ValueInJsonArray(const Json::Array& array, const char* value) {
std::string ChooseServiceConfig(char* service_config_choice_json, std::string ChooseServiceConfig(char* service_config_choice_json,
grpc_error_handle* error) { grpc_error_handle* error) {
Json json = Json::Parse(service_config_choice_json, error); Json json = Json::Parse(service_config_choice_json, error);
if (*error != GRPC_ERROR_NONE) return ""; if (!GRPC_ERROR_IS_NONE(*error)) return "";
if (json.type() != Json::Type::ARRAY) { if (json.type() != Json::Type::ARRAY) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Service Config Choices, error: should be of type array"); "Service Config Choices, error: should be of type array");
@ -300,7 +300,7 @@ void AresClientChannelDNSResolver::AresRequestWrapper::OnResolved(
std::string service_config_string = std::string service_config_string =
ChooseServiceConfig(service_config_json_, &service_config_error); ChooseServiceConfig(service_config_json_, &service_config_error);
RefCountedPtr<ServiceConfig> service_config; RefCountedPtr<ServiceConfig> service_config;
if (service_config_error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(service_config_error) &&
!service_config_string.empty()) { !service_config_string.empty()) {
GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s", GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s",
this, service_config_string.c_str()); this, service_config_string.c_str());
@ -308,7 +308,7 @@ void AresClientChannelDNSResolver::AresRequestWrapper::OnResolved(
service_config_string, service_config_string,
&service_config_error); &service_config_error);
} }
if (service_config_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(service_config_error)) {
result.service_config = absl::UnavailableError( result.service_config = absl::UnavailableError(
absl::StrCat("failed to parse service config: ", absl::StrCat("failed to parse service config: ",
grpc_error_std_string(service_config_error))); grpc_error_std_string(service_config_error)));
@ -438,7 +438,7 @@ class AresDNSResolver : public DNSResolver {
} }
grpc_pollset_set_del_pollset_set(request->pollset_set_, grpc_pollset_set_del_pollset_set(request->pollset_set_,
request->interested_parties_); request->interested_parties_);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
request->on_resolve_address_done_(grpc_error_to_absl_status(error)); request->on_resolve_address_done_(grpc_error_to_absl_status(error));
return; return;
} }
@ -563,7 +563,7 @@ void grpc_resolver_dns_ares_init() {
if (grpc_core::UseAresDnsResolver()) { if (grpc_core::UseAresDnsResolver()) {
address_sorting_init(); address_sorting_init();
grpc_error_handle error = grpc_ares_init(); grpc_error_handle error = grpc_ares_init();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
GRPC_LOG_IF_ERROR("grpc_ares_init() failed", error); GRPC_LOG_IF_ERROR("grpc_ares_init() failed", error);
return; return;
} }

@ -435,7 +435,7 @@ class GrpcPolledFdWindows {
GPR_ASSERT(!connect_done_); GPR_ASSERT(!connect_done_);
connect_done_ = true; connect_done_ = true;
GPR_ASSERT(wsa_connect_error_ == 0); GPR_ASSERT(wsa_connect_error_ == 0);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
DWORD transferred_bytes = 0; DWORD transferred_bytes = 0;
DWORD flags; DWORD flags;
BOOL wsa_success = BOOL wsa_success =
@ -579,7 +579,7 @@ class GrpcPolledFdWindows {
// the entire resolution attempt. Doing so will allow the "inject broken // the entire resolution attempt. Doing so will allow the "inject broken
// nameserver list" test to pass on Windows. // nameserver list" test to pass on Windows.
void OnIocpReadableLocked(grpc_error_handle error) { void OnIocpReadableLocked(grpc_error_handle error) {
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (winsocket_->read_info.wsa_error != 0) { if (winsocket_->read_info.wsa_error != 0) {
/* WSAEMSGSIZE would be due to receiving more data /* WSAEMSGSIZE would be due to receiving more data
* than our read buffer's fixed capacity. Assume that * than our read buffer's fixed capacity. Assume that
@ -596,7 +596,7 @@ class GrpcPolledFdWindows {
} }
} }
} }
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
read_buf_ = grpc_slice_sub_no_ref( read_buf_ = grpc_slice_sub_no_ref(
read_buf_, 0, winsocket_->read_info.bytes_transferred); read_buf_, 0, winsocket_->read_info.bytes_transferred);
read_buf_has_data_ = true; read_buf_has_data_ = true;
@ -620,7 +620,7 @@ class GrpcPolledFdWindows {
void OnIocpWriteableLocked(grpc_error_handle error) { void OnIocpWriteableLocked(grpc_error_handle error) {
GRPC_CARES_TRACE_LOG("OnIocpWriteableInner. fd:|%s|", GetName()); GRPC_CARES_TRACE_LOG("OnIocpWriteableInner. fd:|%s|", GetName());
GPR_ASSERT(socket_type_ == SOCK_STREAM); GPR_ASSERT(socket_type_ == SOCK_STREAM);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (winsocket_->write_info.wsa_error != 0) { if (winsocket_->write_info.wsa_error != 0) {
error = GRPC_WSA_ERROR(winsocket_->write_info.wsa_error, error = GRPC_WSA_ERROR(winsocket_->write_info.wsa_error,
"OnIocpWriteableInner"); "OnIocpWriteableInner");
@ -632,7 +632,7 @@ class GrpcPolledFdWindows {
} }
} }
GPR_ASSERT(tcp_write_state_ == WRITE_PENDING); GPR_ASSERT(tcp_write_state_ == WRITE_PENDING);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
tcp_write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY; tcp_write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY;
write_buf_ = grpc_slice_sub_no_ref( write_buf_ = grpc_slice_sub_no_ref(
write_buf_, 0, winsocket_->write_info.bytes_transferred); write_buf_, 0, winsocket_->write_info.bytes_transferred);

@ -289,7 +289,7 @@ static void on_timeout(void* arg, grpc_error_handle error) {
"err=%s", "err=%s",
driver->request, driver, driver->shutting_down, driver->request, driver, driver->shutting_down,
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
if (!driver->shutting_down && error == GRPC_ERROR_NONE) { if (!driver->shutting_down && GRPC_ERROR_IS_NONE(error)) {
grpc_ares_ev_driver_shutdown_locked(driver); grpc_ares_ev_driver_shutdown_locked(driver);
} }
grpc_ares_ev_driver_unref(driver); grpc_ares_ev_driver_unref(driver);
@ -315,7 +315,7 @@ static void on_ares_backup_poll_alarm(void* arg, grpc_error_handle error) {
"err=%s", "err=%s",
driver->request, driver, driver->shutting_down, driver->request, driver, driver->shutting_down,
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
if (!driver->shutting_down && error == GRPC_ERROR_NONE) { if (!driver->shutting_down && GRPC_ERROR_IS_NONE(error)) {
fd_node* fdn = driver->fds; fd_node* fdn = driver->fds;
while (fdn != nullptr) { while (fdn != nullptr) {
if (!fdn->already_shutdown) { if (!fdn->already_shutdown) {
@ -357,7 +357,7 @@ static void on_readable(void* arg, grpc_error_handle error) {
fdn->readable_registered = false; fdn->readable_registered = false;
GRPC_CARES_TRACE_LOG("request:%p readable on %s", fdn->ev_driver->request, GRPC_CARES_TRACE_LOG("request:%p readable on %s", fdn->ev_driver->request,
fdn->grpc_polled_fd->GetName()); fdn->grpc_polled_fd->GetName());
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
do { do {
ares_process_fd(ev_driver->channel, as, ARES_SOCKET_BAD); ares_process_fd(ev_driver->channel, as, ARES_SOCKET_BAD);
} while (fdn->grpc_polled_fd->IsFdStillReadableLocked()); } while (fdn->grpc_polled_fd->IsFdStillReadableLocked());
@ -383,7 +383,7 @@ static void on_writable(void* arg, grpc_error_handle error) {
fdn->writable_registered = false; fdn->writable_registered = false;
GRPC_CARES_TRACE_LOG("request:%p writable on %s", ev_driver->request, GRPC_CARES_TRACE_LOG("request:%p writable on %s", ev_driver->request,
fdn->grpc_polled_fd->GetName()); fdn->grpc_polled_fd->GetName());
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
ares_process_fd(ev_driver->channel, ARES_SOCKET_BAD, as); ares_process_fd(ev_driver->channel, ARES_SOCKET_BAD, as);
} else { } else {
// If error is not GRPC_ERROR_NONE, it means the fd has been shutdown or // If error is not GRPC_ERROR_NONE, it means the fd has been shutdown or
@ -848,7 +848,7 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked(
} }
error = grpc_ares_ev_driver_create_locked(&r->ev_driver, interested_parties, error = grpc_ares_ev_driver_create_locked(&r->ev_driver, interested_parties,
query_timeout_ms, r); query_timeout_ms, r);
if (error != GRPC_ERROR_NONE) goto error_cleanup; if (!GRPC_ERROR_IS_NONE(error)) goto error_cleanup;
// If dns_server is specified, use it. // If dns_server is specified, use it.
if (dns_server != nullptr && dns_server[0] != '\0') { if (dns_server != nullptr && dns_server[0] != '\0') {
GRPC_CARES_TRACE_LOG("request:%p Using DNS server %s", r, dns_server); GRPC_CARES_TRACE_LOG("request:%p Using DNS server %s", r, dns_server);

@ -215,7 +215,7 @@ void GoogleCloud2ProdResolver::ZoneQuery::OnDone(
GoogleCloud2ProdResolver* resolver, const grpc_http_response* response, GoogleCloud2ProdResolver* resolver, const grpc_http_response* response,
grpc_error_handle error) { grpc_error_handle error) {
absl::StatusOr<std::string> zone; absl::StatusOr<std::string> zone;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
zone = absl::UnknownError( zone = absl::UnknownError(
absl::StrCat("error fetching zone from metadata server: ", absl::StrCat("error fetching zone from metadata server: ",
grpc_error_std_string(error))); grpc_error_std_string(error)));
@ -256,11 +256,11 @@ GoogleCloud2ProdResolver::IPv6Query::IPv6Query(
void GoogleCloud2ProdResolver::IPv6Query::OnDone( void GoogleCloud2ProdResolver::IPv6Query::OnDone(
GoogleCloud2ProdResolver* resolver, const grpc_http_response* response, GoogleCloud2ProdResolver* resolver, const grpc_http_response* response,
grpc_error_handle error) { grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "error fetching IPv6 address from metadata server: %s", gpr_log(GPR_ERROR, "error fetching IPv6 address from metadata server: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
} }
resolver->IPv6QueryDone(error == GRPC_ERROR_NONE && response->status == 200); resolver->IPv6QueryDone(GRPC_ERROR_IS_NONE(error) && response->status == 200);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }

@ -107,7 +107,7 @@ void PollingResolver::OnNextResolutionLocked(grpc_error_handle error) {
this, grpc_error_std_string(error).c_str(), shutdown_); this, grpc_error_std_string(error).c_str(), shutdown_);
} }
have_next_resolution_timer_ = false; have_next_resolution_timer_ = false;
if (error == GRPC_ERROR_NONE && !shutdown_) { if (GRPC_ERROR_IS_NONE(error) && !shutdown_) {
StartResolvingLocked(); StartResolvingLocked();
} }
Unref(DEBUG_LOCATION, "retry-timer"); Unref(DEBUG_LOCATION, "retry-timer");

@ -492,7 +492,7 @@ XdsResolver::XdsConfigSelector::XdsConfigSelector(
Route::ClusterWeightState cluster_weight_state; Route::ClusterWeightState cluster_weight_state;
*error = CreateMethodConfig(route_entry.route, &weighted_cluster, *error = CreateMethodConfig(route_entry.route, &weighted_cluster,
&cluster_weight_state.method_config); &cluster_weight_state.method_config);
if (*error != GRPC_ERROR_NONE) return; if (!GRPC_ERROR_IS_NONE(*error)) return;
end += weighted_cluster.weight; end += weighted_cluster.weight;
cluster_weight_state.range_end = end; cluster_weight_state.range_end = end;
cluster_weight_state.cluster = weighted_cluster.name; cluster_weight_state.cluster = weighted_cluster.name;
@ -596,7 +596,7 @@ grpc_error_handle XdsResolver::XdsConfigSelector::CreateMethodConfig(
resolver_->current_listener_.http_connection_manager.http_filters, resolver_->current_listener_.http_connection_manager.http_filters,
resolver_->current_virtual_host_, route, cluster_weight, resolver_->current_virtual_host_, route, cluster_weight,
grpc_channel_args_copy(resolver_->args_)); grpc_channel_args_copy(resolver_->args_));
if (result.error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(result.error)) {
return result.error; return result.error;
} }
for (const auto& p : result.per_filter_configs) { for (const auto& p : result.per_filter_configs) {
@ -788,7 +788,7 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
void XdsResolver::StartLocked() { void XdsResolver::StartLocked() {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
xds_client_ = XdsClient::GetOrCreate(args_, &error); xds_client_ = XdsClient::GetOrCreate(args_, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Failed to create xds client -- channel will remain in " "Failed to create xds client -- channel will remain in "
"TRANSIENT_FAILURE: %s", "TRANSIENT_FAILURE: %s",
@ -1036,7 +1036,7 @@ XdsResolver::CreateServiceConfig() {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
absl::StatusOr<RefCountedPtr<ServiceConfig>> result = absl::StatusOr<RefCountedPtr<ServiceConfig>> result =
ServiceConfigImpl::Create(args_, json.c_str(), &error); ServiceConfigImpl::Create(args_, json.c_str(), &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
result = grpc_error_to_absl_status(error); result = grpc_error_to_absl_status(error);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
@ -1049,7 +1049,7 @@ void XdsResolver::GenerateResult() {
// state map, and then CreateServiceConfig for LB policies. // state map, and then CreateServiceConfig for LB policies.
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
auto config_selector = MakeRefCounted<XdsConfigSelector>(Ref(), &error); auto config_selector = MakeRefCounted<XdsConfigSelector>(Ref(), &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
OnError("could not create ConfigSelector", OnError("could not create ConfigSelector",
absl::UnavailableError(grpc_error_std_string(error))); absl::UnavailableError(grpc_error_std_string(error)));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

@ -54,7 +54,7 @@ namespace {
absl::optional<std::string> ParseHealthCheckConfig(const Json& field, absl::optional<std::string> ParseHealthCheckConfig(const Json& field,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
if (field.type() != Json::Type::OBJECT) { if (field.type() != Json::Type::OBJECT) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:healthCheckConfig error:should be of type object"); "field:healthCheckConfig error:should be of type object");
@ -82,7 +82,7 @@ std::unique_ptr<ServiceConfigParser::ParsedConfig>
ClientChannelServiceConfigParser::ParseGlobalParams( ClientChannelServiceConfigParser::ParseGlobalParams(
const grpc_channel_args* /*args*/, const Json& json, const grpc_channel_args* /*args*/, const Json& json,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
std::vector<grpc_error_handle> error_list; std::vector<grpc_error_handle> error_list;
// Parse LB config. // Parse LB config.
RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config; RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config;
@ -91,7 +91,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(
grpc_error_handle parse_error = GRPC_ERROR_NONE; grpc_error_handle parse_error = GRPC_ERROR_NONE;
parsed_lb_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( parsed_lb_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
it->second, &parse_error); it->second, &parse_error);
if (parse_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parse_error)) {
std::vector<grpc_error_handle> lb_errors; std::vector<grpc_error_handle> lb_errors;
lb_errors.push_back(parse_error); lb_errors.push_back(parse_error);
error_list.push_back(GRPC_ERROR_CREATE_FROM_VECTOR( error_list.push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
@ -130,13 +130,13 @@ ClientChannelServiceConfigParser::ParseGlobalParams(
grpc_error_handle parsing_error = GRPC_ERROR_NONE; grpc_error_handle parsing_error = GRPC_ERROR_NONE;
health_check_service_name = health_check_service_name =
ParseHealthCheckConfig(it->second, &parsing_error); ParseHealthCheckConfig(it->second, &parsing_error);
if (parsing_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parsing_error)) {
error_list.push_back(parsing_error); error_list.push_back(parsing_error);
} }
} }
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel global parser", *error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel global parser",
&error_list); &error_list);
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
return absl::make_unique<ClientChannelGlobalParsedConfig>( return absl::make_unique<ClientChannelGlobalParsedConfig>(
std::move(parsed_lb_config), std::move(lb_policy_name), std::move(parsed_lb_config), std::move(lb_policy_name),
std::move(health_check_service_name)); std::move(health_check_service_name));
@ -148,7 +148,7 @@ std::unique_ptr<ServiceConfigParser::ParsedConfig>
ClientChannelServiceConfigParser::ParsePerMethodParams( ClientChannelServiceConfigParser::ParsePerMethodParams(
const grpc_channel_args* /*args*/, const Json& json, const grpc_channel_args* /*args*/, const Json& json,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
std::vector<grpc_error_handle> error_list; std::vector<grpc_error_handle> error_list;
// Parse waitForReady. // Parse waitForReady.
absl::optional<bool> wait_for_ready; absl::optional<bool> wait_for_ready;
@ -169,7 +169,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(
&error_list, false); &error_list, false);
// Return result. // Return result.
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel parser", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel parser", &error_list);
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
return absl::make_unique<ClientChannelMethodParsedConfig>(timeout, return absl::make_unique<ClientChannelMethodParsedConfig>(timeout,
wait_for_ready); wait_for_ready);
} }

@ -1280,7 +1280,7 @@ void RetryFilter::CallData::CallAttempt::OnPerAttemptRecvTimerLocked(
call_attempt->per_attempt_recv_timer_pending_); call_attempt->per_attempt_recv_timer_pending_);
} }
CallCombinerClosureList closures; CallCombinerClosureList closures;
if (error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(error) &&
call_attempt->per_attempt_recv_timer_pending_) { call_attempt->per_attempt_recv_timer_pending_) {
call_attempt->per_attempt_recv_timer_pending_ = false; call_attempt->per_attempt_recv_timer_pending_ = false;
// Cancel this attempt. // Cancel this attempt.
@ -1452,7 +1452,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvInitialMetadataReady(
// callback back to the surface. We can evaluate whether to retry when // callback back to the surface. We can evaluate whether to retry when
// recv_trailing_metadata comes back. // recv_trailing_metadata comes back.
if (GPR_UNLIKELY((call_attempt->trailing_metadata_available_ || if (GPR_UNLIKELY((call_attempt->trailing_metadata_available_ ||
error != GRPC_ERROR_NONE) && !GRPC_ERROR_IS_NONE(error)) &&
!call_attempt->completed_recv_trailing_metadata_)) { !call_attempt->completed_recv_trailing_metadata_)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -1464,7 +1464,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvInitialMetadataReady(
std::move(batch_data); std::move(batch_data);
call_attempt->recv_initial_metadata_error_ = GRPC_ERROR_REF(error); call_attempt->recv_initial_metadata_error_ = GRPC_ERROR_REF(error);
CallCombinerClosureList closures; CallCombinerClosureList closures;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
call_attempt->MaybeAddBatchForCancelOp(GRPC_ERROR_REF(error), call_attempt->MaybeAddBatchForCancelOp(GRPC_ERROR_REF(error),
&closures); &closures);
} }
@ -1557,7 +1557,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvMessageReady(
// callback back to the surface. We can evaluate whether to retry when // callback back to the surface. We can evaluate whether to retry when
// recv_trailing_metadata comes back. // recv_trailing_metadata comes back.
if (GPR_UNLIKELY((!call_attempt->recv_message_.has_value() || if (GPR_UNLIKELY((!call_attempt->recv_message_.has_value() ||
error != GRPC_ERROR_NONE) && !GRPC_ERROR_IS_NONE(error)) &&
!call_attempt->completed_recv_trailing_metadata_)) { !call_attempt->completed_recv_trailing_metadata_)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -1568,7 +1568,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvMessageReady(
call_attempt->recv_message_ready_deferred_batch_ = std::move(batch_data); call_attempt->recv_message_ready_deferred_batch_ = std::move(batch_data);
call_attempt->recv_message_error_ = GRPC_ERROR_REF(error); call_attempt->recv_message_error_ = GRPC_ERROR_REF(error);
CallCombinerClosureList closures; CallCombinerClosureList closures;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
call_attempt->MaybeAddBatchForCancelOp(GRPC_ERROR_REF(error), call_attempt->MaybeAddBatchForCancelOp(GRPC_ERROR_REF(error),
&closures); &closures);
} }
@ -1606,7 +1606,7 @@ void GetCallStatus(
grpc_status_code* status, absl::optional<Duration>* server_pushback, grpc_status_code* status, absl::optional<Duration>* server_pushback,
bool* is_lb_drop, bool* is_lb_drop,
absl::optional<GrpcStreamNetworkState::ValueType>* stream_network_state) { absl::optional<GrpcStreamNetworkState::ValueType>* stream_network_state) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_error_get_status(error, deadline, status, nullptr, nullptr, nullptr); grpc_error_get_status(error, deadline, status, nullptr, nullptr, nullptr);
intptr_t value = 0; intptr_t value = 0;
if (grpc_error_get_int(error, GRPC_ERROR_INT_LB_POLICY_DROP, &value) && if (grpc_error_get_int(error, GRPC_ERROR_INT_LB_POLICY_DROP, &value) &&
@ -1801,7 +1801,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvTrailingMetadataReady(
CallCombinerClosureList closures; CallCombinerClosureList closures;
// Cancel call attempt. // Cancel call attempt.
call_attempt->MaybeAddBatchForCancelOp( call_attempt->MaybeAddBatchForCancelOp(
error == GRPC_ERROR_NONE GRPC_ERROR_IS_NONE(error)
? grpc_error_set_int( ? grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("call attempt failed"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("call attempt failed"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED) GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED)
@ -1919,7 +1919,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::OnComplete(
// recv_trailing_metadata_ready callback, then defer propagating this // recv_trailing_metadata_ready callback, then defer propagating this
// callback back to the surface. We can evaluate whether to retry when // callback back to the surface. We can evaluate whether to retry when
// recv_trailing_metadata comes back. // recv_trailing_metadata comes back.
if (GPR_UNLIKELY(!calld->retry_committed_ && error != GRPC_ERROR_NONE && if (GPR_UNLIKELY(!calld->retry_committed_ && !GRPC_ERROR_IS_NONE(error) &&
!call_attempt->completed_recv_trailing_metadata_)) { !call_attempt->completed_recv_trailing_metadata_)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: deferring on_complete", gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: deferring on_complete",
@ -2219,7 +2219,7 @@ void RetryFilter::CallData::StartTransportStreamOpBatch(
} }
// If we were previously cancelled from the surface, fail this // If we were previously cancelled from the surface, fail this
// batch immediately. // batch immediately.
if (cancelled_from_surface_ != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(cancelled_from_surface_)) {
// Note: This will release the call combiner. // Note: This will release the call combiner.
grpc_transport_stream_op_batch_finish_with_failure( grpc_transport_stream_op_batch_finish_with_failure(
batch, GRPC_ERROR_REF(cancelled_from_surface_), call_combiner_); batch, GRPC_ERROR_REF(cancelled_from_surface_), call_combiner_);
@ -2532,7 +2532,7 @@ void RetryFilter::CallData::FailPendingBatchInCallCombiner(
// This is called via the call combiner, so access to calld is synchronized. // This is called via the call combiner, so access to calld is synchronized.
void RetryFilter::CallData::PendingBatchesFail(grpc_error_handle error) { void RetryFilter::CallData::PendingBatchesFail(grpc_error_handle error) {
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
size_t num_batches = 0; size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
@ -2641,7 +2641,7 @@ void RetryFilter::CallData::OnRetryTimer(void* arg, grpc_error_handle error) {
void RetryFilter::CallData::OnRetryTimerLocked(void* arg, void RetryFilter::CallData::OnRetryTimerLocked(void* arg,
grpc_error_handle error) { grpc_error_handle error) {
auto* calld = static_cast<CallData*>(arg); auto* calld = static_cast<CallData*>(arg);
if (error == GRPC_ERROR_NONE && calld->retry_timer_pending_) { if (GRPC_ERROR_IS_NONE(error) && calld->retry_timer_pending_) {
calld->retry_timer_pending_ = false; calld->retry_timer_pending_ = false;
calld->CreateCallAttempt(/*is_transparent_retry=*/false); calld->CreateCallAttempt(/*is_transparent_retry=*/false);
} else { } else {
@ -2664,7 +2664,7 @@ void RetryFilter::CallData::AddClosureToStartTransparentRetry(
void RetryFilter::CallData::StartTransparentRetry(void* arg, void RetryFilter::CallData::StartTransparentRetry(void* arg,
grpc_error_handle /*error*/) { grpc_error_handle /*error*/) {
auto* calld = static_cast<CallData*>(arg); auto* calld = static_cast<CallData*>(arg);
if (calld->cancelled_from_surface_ == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(calld->cancelled_from_surface_)) {
calld->CreateCallAttempt(/*is_transparent_retry=*/true); calld->CreateCallAttempt(/*is_transparent_retry=*/true);
} else { } else {
GRPC_CALL_COMBINER_STOP(calld->call_combiner_, GRPC_CALL_COMBINER_STOP(calld->call_combiner_,

@ -141,14 +141,14 @@ std::unique_ptr<ServiceConfigParser::ParsedConfig>
RetryServiceConfigParser::ParseGlobalParams(const grpc_channel_args* /*args*/, RetryServiceConfigParser::ParseGlobalParams(const grpc_channel_args* /*args*/,
const Json& json, const Json& json,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
auto it = json.object_value().find("retryThrottling"); auto it = json.object_value().find("retryThrottling");
if (it == json.object_value().end()) return nullptr; if (it == json.object_value().end()) return nullptr;
intptr_t max_milli_tokens = 0; intptr_t max_milli_tokens = 0;
intptr_t milli_token_ratio = 0; intptr_t milli_token_ratio = 0;
*error = *error =
ParseRetryThrottling(it->second, &max_milli_tokens, &milli_token_ratio); ParseRetryThrottling(it->second, &max_milli_tokens, &milli_token_ratio);
if (*error != GRPC_ERROR_NONE) return nullptr; if (!GRPC_ERROR_IS_NONE(*error)) return nullptr;
return absl::make_unique<RetryGlobalConfig>(max_milli_tokens, return absl::make_unique<RetryGlobalConfig>(max_milli_tokens,
milli_token_ratio); milli_token_ratio);
} }
@ -290,7 +290,7 @@ std::unique_ptr<ServiceConfigParser::ParsedConfig>
RetryServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args, RetryServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args,
const Json& json, const Json& json,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
// Parse retry policy. // Parse retry policy.
auto it = json.object_value().find("retryPolicy"); auto it = json.object_value().find("retryPolicy");
if (it == json.object_value().end()) return nullptr; if (it == json.object_value().end()) return nullptr;
@ -303,7 +303,7 @@ RetryServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args,
*error = ParseRetryPolicy(args, it->second, &max_attempts, &initial_backoff, *error = ParseRetryPolicy(args, it->second, &max_attempts, &initial_backoff,
&max_backoff, &backoff_multiplier, &max_backoff, &backoff_multiplier,
&retryable_status_codes, &per_attempt_recv_timeout); &retryable_status_codes, &per_attempt_recv_timeout);
if (*error != GRPC_ERROR_NONE) return nullptr; if (!GRPC_ERROR_IS_NONE(*error)) return nullptr;
return absl::make_unique<RetryMethodConfig>( return absl::make_unique<RetryMethodConfig>(
max_attempts, initial_backoff, max_backoff, backoff_multiplier, max_attempts, initial_backoff, max_backoff, backoff_multiplier,
retryable_status_codes, per_attempt_recv_timeout); retryable_status_codes, per_attempt_recv_timeout);

@ -58,7 +58,7 @@ class ServiceConfigChannelArgChannelData {
grpc_error_handle service_config_error = GRPC_ERROR_NONE; grpc_error_handle service_config_error = GRPC_ERROR_NONE;
auto service_config = ServiceConfigImpl::Create( auto service_config = ServiceConfigImpl::Create(
args->channel_args, service_config_str, &service_config_error); args->channel_args, service_config_str, &service_config_error);
if (service_config_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(service_config_error)) {
service_config_ = std::move(service_config); service_config_ = std::move(service_config);
} else { } else {
gpr_log(GPR_ERROR, "%s", gpr_log(GPR_ERROR, "%s",

@ -165,7 +165,7 @@ SubchannelCall::SubchannelCall(Args args, grpc_error_handle* error)
}; };
*error = grpc_call_stack_init(connected_subchannel_->channel_stack(), 1, *error = grpc_call_stack_init(connected_subchannel_->channel_stack(), 1,
SubchannelCall::Destroy, this, &call_args); SubchannelCall::Destroy, this, &call_args);
if (GPR_UNLIKELY(*error != GRPC_ERROR_NONE)) { if (GPR_UNLIKELY(!GRPC_ERROR_IS_NONE(*error))) {
gpr_log(GPR_ERROR, "error: %s", grpc_error_std_string(*error).c_str()); gpr_log(GPR_ERROR, "error: %s", grpc_error_std_string(*error).c_str());
return; return;
} }
@ -262,7 +262,7 @@ namespace {
// Sets *status based on the rest of the parameters. // Sets *status based on the rest of the parameters.
void GetCallStatus(grpc_status_code* status, Timestamp deadline, void GetCallStatus(grpc_status_code* status, Timestamp deadline,
grpc_metadata_batch* md_batch, grpc_error_handle error) { grpc_metadata_batch* md_batch, grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_error_get_status(error, deadline, status, nullptr, nullptr, nullptr); grpc_error_get_status(error, deadline, status, nullptr, nullptr, nullptr);
} else { } else {
*status = md_batch->get(GrpcStatusMetadata()).value_or(GRPC_STATUS_UNKNOWN); *status = md_batch->get(GrpcStatusMetadata()).value_or(GRPC_STATUS_UNKNOWN);

@ -146,7 +146,7 @@ void SubchannelStreamClient::OnRetryTimer(void* arg, grpc_error_handle error) {
{ {
MutexLock lock(&self->mu_); MutexLock lock(&self->mu_);
self->retry_timer_callback_pending_ = false; self->retry_timer_callback_pending_ = false;
if (self->event_handler_ != nullptr && error == GRPC_ERROR_NONE && if (self->event_handler_ != nullptr && GRPC_ERROR_IS_NONE(error) &&
self->call_state_ == nullptr) { self->call_state_ == nullptr) {
if (GPR_UNLIKELY(self->tracer_ != nullptr)) { if (GPR_UNLIKELY(self->tracer_ != nullptr)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -218,7 +218,7 @@ void SubchannelStreamClient::CallState::StartCallLocked() {
this, grpc_schedule_on_exec_ctx); this, grpc_schedule_on_exec_ctx);
call_->SetAfterCallStackDestroy(&after_call_stack_destruction_); call_->SetAfterCallStackDestroy(&after_call_stack_destruction_);
// Check if creation failed. // Check if creation failed.
if (error != GRPC_ERROR_NONE || if (!GRPC_ERROR_IS_NONE(error) ||
subchannel_stream_client_->event_handler_ == nullptr) { subchannel_stream_client_->event_handler_ == nullptr) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"SubchannelStreamClient %p CallState %p: error creating " "SubchannelStreamClient %p CallState %p: error creating "
@ -240,7 +240,7 @@ void SubchannelStreamClient::CallState::StartCallLocked() {
send_initial_metadata_.Set( send_initial_metadata_.Set(
HttpPathMetadata(), HttpPathMetadata(),
subchannel_stream_client_->event_handler_->GetPathLocked()); subchannel_stream_client_->event_handler_->GetPathLocked());
GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(error));
payload_.send_initial_metadata.send_initial_metadata = payload_.send_initial_metadata.send_initial_metadata =
&send_initial_metadata_; &send_initial_metadata_;
payload_.send_initial_metadata.send_initial_metadata_flags = 0; payload_.send_initial_metadata.send_initial_metadata_flags = 0;
@ -420,7 +420,7 @@ void SubchannelStreamClient::CallState::RecvTrailingMetadataReady(
grpc_status_code status = grpc_status_code status =
self->recv_trailing_metadata_.get(GrpcStatusMetadata()) self->recv_trailing_metadata_.get(GrpcStatusMetadata())
.value_or(GRPC_STATUS_UNKNOWN); .value_or(GRPC_STATUS_UNKNOWN);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_error_get_status(error, Timestamp::InfFuture(), &status, grpc_error_get_status(error, Timestamp::InfFuture(), &status,
nullptr /* slice */, nullptr /* http_error */, nullptr /* slice */, nullptr /* http_error */,
nullptr /* error_string */); nullptr /* error_string */);

@ -144,7 +144,7 @@ ParseFaultInjectionPolicy(const Json::Array& policies_json_array,
std::unique_ptr<ServiceConfigParser::ParsedConfig> std::unique_ptr<ServiceConfigParser::ParsedConfig>
FaultInjectionServiceConfigParser::ParsePerMethodParams( FaultInjectionServiceConfigParser::ParsePerMethodParams(
const grpc_channel_args* args, const Json& json, grpc_error_handle* error) { const grpc_channel_args* args, const Json& json, grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
// Only parse fault injection policy if the following channel arg is present. // Only parse fault injection policy if the following channel arg is present.
if (!grpc_channel_args_find_bool( if (!grpc_channel_args_find_bool(
args, GRPC_ARG_PARSE_FAULT_INJECTION_METHOD_CONFIG, false)) { args, GRPC_ARG_PARSE_FAULT_INJECTION_METHOD_CONFIG, false)) {
@ -161,7 +161,7 @@ FaultInjectionServiceConfigParser::ParsePerMethodParams(
ParseFaultInjectionPolicy(*policies_json_array, &error_list); ParseFaultInjectionPolicy(*policies_json_array, &error_list);
} }
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Fault injection parser", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("Fault injection parser", &error_list);
if (*error != GRPC_ERROR_NONE || fault_injection_policies.empty()) { if (!GRPC_ERROR_IS_NONE(*error) || fault_injection_policies.empty()) {
return nullptr; return nullptr;
} }
return absl::make_unique<FaultInjectionMethodParsedConfig>( return absl::make_unique<FaultInjectionMethodParsedConfig>(

@ -241,7 +241,7 @@ void CallData::CompressStartTransportStreamOpBatch(
GRPC_ERROR_REF(cancel_error_), "failing send_message op"); GRPC_ERROR_REF(cancel_error_), "failing send_message op");
} }
} }
} else if (cancel_error_ != GRPC_ERROR_NONE) { } else if (!GRPC_ERROR_IS_NONE(cancel_error_)) {
grpc_transport_stream_op_batch_finish_with_failure( grpc_transport_stream_op_batch_finish_with_failure(
batch, GRPC_ERROR_REF(cancel_error_), call_combiner_); batch, GRPC_ERROR_REF(cancel_error_), call_combiner_);
return; return;

@ -131,7 +131,7 @@ class CallData {
void CallData::OnRecvInitialMetadataReady(void* arg, grpc_error_handle error) { void CallData::OnRecvInitialMetadataReady(void* arg, grpc_error_handle error) {
CallData* calld = static_cast<CallData*>(arg); CallData* calld = static_cast<CallData*>(arg);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
calld->algorithm_ = calld->algorithm_ =
calld->recv_initial_metadata_->get(GrpcEncodingMetadata()) calld->recv_initial_metadata_->get(GrpcEncodingMetadata())
.value_or(GRPC_COMPRESS_NONE); .value_or(GRPC_COMPRESS_NONE);
@ -154,7 +154,7 @@ void CallData::MaybeResumeOnRecvMessageReady() {
void CallData::OnRecvMessageReady(void* arg, grpc_error_handle error) { void CallData::OnRecvMessageReady(void* arg, grpc_error_handle error) {
CallData* calld = static_cast<CallData*>(arg); CallData* calld = static_cast<CallData*>(arg);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (calld->original_recv_initial_metadata_ready_ != nullptr) { if (calld->original_recv_initial_metadata_ready_ != nullptr) {
calld->seen_recv_message_ready_ = true; calld->seen_recv_message_ready_ = true;
GRPC_CALL_COMBINER_STOP(calld->call_combiner_, GRPC_CALL_COMBINER_STOP(calld->call_combiner_,
@ -173,7 +173,7 @@ void CallData::OnRecvMessageReady(void* arg, grpc_error_handle error) {
if (calld->max_recv_message_length_ >= 0 && if (calld->max_recv_message_length_ >= 0 &&
(*calld->recv_message_)->Length() > (*calld->recv_message_)->Length() >
static_cast<uint32_t>(calld->max_recv_message_length_)) { static_cast<uint32_t>(calld->max_recv_message_length_)) {
GPR_DEBUG_ASSERT(calld->error_ == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(GRPC_ERROR_IS_NONE(calld->error_));
calld->error_ = grpc_error_set_int( calld->error_ = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING( GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrFormat("Received message larger than max (%u vs. %d)", absl::StrFormat("Received message larger than max (%u vs. %d)",
@ -187,7 +187,7 @@ void CallData::OnRecvMessageReady(void* arg, grpc_error_handle error) {
if (grpc_msg_decompress(calld->algorithm_, if (grpc_msg_decompress(calld->algorithm_,
(*calld->recv_message_)->c_slice_buffer(), (*calld->recv_message_)->c_slice_buffer(),
decompressed_slices.c_slice_buffer()) == 0) { decompressed_slices.c_slice_buffer()) == 0) {
GPR_DEBUG_ASSERT(calld->error_ == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(GRPC_ERROR_IS_NONE(calld->error_));
calld->error_ = GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat( calld->error_ = GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
"Unexpected error decompressing data for algorithm with " "Unexpected error decompressing data for algorithm with "
"enum value ", "enum value ",

@ -76,7 +76,7 @@ std::unique_ptr<ServiceConfigParser::ParsedConfig>
MessageSizeParser::ParsePerMethodParams(const grpc_channel_args* /*args*/, MessageSizeParser::ParsePerMethodParams(const grpc_channel_args* /*args*/,
const Json& json, const Json& json,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
std::vector<grpc_error_handle> error_list; std::vector<grpc_error_handle> error_list;
// Max request size. // Max request size.
int max_request_message_bytes = -1; int max_request_message_bytes = -1;

@ -82,7 +82,7 @@ void RbacFilter::CallData::RecvInitialMetadataReady(void* user_data,
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data); grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
CallData* calld = static_cast<CallData*>(elem->call_data); CallData* calld = static_cast<CallData*>(elem->call_data);
RbacFilter* filter = static_cast<RbacFilter*>(elem->channel_data); RbacFilter* filter = static_cast<RbacFilter*>(elem->channel_data);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
// Fetch and apply the rbac policy from the service config. // Fetch and apply the rbac policy from the service config.
auto* service_config_call_data = static_cast<ServiceConfigCallData*>( auto* service_config_call_data = static_cast<ServiceConfigCallData*>(
calld->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value); calld->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
@ -103,7 +103,7 @@ void RbacFilter::CallData::RecvInitialMetadataReady(void* user_data,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unauthorized RPC rejected"); GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unauthorized RPC rejected");
} }
} }
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_PERMISSION_DENIED); GRPC_STATUS_PERMISSION_DENIED);
} }

@ -584,7 +584,7 @@ std::unique_ptr<ServiceConfigParser::ParsedConfig>
RbacServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args, RbacServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args,
const Json& json, const Json& json,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && GRPC_ERROR_IS_NONE(*error));
// Only parse rbac policy if the channel arg is present // Only parse rbac policy if the channel arg is present
if (!grpc_channel_args_find_bool(args, GRPC_ARG_PARSE_RBAC_METHOD_CONFIG, if (!grpc_channel_args_find_bool(args, GRPC_ARG_PARSE_RBAC_METHOD_CONFIG,
false)) { false)) {
@ -598,7 +598,7 @@ RbacServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args,
rbac_policies = ParseRbacArray(*policies_json_array, &error_list); rbac_policies = ParseRbacArray(*policies_json_array, &error_list);
} }
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Rbac parser", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("Rbac parser", &error_list);
if (*error != GRPC_ERROR_NONE || rbac_policies.empty()) { if (!GRPC_ERROR_IS_NONE(*error) || rbac_policies.empty()) {
return nullptr; return nullptr;
} }
return absl::make_unique<RbacMethodParsedConfig>(std::move(rbac_policies)); return absl::make_unique<RbacMethodParsedConfig>(std::move(rbac_policies));

@ -136,7 +136,7 @@ ArenaPromise<ServerMetadataHandle> ServerConfigSelectorFilter::MakeCallPromise(
if (!sel.ok()) return Immediate(ServerMetadataHandle(sel.status())); if (!sel.ok()) return Immediate(ServerMetadataHandle(sel.status()));
auto call_config = auto call_config =
sel.value()->GetCallConfig(call_args.client_initial_metadata.get()); sel.value()->GetCallConfig(call_args.client_initial_metadata.get());
if (call_config.error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(call_config.error)) {
auto r = Immediate(ServerMetadataHandle( auto r = Immediate(ServerMetadataHandle(
absl::UnavailableError(grpc_error_std_string(call_config.error)))); absl::UnavailableError(grpc_error_std_string(call_config.error))));
GRPC_ERROR_UNREF(call_config.error); GRPC_ERROR_UNREF(call_config.error);

@ -151,7 +151,7 @@ static void cancel_stream_locked(grpc_binder_transport* gbt,
grpc_error_handle error) { grpc_error_handle error) {
gpr_log(GPR_INFO, "cancel_stream_locked"); gpr_log(GPR_INFO, "cancel_stream_locked");
if (!gbs->is_closed) { if (!gbs->is_closed) {
GPR_ASSERT(gbs->cancel_self_error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(gbs->cancel_self_error));
gbs->is_closed = true; gbs->is_closed = true;
gbs->cancel_self_error = GRPC_ERROR_REF(error); gbs->cancel_self_error = GRPC_ERROR_REF(error);
gbt->transport_stream_receiver->CancelStream(gbs->tx_code); gbt->transport_stream_receiver->CancelStream(gbs->tx_code);
@ -262,7 +262,7 @@ static void recv_message_locked(void* arg, grpc_error_handle /*error*/) {
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
}(); }();
if (error != GRPC_ERROR_NONE && if (!GRPC_ERROR_IS_NONE(error) &&
gbs->call_failed_before_recv_message != nullptr) { gbs->call_failed_before_recv_message != nullptr) {
*gbs->call_failed_before_recv_message = true; *gbs->call_failed_before_recv_message = true;
} }
@ -609,11 +609,11 @@ static void perform_transport_op_locked(void* transport_op,
grpc_core::ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, GRPC_ERROR_NONE); grpc_core::ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, GRPC_ERROR_NONE);
} }
bool do_close = false; bool do_close = false;
if (op->disconnect_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->disconnect_with_error)) {
do_close = true; do_close = true;
GRPC_ERROR_UNREF(op->disconnect_with_error); GRPC_ERROR_UNREF(op->disconnect_with_error);
} }
if (op->goaway_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->goaway_error)) {
do_close = true; do_close = true;
GRPC_ERROR_UNREF(op->goaway_error); GRPC_ERROR_UNREF(op->goaway_error);
} }

@ -148,8 +148,8 @@ void Chttp2Connector::OnHandshakeDone(void* arg, grpc_error_handle error) {
Chttp2Connector* self = static_cast<Chttp2Connector*>(args->user_data); Chttp2Connector* self = static_cast<Chttp2Connector*>(args->user_data);
{ {
MutexLock lock(&self->mu_); MutexLock lock(&self->mu_);
if (error != GRPC_ERROR_NONE || self->shutdown_) { if (!GRPC_ERROR_IS_NONE(error) || self->shutdown_) {
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown"); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown");
// We were shut down after handshaking completed successfully, so // We were shut down after handshaking completed successfully, so
// destroy the endpoint here. // destroy the endpoint here.
@ -206,7 +206,7 @@ void Chttp2Connector::OnReceiveSettings(void* arg, grpc_error_handle error) {
if (!self->notify_error_.has_value()) { if (!self->notify_error_.has_value()) {
grpc_endpoint_delete_from_pollset_set(self->endpoint_, grpc_endpoint_delete_from_pollset_set(self->endpoint_,
self->args_.interested_parties); self->args_.interested_parties);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// Transport got an error while waiting on SETTINGS frame. // Transport got an error while waiting on SETTINGS frame.
// TODO(yashykt): The following two lines should be moved to // TODO(yashykt): The following two lines should be moved to
// SubchannelConnector::Result::Reset() // SubchannelConnector::Result::Reset()

@ -325,7 +325,7 @@ void Chttp2ServerListener::ConfigFetcherWatcher::UpdateConnectionManager(
int port_temp; int port_temp;
grpc_error_handle error = grpc_tcp_server_add_port( grpc_error_handle error = grpc_tcp_server_add_port(
listener_->tcp_server_, &listener_->resolved_address_, &port_temp); listener_->tcp_server_, &listener_->resolved_address_, &port_temp);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
gpr_log(GPR_ERROR, "Error adding port to server: %s", gpr_log(GPR_ERROR, "Error adding port to server: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
@ -446,11 +446,11 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone(
bool cleanup_connection = false; bool cleanup_connection = false;
{ {
MutexLock connection_lock(&self->connection_->mu_); MutexLock connection_lock(&self->connection_->mu_);
if (error != GRPC_ERROR_NONE || self->connection_->shutdown_) { if (!GRPC_ERROR_IS_NONE(error) || self->connection_->shutdown_) {
std::string error_str = grpc_error_std_string(error); std::string error_str = grpc_error_std_string(error);
gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str.c_str()); gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str.c_str());
cleanup_connection = true; cleanup_connection = true;
if (error == GRPC_ERROR_NONE && args->endpoint != nullptr) { if (GRPC_ERROR_IS_NONE(error) && args->endpoint != nullptr) {
// We were shut down or stopped serving after handshaking completed // We were shut down or stopped serving after handshaking completed
// successfully, so destroy the endpoint here. // successfully, so destroy the endpoint here.
// TODO(ctiller): It is currently necessary to shutdown endpoints // TODO(ctiller): It is currently necessary to shutdown endpoints
@ -474,7 +474,7 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone(
self->connection_->listener_->server_->SetupTransport( self->connection_->listener_->server_->SetupTransport(
transport, self->accepting_pollset_, args->args, transport, self->accepting_pollset_, args->args,
grpc_chttp2_transport_get_socket_node(transport)); grpc_chttp2_transport_get_socket_node(transport));
if (channel_init_err == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(channel_init_err)) {
// Use notify_on_receive_settings callback to enforce the // Use notify_on_receive_settings callback to enforce the
// handshake deadline. // handshake deadline.
// Note: The reinterpret_cast<>s here are safe, because // Note: The reinterpret_cast<>s here are safe, because
@ -653,7 +653,7 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry(
ActiveConnection* self = static_cast<ActiveConnection*>(arg); ActiveConnection* self = static_cast<ActiveConnection*>(arg);
// If the drain_grace_timer_ was not cancelled, disconnect the transport // If the drain_grace_timer_ was not cancelled, disconnect the transport
// immediately. // immediately.
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
grpc_chttp2_transport* transport = nullptr; grpc_chttp2_transport* transport = nullptr;
{ {
MutexLock lock(&self->mu_); MutexLock lock(&self->mu_);
@ -683,14 +683,14 @@ grpc_error_handle Chttp2ServerListener::Create(
listener = new Chttp2ServerListener(server, args, args_modifier); listener = new Chttp2ServerListener(server, args, args_modifier);
error = grpc_tcp_server_create(&listener->tcp_server_shutdown_complete_, error = grpc_tcp_server_create(&listener->tcp_server_shutdown_complete_,
args, &listener->tcp_server_); args, &listener->tcp_server_);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
if (server->config_fetcher() != nullptr) { if (server->config_fetcher() != nullptr) {
listener->resolved_address_ = *addr; listener->resolved_address_ = *addr;
// TODO(yashykt): Consider binding so as to be able to return the port // TODO(yashykt): Consider binding so as to be able to return the port
// number. // number.
} else { } else {
error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
// Create channelz node. // Create channelz node.
if (grpc_channel_args_find_bool(args, GRPC_ARG_ENABLE_CHANNELZ, if (grpc_channel_args_find_bool(args, GRPC_ARG_ENABLE_CHANNELZ,
@ -709,7 +709,7 @@ grpc_error_handle Chttp2ServerListener::Create(
server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener)); server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
}(); }();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (listener != nullptr) { if (listener != nullptr) {
if (listener->tcp_server_ != nullptr) { if (listener->tcp_server_ != nullptr) {
// listener is deleted when tcp_server_ is shutdown. // listener is deleted when tcp_server_ is shutdown.
@ -731,7 +731,7 @@ grpc_error_handle Chttp2ServerListener::CreateWithAcceptor(
new Chttp2ServerListener(server, args, args_modifier); new Chttp2ServerListener(server, args, args_modifier);
grpc_error_handle error = grpc_tcp_server_create( grpc_error_handle error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_, args, &listener->tcp_server_); &listener->tcp_server_shutdown_complete_, args, &listener->tcp_server_);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
delete listener; delete listener;
return error; return error;
} }
@ -832,7 +832,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
} }
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
args = self->args_modifier_(*args_result, &error); args = self->args_modifier_(*args_result, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_DEBUG, "Closing connection: %s", gpr_log(GPR_DEBUG, "Closing connection: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
endpoint_cleanup(error); endpoint_cleanup(error);
@ -959,7 +959,7 @@ grpc_error_handle Chttp2ServerAddPort(Server* server, const char* addr,
error = Chttp2ServerListener::Create(server, &addr, error = Chttp2ServerListener::Create(server, &addr,
grpc_channel_args_copy(args), grpc_channel_args_copy(args),
args_modifier, &port_temp); args_modifier, &port_temp);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
error_list.push_back(error); error_list.push_back(error);
} else { } else {
if (*port_num == -1) { if (*port_num == -1) {
@ -992,7 +992,7 @@ grpc_error_handle Chttp2ServerAddPort(Server* server, const char* addr,
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
grpc_channel_args_destroy(args); grpc_channel_args_destroy(args);
if (error != GRPC_ERROR_NONE) *port_num = 0; if (!GRPC_ERROR_IS_NONE(error)) *port_num = 0;
return error; return error;
} }
@ -1076,7 +1076,7 @@ int grpc_server_add_http2_port(grpc_server* server, const char* addr,
ModifyArgsForConnection, &port_num); ModifyArgsForConnection, &port_num);
done: done:
sc.reset(DEBUG_LOCATION, "server"); sc.reset(DEBUG_LOCATION, "server");
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
gpr_log(GPR_ERROR, "%s", grpc_error_std_string(err).c_str()); gpr_log(GPR_ERROR, "%s", grpc_error_std_string(err).c_str());
GRPC_ERROR_UNREF(err); GRPC_ERROR_UNREF(err);
@ -1107,7 +1107,7 @@ void grpc_server_add_channel_from_fd(grpc_server* server, int fd,
); );
grpc_error_handle error = grpc_error_handle error =
core_server->SetupTransport(transport, nullptr, server_args, nullptr); core_server->SetupTransport(transport, nullptr, server_args, nullptr);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
for (grpc_pollset* pollset : core_server->pollsets()) { for (grpc_pollset* pollset : core_server->pollsets()) {
grpc_endpoint_add_to_pollset(server_endpoint, pollset); grpc_endpoint_add_to_pollset(server_endpoint, pollset);
} }

@ -584,13 +584,13 @@ static void close_transport_locked(grpc_chttp2_transport* t,
grpc_error_handle error) { grpc_error_handle error) {
end_all_the_calls(t, GRPC_ERROR_REF(error)); end_all_the_calls(t, GRPC_ERROR_REF(error));
cancel_pings(t, GRPC_ERROR_REF(error)); cancel_pings(t, GRPC_ERROR_REF(error));
if (t->closed_with_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(t->closed_with_error)) {
if (!grpc_error_has_clear_grpc_status(error)) { if (!grpc_error_has_clear_grpc_status(error)) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAVAILABLE); GRPC_STATUS_UNAVAILABLE);
} }
if (t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE) { if (t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE) {
if (t->close_transport_on_writes_finished == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(t->close_transport_on_writes_finished)) {
t->close_transport_on_writes_finished = t->close_transport_on_writes_finished =
GRPC_ERROR_CREATE_FROM_STATIC_STRING( GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Delayed close due to in-progress write"); "Delayed close due to in-progress write");
@ -599,7 +599,7 @@ static void close_transport_locked(grpc_chttp2_transport* t,
grpc_error_add_child(t->close_transport_on_writes_finished, error); grpc_error_add_child(t->close_transport_on_writes_finished, error);
return; return;
} }
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
t->closed_with_error = GRPC_ERROR_REF(error); t->closed_with_error = GRPC_ERROR_REF(error);
connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(), connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(),
"close_transport"); "close_transport");
@ -797,7 +797,7 @@ static void set_write_state(grpc_chttp2_transport* t,
// from peer while we had some pending writes) // from peer while we had some pending writes)
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) { if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &t->run_after_write); grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &t->run_after_write);
if (t->close_transport_on_writes_finished != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->close_transport_on_writes_finished)) {
grpc_error_handle err = t->close_transport_on_writes_finished; grpc_error_handle err = t->close_transport_on_writes_finished;
t->close_transport_on_writes_finished = GRPC_ERROR_NONE; t->close_transport_on_writes_finished = GRPC_ERROR_NONE;
close_transport_locked(t, err); close_transport_locked(t, err);
@ -919,7 +919,7 @@ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t, void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) { grpc_chttp2_stream* s) {
if (t->closed_with_error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(t->closed_with_error) &&
grpc_chttp2_list_add_writable_stream(t, s)) { grpc_chttp2_list_add_writable_stream(t, s)) {
GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:become"); GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:become");
} }
@ -939,7 +939,7 @@ static void write_action_begin_locked(void* gt,
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(gt); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(gt);
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE); GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
grpc_chttp2_begin_write_result r; grpc_chttp2_begin_write_result r;
if (t->closed_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->closed_with_error)) {
r.writing = false; r.writing = false;
} else { } else {
r = grpc_chttp2_begin_write(t); r = grpc_chttp2_begin_write(t);
@ -999,7 +999,7 @@ static void write_action_end_locked(void* tp, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
bool closed = false; bool closed = false;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
close_transport_locked(t, GRPC_ERROR_REF(error)); close_transport_locked(t, GRPC_ERROR_REF(error));
closed = true; closed = true;
} }
@ -1078,7 +1078,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
uint32_t last_stream_id, uint32_t last_stream_id,
absl::string_view goaway_text) { absl::string_view goaway_text) {
// Discard the error from a previous goaway frame (if any) // Discard the error from a previous goaway frame (if any)
if (t->goaway_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->goaway_error)) {
GRPC_ERROR_UNREF(t->goaway_error); GRPC_ERROR_UNREF(t->goaway_error);
} }
t->goaway_error = grpc_error_set_str( t->goaway_error = grpc_error_set_str(
@ -1148,7 +1148,7 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) {
grpc_chttp2_stream* s; grpc_chttp2_stream* s;
// maybe cancel out streams that haven't yet started if we have received a // maybe cancel out streams that haven't yet started if we have received a
// GOAWAY // GOAWAY
if (t->goaway_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->goaway_error)) {
cancel_unstarted_streams(t, GRPC_ERROR_REF(t->goaway_error)); cancel_unstarted_streams(t, GRPC_ERROR_REF(t->goaway_error));
return; return;
} }
@ -1240,7 +1240,7 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
desc, grpc_error_std_string(error).c_str(), desc, grpc_error_std_string(error).c_str(),
write_state_name(t->write_state)); write_state_name(t->write_state));
} }
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
#ifdef GRPC_ERROR_IS_ABSEIL_STATUS #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
grpc_error_handle cl_err = grpc_error_handle cl_err =
grpc_core::internal::StatusMoveFromHeapPtr(closure->error_data.error); grpc_core::internal::StatusMoveFromHeapPtr(closure->error_data.error);
@ -1248,7 +1248,7 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
grpc_error_handle cl_err = grpc_error_handle cl_err =
reinterpret_cast<grpc_error_handle>(closure->error_data.error); reinterpret_cast<grpc_error_handle>(closure->error_data.error);
#endif #endif
if (cl_err == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(cl_err)) {
cl_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING( cl_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error in HTTP transport completing operation"); "Error in HTTP transport completing operation");
cl_err = grpc_error_set_str(cl_err, GRPC_ERROR_STR_TARGET_ADDRESS, cl_err = grpc_error_set_str(cl_err, GRPC_ERROR_STR_TARGET_ADDRESS,
@ -1361,7 +1361,7 @@ static void perform_stream_op_locked(void* stream_op,
} }
if (!s->write_closed) { if (!s->write_closed) {
if (t->is_client) { if (t->is_client) {
if (t->closed_with_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(t->closed_with_error)) {
GPR_ASSERT(s->id == 0); GPR_ASSERT(s->id == 0);
grpc_chttp2_list_add_waiting_for_concurrency(t, s); grpc_chttp2_list_add_waiting_for_concurrency(t, s);
maybe_start_some_streams(t); maybe_start_some_streams(t);
@ -1593,7 +1593,7 @@ static void cancel_pings(grpc_chttp2_transport* t, grpc_error_handle error) {
// callback remaining pings: they're not allowed to call into the transport, // callback remaining pings: they're not allowed to call into the transport,
// and maybe they hold resources that need to be freed // and maybe they hold resources that need to be freed
grpc_chttp2_ping_queue* pq = &t->ping_queue; grpc_chttp2_ping_queue* pq = &t->ping_queue;
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) { for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error)); grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error));
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &pq->lists[j]); grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &pq->lists[j]);
@ -1603,7 +1603,7 @@ static void cancel_pings(grpc_chttp2_transport* t, grpc_error_handle error) {
static void send_ping_locked(grpc_chttp2_transport* t, static void send_ping_locked(grpc_chttp2_transport* t,
grpc_closure* on_initiate, grpc_closure* on_ack) { grpc_closure* on_initiate, grpc_closure* on_ack) {
if (t->closed_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->closed_with_error)) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_initiate, grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_initiate,
GRPC_ERROR_REF(t->closed_with_error)); GRPC_ERROR_REF(t->closed_with_error));
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_ack, grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_ack,
@ -1621,7 +1621,7 @@ static void send_ping_locked(grpc_chttp2_transport* t,
// a ping in progress, the keepalive ping would piggyback onto that ping, // a ping in progress, the keepalive ping would piggyback onto that ping,
// instead of waiting for that ping to complete and then starting a new ping. // instead of waiting for that ping to complete and then starting a new ping.
static void send_keepalive_ping_locked(grpc_chttp2_transport* t) { static void send_keepalive_ping_locked(grpc_chttp2_transport* t) {
if (t->closed_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->closed_with_error)) {
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked, t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
start_keepalive_ping_locked, t, nullptr), start_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(t->closed_with_error)); GRPC_ERROR_REF(t->closed_with_error));
@ -1666,7 +1666,7 @@ void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error_handle error) {
static void retry_initiate_ping_locked(void* tp, grpc_error_handle error) { static void retry_initiate_ping_locked(void* tp, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->ping_state.is_delayed_ping_timer_set = false; t->ping_state.is_delayed_ping_timer_set = false;
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
} }
GRPC_CHTTP2_UNREF_TRANSPORT(t, "retry_initiate_ping_locked"); GRPC_CHTTP2_UNREF_TRANSPORT(t, "retry_initiate_ping_locked");
@ -1723,7 +1723,7 @@ class GracefulGoaway : public grpc_core::RefCounted<GracefulGoaway> {
// We already sent the final GOAWAY. // We already sent the final GOAWAY.
return; return;
} }
if (t_->destroying || t_->closed_with_error != GRPC_ERROR_NONE) { if (t_->destroying || !GRPC_ERROR_IS_NONE(t_->closed_with_error)) {
GRPC_CHTTP2_IF_TRACING(gpr_log( GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_INFO, GPR_INFO,
"transport:%p %s peer:%s Transport already shutting down. " "transport:%p %s peer:%s Transport already shutting down. "
@ -1760,7 +1760,7 @@ class GracefulGoaway : public grpc_core::RefCounted<GracefulGoaway> {
static void OnTimer(void* arg, grpc_error_handle error) { static void OnTimer(void* arg, grpc_error_handle error) {
auto* self = static_cast<GracefulGoaway*>(arg); auto* self = static_cast<GracefulGoaway*>(arg);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
self->Unref(); self->Unref();
return; return;
} }
@ -1844,7 +1844,7 @@ static void perform_transport_op_locked(void* stream_op,
grpc_chttp2_transport* t = grpc_chttp2_transport* t =
static_cast<grpc_chttp2_transport*>(op->handler_private.extra_arg); static_cast<grpc_chttp2_transport*>(op->handler_private.extra_arg);
if (op->goaway_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->goaway_error)) {
send_goaway(t, op->goaway_error, /*immediate_disconnect_hint=*/false); send_goaway(t, op->goaway_error, /*immediate_disconnect_hint=*/false);
} }
@ -1874,7 +1874,7 @@ static void perform_transport_op_locked(void* stream_op,
t->state_tracker.RemoveWatcher(op->stop_connectivity_watch); t->state_tracker.RemoveWatcher(op->stop_connectivity_watch);
} }
if (op->disconnect_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->disconnect_with_error)) {
send_goaway(t, GRPC_ERROR_REF(op->disconnect_with_error), send_goaway(t, GRPC_ERROR_REF(op->disconnect_with_error),
/*immediate_disconnect_hint=*/true); /*immediate_disconnect_hint=*/true);
close_transport_locked(t, op->disconnect_with_error); close_transport_locked(t, op->disconnect_with_error);
@ -1951,7 +1951,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
} }
} else { } else {
error = absl::get<grpc_error_handle>(r); error = absl::get<grpc_error_handle>(r);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
s->seen_error = true; s->seen_error = true;
grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage); grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
break; break;
@ -1973,7 +1973,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
} }
// save the length of the buffer before handing control back to application // save the length of the buffer before handing control back to application
// threads. Needed to support correct flow control bookkeeping // threads. Needed to support correct flow control bookkeeping
if (error == GRPC_ERROR_NONE && s->recv_message->has_value()) { if (GRPC_ERROR_IS_NONE(error) && s->recv_message->has_value()) {
null_then_sched_closure(&s->recv_message_ready); null_then_sched_closure(&s->recv_message_ready);
} else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) { } else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) {
if (s->call_failed_before_recv_message != nullptr) { if (s->call_failed_before_recv_message != nullptr) {
@ -2052,7 +2052,7 @@ void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM);
} }
} }
if (due_to_error != GRPC_ERROR_NONE && !s->seen_error) { if (!GRPC_ERROR_IS_NONE(due_to_error) && !s->seen_error) {
s->seen_error = true; s->seen_error = true;
} }
grpc_chttp2_mark_stream_closed(t, s, 1, 1, due_to_error); grpc_chttp2_mark_stream_closed(t, s, 1, 1, due_to_error);
@ -2090,7 +2090,7 @@ void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
static void add_error(grpc_error_handle error, grpc_error_handle* refs, static void add_error(grpc_error_handle error, grpc_error_handle* refs,
size_t* nrefs) { size_t* nrefs) {
if (error == GRPC_ERROR_NONE) return; if (GRPC_ERROR_IS_NONE(error)) return;
for (size_t i = 0; i < *nrefs; i++) { for (size_t i = 0; i < *nrefs; i++) {
if (error == refs[i]) { if (error == refs[i]) {
return; return;
@ -2160,7 +2160,7 @@ void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
if (s->read_closed && s->write_closed) { if (s->read_closed && s->write_closed) {
// already closed, but we should still fake the status if needed. // already closed, but we should still fake the status if needed.
grpc_error_handle overall_error = removal_error(error, s, "Stream removed"); grpc_error_handle overall_error = removal_error(error, s, "Stream removed");
if (overall_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(overall_error)) {
grpc_chttp2_fake_status(t, s, overall_error); grpc_chttp2_fake_status(t, s, overall_error);
} }
grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
@ -2188,7 +2188,7 @@ void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
// Purge streams waiting on concurrency still waiting for id assignment // Purge streams waiting on concurrency still waiting for id assignment
grpc_chttp2_list_remove_waiting_for_concurrency(t, s); grpc_chttp2_list_remove_waiting_for_concurrency(t, s);
} }
if (overall_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(overall_error)) {
grpc_chttp2_fake_status(t, s, overall_error); grpc_chttp2_fake_status(t, s, overall_error);
} }
} }
@ -2446,11 +2446,11 @@ static grpc_error_handle try_http_parsing(grpc_chttp2_transport* t) {
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
grpc_error_handle parse_error = GRPC_ERROR_NONE; grpc_error_handle parse_error = GRPC_ERROR_NONE;
for (; i < t->read_buffer.count && parse_error == GRPC_ERROR_NONE; i++) { for (; i < t->read_buffer.count && GRPC_ERROR_IS_NONE(parse_error); i++) {
parse_error = parse_error =
grpc_http_parser_parse(&parser, t->read_buffer.slices[i], nullptr); grpc_http_parser_parse(&parser, t->read_buffer.slices[i], nullptr);
} }
if (parse_error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(parse_error) &&
(parse_error = grpc_http_parser_eof(&parser)) == GRPC_ERROR_NONE) { (parse_error = grpc_http_parser_eof(&parser)) == GRPC_ERROR_NONE) {
error = grpc_error_set_int( error = grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@ -2481,7 +2481,7 @@ static void read_action_locked(void* tp, grpc_error_handle error) {
(void)GRPC_ERROR_REF(error); (void)GRPC_ERROR_REF(error);
grpc_error_handle err = error; grpc_error_handle err = error;
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
err = grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( err = grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint read failed", &err, 1), "Endpoint read failed", &err, 1),
GRPC_ERROR_INT_OCCURRED_DURING_WRITE, GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
@ -2489,7 +2489,7 @@ static void read_action_locked(void* tp, grpc_error_handle error) {
} }
std::swap(err, error); std::swap(err, error);
GRPC_ERROR_UNREF(err); GRPC_ERROR_UNREF(err);
if (t->closed_with_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(t->closed_with_error)) {
GPR_TIMER_SCOPE("reading_action.parse", 0); GPR_TIMER_SCOPE("reading_action.parse", 0);
size_t i = 0; size_t i = 0;
grpc_error_handle errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE, grpc_error_handle errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
@ -2523,20 +2523,20 @@ static void read_action_locked(void* tp, grpc_error_handle error) {
GPR_TIMER_SCOPE("post_reading_action_locked", 0); GPR_TIMER_SCOPE("post_reading_action_locked", 0);
bool keep_reading = false; bool keep_reading = false;
if (error == GRPC_ERROR_NONE && t->closed_with_error != GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error) && !GRPC_ERROR_IS_NONE(t->closed_with_error)) {
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Transport closed", &t->closed_with_error, 1); "Transport closed", &t->closed_with_error, 1);
} }
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// If a goaway frame was received, this might be the reason why the read // If a goaway frame was received, this might be the reason why the read
// failed. Add this info to the error // failed. Add this info to the error
if (t->goaway_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(t->goaway_error)) {
error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error)); error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error));
} }
close_transport_locked(t, GRPC_ERROR_REF(error)); close_transport_locked(t, GRPC_ERROR_REF(error));
t->endpoint_reading = 0; t->endpoint_reading = 0;
} else if (t->closed_with_error == GRPC_ERROR_NONE) { } else if (GRPC_ERROR_IS_NONE(t->closed_with_error)) {
keep_reading = true; keep_reading = true;
// Since we have read a byte, reset the keepalive timer // Since we have read a byte, reset the keepalive timer
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) { if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
@ -2564,7 +2564,7 @@ static void read_action_locked(void* tp, grpc_error_handle error) {
} }
static void continue_read_action_locked(grpc_chttp2_transport* t) { static void continue_read_action_locked(grpc_chttp2_transport* t) {
const bool urgent = t->goaway_error != GRPC_ERROR_NONE; const bool urgent = !GRPC_ERROR_IS_NONE(t->goaway_error);
GRPC_CLOSURE_INIT(&t->read_action_locked, read_action, t, GRPC_CLOSURE_INIT(&t->read_action_locked, read_action, t,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent, grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent,
@ -2598,7 +2598,7 @@ static void start_bdp_ping_locked(void* tp, grpc_error_handle error) {
gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", t->peer_string.c_str(), gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", t->peer_string.c_str(),
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
} }
if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error) || !GRPC_ERROR_IS_NONE(t->closed_with_error)) {
return; return;
} }
// Reset the keepalive ping timer // Reset the keepalive ping timer
@ -2622,7 +2622,7 @@ static void finish_bdp_ping_locked(void* tp, grpc_error_handle error) {
gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", t->peer_string.c_str(), gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", t->peer_string.c_str(),
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
} }
if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error) || !GRPC_ERROR_IS_NONE(t->closed_with_error)) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
return; return;
} }
@ -2660,7 +2660,7 @@ static void next_bdp_ping_timer_expired_locked(void* tp,
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
GPR_ASSERT(t->have_next_bdp_ping_timer); GPR_ASSERT(t->have_next_bdp_ping_timer);
t->have_next_bdp_ping_timer = false; t->have_next_bdp_ping_timer = false;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
return; return;
} }
@ -2742,9 +2742,9 @@ static void init_keepalive_ping(void* arg, grpc_error_handle error) {
static void init_keepalive_ping_locked(void* arg, grpc_error_handle error) { static void init_keepalive_ping_locked(void* arg, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING); GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
if (t->destroying || t->closed_with_error != GRPC_ERROR_NONE) { if (t->destroying || !GRPC_ERROR_IS_NONE(t->closed_with_error)) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
} else if (error == GRPC_ERROR_NONE) { } else if (GRPC_ERROR_IS_NONE(error)) {
if (t->keepalive_permit_without_calls || if (t->keepalive_permit_without_calls ||
grpc_chttp2_stream_map_size(&t->stream_map) > 0) { grpc_chttp2_stream_map_size(&t->stream_map) > 0) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING;
@ -2781,7 +2781,7 @@ static void start_keepalive_ping(void* arg, grpc_error_handle error) {
static void start_keepalive_ping_locked(void* arg, grpc_error_handle error) { static void start_keepalive_ping_locked(void* arg, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
return; return;
} }
if (t->channelz_socket != nullptr) { if (t->channelz_socket != nullptr) {
@ -2810,7 +2810,7 @@ static void finish_keepalive_ping(void* arg, grpc_error_handle error) {
static void finish_keepalive_ping_locked(void* arg, grpc_error_handle error) { static void finish_keepalive_ping_locked(void* arg, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) { if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) {
gpr_log(GPR_INFO, "%s: Finish keepalive ping", t->peer_string.c_str()); gpr_log(GPR_INFO, "%s: Finish keepalive ping", t->peer_string.c_str());
@ -2850,7 +2850,7 @@ static void keepalive_watchdog_fired_locked(void* arg,
grpc_error_handle error) { grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) { if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_INFO, "%s: Keepalive watchdog fired. Closing transport.", gpr_log(GPR_INFO, "%s: Keepalive watchdog fired. Closing transport.",
t->peer_string.c_str()); t->peer_string.c_str());
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
@ -2946,7 +2946,7 @@ static void post_destructive_reclaimer(grpc_chttp2_transport* t) {
static void benign_reclaimer_locked(void* arg, grpc_error_handle error) { static void benign_reclaimer_locked(void* arg, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(error) &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) { grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
// Channel with no active streams: send a goaway to try and make it // Channel with no active streams: send a goaway to try and make it
// disconnect cleanly // disconnect cleanly
@ -2959,7 +2959,7 @@ static void benign_reclaimer_locked(void* arg, grpc_error_handle error) {
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM), GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM),
/*immediate_disconnect_hint=*/true); /*immediate_disconnect_hint=*/true);
} else if (error == GRPC_ERROR_NONE && } else if (GRPC_ERROR_IS_NONE(error) &&
GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) { GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR "HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR
@ -2978,7 +2978,7 @@ static void destructive_reclaimer_locked(void* arg, grpc_error_handle error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg); grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
size_t n = grpc_chttp2_stream_map_size(&t->stream_map); size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
t->destructive_reclaimer_registered = false; t->destructive_reclaimer_registered = false;
if (error == GRPC_ERROR_NONE && n > 0) { if (GRPC_ERROR_IS_NONE(error) && n > 0) {
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>( grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(
grpc_chttp2_stream_map_rand(&t->stream_map)); grpc_chttp2_stream_map_rand(&t->stream_map));
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {

@ -600,7 +600,7 @@ class HPackParser::Input {
// Set the current error - allows the rest of the code not to need to pass // Set the current error - allows the rest of the code not to need to pass
// around StatusOr<> which would be prohibitive here. // around StatusOr<> which would be prohibitive here.
GPR_ATTRIBUTE_NOINLINE void SetError(grpc_error_handle error) { GPR_ATTRIBUTE_NOINLINE void SetError(grpc_error_handle error) {
if (error_ != GRPC_ERROR_NONE || eof_error_) { if (!GRPC_ERROR_IS_NONE(error_) || eof_error_) {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return; return;
} }
@ -613,7 +613,7 @@ class HPackParser::Input {
template <typename F, typename T> template <typename F, typename T>
GPR_ATTRIBUTE_NOINLINE T MaybeSetErrorAndReturn(F error_factory, GPR_ATTRIBUTE_NOINLINE T MaybeSetErrorAndReturn(F error_factory,
T return_value) { T return_value) {
if (error_ != GRPC_ERROR_NONE || eof_error_) return return_value; if (!GRPC_ERROR_IS_NONE(error_) || eof_error_) return return_value;
error_ = error_factory(); error_ = error_factory();
begin_ = end_; begin_ = end_;
return return_value; return return_value;
@ -623,7 +623,7 @@ class HPackParser::Input {
// is a common case) // is a common case)
template <typename T> template <typename T>
T UnexpectedEOF(T return_value) { T UnexpectedEOF(T return_value) {
if (error_ != GRPC_ERROR_NONE) return return_value; if (!GRPC_ERROR_IS_NONE(error_)) return return_value;
eof_error_ = true; eof_error_ = true;
return return_value; return return_value;
} }
@ -1089,7 +1089,7 @@ class HPackParser::Parser {
auto r = EmitHeader(*md); auto r = EmitHeader(*md);
// Add to the hpack table // Add to the hpack table
grpc_error_handle err = table_->Add(std::move(*md)); grpc_error_handle err = table_->Add(std::move(*md));
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) { if (GPR_UNLIKELY(!GRPC_ERROR_IS_NONE(err))) {
input_->SetError(err); input_->SetError(err);
return false; return false;
}; };
@ -1185,7 +1185,7 @@ class HPackParser::Parser {
} }
(*dynamic_table_updates_allowed_)--; (*dynamic_table_updates_allowed_)--;
grpc_error_handle err = table_->SetCurrentTableSize(*size); grpc_error_handle err = table_->SetCurrentTableSize(*size);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
input_->SetError(err); input_->SetError(err);
return false; return false;
} }
@ -1360,7 +1360,7 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice); s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
} }
grpc_error_handle error = parser->Parse(slice, is_last != 0); grpc_error_handle error = parser->Parse(slice, is_last != 0);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
return error; return error;
} }
if (is_last) { if (is_last) {

@ -204,12 +204,12 @@ grpc_error_handle grpc_chttp2_perform_read(grpc_chttp2_transport* t,
t->incoming_stream_id |= (static_cast<uint32_t>(*cur)); t->incoming_stream_id |= (static_cast<uint32_t>(*cur));
t->deframe_state = GRPC_DTS_FRAME; t->deframe_state = GRPC_DTS_FRAME;
err = init_frame_parser(t); err = init_frame_parser(t);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
if (t->incoming_frame_size == 0) { if (t->incoming_frame_size == 0) {
err = parse_frame_slice(t, grpc_empty_slice(), 1); err = parse_frame_slice(t, grpc_empty_slice(), 1);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
t->incoming_stream = nullptr; t->incoming_stream = nullptr;
@ -239,7 +239,7 @@ grpc_error_handle grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice_sub_no_ref(slice, static_cast<size_t>(cur - beg), grpc_slice_sub_no_ref(slice, static_cast<size_t>(cur - beg),
static_cast<size_t>(end - beg)), static_cast<size_t>(end - beg)),
1); 1);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
t->deframe_state = GRPC_DTS_FH_0; t->deframe_state = GRPC_DTS_FH_0;
@ -252,7 +252,7 @@ grpc_error_handle grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice_sub_no_ref(slice, cur_offset, grpc_slice_sub_no_ref(slice, cur_offset,
cur_offset + t->incoming_frame_size), cur_offset + t->incoming_frame_size),
1); 1);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
cur += t->incoming_frame_size; cur += t->incoming_frame_size;
@ -264,7 +264,7 @@ grpc_error_handle grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice_sub_no_ref(slice, static_cast<size_t>(cur - beg), grpc_slice_sub_no_ref(slice, static_cast<size_t>(cur - beg),
static_cast<size_t>(end - beg)), static_cast<size_t>(end - beg)),
0); 0);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
t->incoming_frame_size -= static_cast<uint32_t>(end - cur); t->incoming_frame_size -= static_cast<uint32_t>(end - cur);
@ -582,7 +582,7 @@ static grpc_error_handle init_window_update_frame_parser(
grpc_error_handle err = grpc_chttp2_window_update_parser_begin_frame( grpc_error_handle err = grpc_chttp2_window_update_parser_begin_frame(
&t->simple.window_update, t->incoming_frame_size, &t->simple.window_update, t->incoming_frame_size,
t->incoming_frame_flags); t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
if (t->incoming_stream_id != 0) { if (t->incoming_stream_id != 0) {
grpc_chttp2_stream* s = t->incoming_stream = grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
@ -599,7 +599,7 @@ static grpc_error_handle init_window_update_frame_parser(
static grpc_error_handle init_ping_parser(grpc_chttp2_transport* t) { static grpc_error_handle init_ping_parser(grpc_chttp2_transport* t) {
grpc_error_handle err = grpc_chttp2_ping_parser_begin_frame( grpc_error_handle err = grpc_chttp2_ping_parser_begin_frame(
&t->simple.ping, t->incoming_frame_size, t->incoming_frame_flags); &t->simple.ping, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
t->parser = grpc_chttp2_ping_parser_parse; t->parser = grpc_chttp2_ping_parser_parse;
t->parser_data = &t->simple.ping; t->parser_data = &t->simple.ping;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -608,7 +608,7 @@ static grpc_error_handle init_ping_parser(grpc_chttp2_transport* t) {
static grpc_error_handle init_rst_stream_parser(grpc_chttp2_transport* t) { static grpc_error_handle init_rst_stream_parser(grpc_chttp2_transport* t) {
grpc_error_handle err = grpc_chttp2_rst_stream_parser_begin_frame( grpc_error_handle err = grpc_chttp2_rst_stream_parser_begin_frame(
&t->simple.rst_stream, t->incoming_frame_size, t->incoming_frame_flags); &t->simple.rst_stream, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
grpc_chttp2_stream* s = t->incoming_stream = grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (!t->incoming_stream) { if (!t->incoming_stream) {
@ -623,7 +623,7 @@ static grpc_error_handle init_rst_stream_parser(grpc_chttp2_transport* t) {
static grpc_error_handle init_goaway_parser(grpc_chttp2_transport* t) { static grpc_error_handle init_goaway_parser(grpc_chttp2_transport* t) {
grpc_error_handle err = grpc_chttp2_goaway_parser_begin_frame( grpc_error_handle err = grpc_chttp2_goaway_parser_begin_frame(
&t->goaway_parser, t->incoming_frame_size, t->incoming_frame_flags); &t->goaway_parser, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
t->parser = grpc_chttp2_goaway_parser_parse; t->parser = grpc_chttp2_goaway_parser_parse;
t->parser_data = &t->goaway_parser; t->parser_data = &t->goaway_parser;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -638,7 +638,7 @@ static grpc_error_handle init_settings_frame_parser(grpc_chttp2_transport* t) {
grpc_error_handle err = grpc_chttp2_settings_parser_begin_frame( grpc_error_handle err = grpc_chttp2_settings_parser_begin_frame(
&t->simple.settings, t->incoming_frame_size, t->incoming_frame_flags, &t->simple.settings, t->incoming_frame_size, t->incoming_frame_flags,
t->settings[GRPC_PEER_SETTINGS]); t->settings[GRPC_PEER_SETTINGS]);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
if (t->incoming_frame_flags & GRPC_CHTTP2_FLAG_ACK) { if (t->incoming_frame_flags & GRPC_CHTTP2_FLAG_ACK) {
@ -664,7 +664,7 @@ static grpc_error_handle parse_frame_slice(grpc_chttp2_transport* t,
grpc_chttp2_stream* s = t->incoming_stream; grpc_chttp2_stream* s = t->incoming_stream;
grpc_error_handle err = t->parser(t->parser_data, t, s, slice, is_last); grpc_error_handle err = t->parser(t->parser_data, t, s, slice, is_last);
intptr_t unused; intptr_t unused;
if (GPR_LIKELY(err == GRPC_ERROR_NONE)) { if (GPR_LIKELY(GRPC_ERROR_IS_NONE(err))) {
return err; return err;
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, &unused)) { } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, &unused)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {

@ -334,7 +334,7 @@ class WriteContext {
void UpdateStreamsNoLongerStalled() { void UpdateStreamsNoLongerStalled() {
grpc_chttp2_stream* s; grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_stalled_by_transport(t_, &s)) { while (grpc_chttp2_list_pop_stalled_by_transport(t_, &s)) {
if (t_->closed_with_error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(t_->closed_with_error) &&
grpc_chttp2_list_add_writable_stream(t_, s)) { grpc_chttp2_list_add_writable_stream(t_, s)) {
if (!s->refcount->refs.RefIfNonZero()) { if (!s->refcount->refs.RefIfNonZero()) {
grpc_chttp2_list_remove_writable_stream(t_, s); grpc_chttp2_list_remove_writable_stream(t_, s);

@ -1326,7 +1326,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
result = ACTION_TAKEN_NO_CALLBACK; result = ACTION_TAKEN_NO_CALLBACK;
} }
stream_state->state_op_done[OP_CANCEL_ERROR] = true; stream_state->state_op_done[OP_CANCEL_ERROR] = true;
if (stream_state->cancel_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(stream_state->cancel_error)) {
stream_state->cancel_error = stream_state->cancel_error =
GRPC_ERROR_REF(stream_op->payload->cancel_stream.cancel_error); GRPC_ERROR_REF(stream_op->payload->cancel_stream.cancel_error);
} }

@ -210,7 +210,7 @@ struct inproc_stream {
cs->write_buffer_trailing_md.Clear(); cs->write_buffer_trailing_md.Clear();
cs->write_buffer_trailing_md_filled = false; cs->write_buffer_trailing_md_filled = false;
} }
if (cs->write_buffer_cancel_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(cs->write_buffer_cancel_error)) {
cancel_other_error = cs->write_buffer_cancel_error; cancel_other_error = cs->write_buffer_cancel_error;
cs->write_buffer_cancel_error = GRPC_ERROR_NONE; cs->write_buffer_cancel_error = GRPC_ERROR_NONE;
maybe_process_ops_locked(this, cancel_other_error); maybe_process_ops_locked(this, cancel_other_error);
@ -433,7 +433,7 @@ void complete_if_batch_end_locked(inproc_stream* s, grpc_error_handle error,
} }
void maybe_process_ops_locked(inproc_stream* s, grpc_error_handle error) { void maybe_process_ops_locked(inproc_stream* s, grpc_error_handle error) {
if (s && (error != GRPC_ERROR_NONE || s->ops_needed)) { if (s && (!GRPC_ERROR_IS_NONE(error) || s->ops_needed)) {
s->ops_needed = false; s->ops_needed = false;
op_state_machine_locked(s, error); op_state_machine_locked(s, error);
} }
@ -457,11 +457,11 @@ void fail_helper_locked(inproc_stream* s, grpc_error_handle error) {
(void)fill_in_metadata(s, &fake_md, 0, dest, nullptr, destfilled); (void)fill_in_metadata(s, &fake_md, 0, dest, nullptr, destfilled);
if (other != nullptr) { if (other != nullptr) {
if (other->cancel_other_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(other->cancel_other_error)) {
other->cancel_other_error = GRPC_ERROR_REF(error); other->cancel_other_error = GRPC_ERROR_REF(error);
} }
maybe_process_ops_locked(other, error); maybe_process_ops_locked(other, error);
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) { } else if (GRPC_ERROR_IS_NONE(s->write_buffer_cancel_error)) {
s->write_buffer_cancel_error = GRPC_ERROR_REF(error); s->write_buffer_cancel_error = GRPC_ERROR_REF(error);
} }
} }
@ -606,13 +606,13 @@ void op_state_machine_locked(inproc_stream* s, grpc_error_handle error) {
// cancellation takes precedence // cancellation takes precedence
inproc_stream* other = s->other_side; inproc_stream* other = s->other_side;
if (s->cancel_self_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(s->cancel_self_error)) {
fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_self_error)); fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_self_error));
goto done; goto done;
} else if (s->cancel_other_error != GRPC_ERROR_NONE) { } else if (!GRPC_ERROR_IS_NONE(s->cancel_other_error)) {
fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_other_error)); fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_other_error));
goto done; goto done;
} else if (error != GRPC_ERROR_NONE) { } else if (!GRPC_ERROR_IS_NONE(error)) {
fail_helper_locked(s, GRPC_ERROR_REF(error)); fail_helper_locked(s, GRPC_ERROR_REF(error));
goto done; goto done;
} }
@ -885,7 +885,7 @@ bool cancel_stream_locked(inproc_stream* s, grpc_error_handle error) {
bool ret = false; // was the cancel accepted bool ret = false; // was the cancel accepted
INPROC_LOG(GPR_INFO, "cancel_stream %p with %s", s, INPROC_LOG(GPR_INFO, "cancel_stream %p with %s", s,
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
if (s->cancel_self_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(s->cancel_self_error)) {
ret = true; ret = true;
s->cancel_self_error = GRPC_ERROR_REF(error); s->cancel_self_error = GRPC_ERROR_REF(error);
// Catch current value of other before it gets closed off // Catch current value of other before it gets closed off
@ -905,11 +905,11 @@ bool cancel_stream_locked(inproc_stream* s, grpc_error_handle error) {
(void)fill_in_metadata(s, &cancel_md, 0, dest, nullptr, destfilled); (void)fill_in_metadata(s, &cancel_md, 0, dest, nullptr, destfilled);
if (other != nullptr) { if (other != nullptr) {
if (other->cancel_other_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(other->cancel_other_error)) {
other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error); other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
} }
maybe_process_ops_locked(other, other->cancel_other_error); maybe_process_ops_locked(other, other->cancel_other_error);
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) { } else if (GRPC_ERROR_IS_NONE(s->write_buffer_cancel_error)) {
s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error); s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error);
} }
@ -972,7 +972,7 @@ void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
// this function is responsible to make sure that that field gets unref'ed // this function is responsible to make sure that that field gets unref'ed
cancel_stream_locked(s, op->payload->cancel_stream.cancel_error); cancel_stream_locked(s, op->payload->cancel_stream.cancel_error);
// this op can complete without an error // this op can complete without an error
} else if (s->cancel_self_error != GRPC_ERROR_NONE) { } else if (!GRPC_ERROR_IS_NONE(s->cancel_self_error)) {
// already self-canceled so still give it an error // already self-canceled so still give it an error
error = GRPC_ERROR_REF(s->cancel_self_error); error = GRPC_ERROR_REF(s->cancel_self_error);
} else { } else {
@ -987,12 +987,12 @@ void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
} }
inproc_stream* other = s->other_side; inproc_stream* other = s->other_side;
if (error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(error) &&
(op->send_initial_metadata || op->send_trailing_metadata)) { (op->send_initial_metadata || op->send_trailing_metadata)) {
if (s->t->is_closed) { if (s->t->is_closed) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
} }
if (error == GRPC_ERROR_NONE && op->send_initial_metadata) { if (GRPC_ERROR_IS_NONE(error) && op->send_initial_metadata) {
grpc_metadata_batch* dest = (other == nullptr) grpc_metadata_batch* dest = (other == nullptr)
? &s->write_buffer_initial_md ? &s->write_buffer_initial_md
: &other->to_read_initial_md; : &other->to_read_initial_md;
@ -1026,7 +1026,7 @@ void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
} }
} }
if (error == GRPC_ERROR_NONE && if (GRPC_ERROR_IS_NONE(error) &&
(op->send_message || op->send_trailing_metadata || (op->send_message || op->send_trailing_metadata ||
op->recv_initial_metadata || op->recv_message || op->recv_initial_metadata || op->recv_message ||
op->recv_trailing_metadata)) { op->recv_trailing_metadata)) {
@ -1066,7 +1066,7 @@ void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
s->ops_needed = true; s->ops_needed = true;
} }
} else { } else {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// Consume any send message that was sent here but that we are not // Consume any send message that was sent here but that we are not
// pushing to the other side // pushing to the other side
if (op->send_message) { if (op->send_message) {
@ -1162,11 +1162,11 @@ void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
} }
bool do_close = false; bool do_close = false;
if (op->goaway_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->goaway_error)) {
do_close = true; do_close = true;
GRPC_ERROR_UNREF(op->goaway_error); GRPC_ERROR_UNREF(op->goaway_error);
} }
if (op->disconnect_with_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(op->disconnect_with_error)) {
do_close = true; do_close = true;
GRPC_ERROR_UNREF(op->disconnect_with_error); GRPC_ERROR_UNREF(op->disconnect_with_error);
} }
@ -1280,7 +1280,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
grpc_error_handle error = core_server->SetupTransport( grpc_error_handle error = core_server->SetupTransport(
server_transport, nullptr, server_args, nullptr); server_transport, nullptr, server_args, nullptr);
grpc_channel* channel = nullptr; grpc_channel* channel = nullptr;
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
auto new_channel = grpc_core::Channel::Create( auto new_channel = grpc_core::Channel::Create(
"inproc", grpc_core::ChannelArgs::FromC(client_args), "inproc", grpc_core::ChannelArgs::FromC(client_args),
GRPC_CLIENT_DIRECT_CHANNEL, client_transport); GRPC_CLIENT_DIRECT_CHANNEL, client_transport);

@ -302,7 +302,7 @@ grpc_slice XdsApi::CreateAdsRequest(
} }
// Set error_detail if it's a NACK. // Set error_detail if it's a NACK.
std::string error_string_storage; std::string error_string_storage;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
google_rpc_Status* error_detail = google_rpc_Status* error_detail =
envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail( envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
request, arena.ptr()); request, arena.ptr());

@ -92,7 +92,7 @@ grpc_error_handle ParseChannelCredsArray(const Json::Array& json,
} else { } else {
grpc_error_handle parse_error = grpc_error_handle parse_error =
ParseChannelCreds(child.object_value(), i, server); ParseChannelCreds(child.object_value(), i, server);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
if (server->channel_creds_type.empty()) { if (server->channel_creds_type.empty()) {
@ -121,7 +121,7 @@ XdsBootstrap::XdsServer XdsBootstrap::XdsServer::Parse(
if (creds_array != nullptr) { if (creds_array != nullptr) {
grpc_error_handle parse_error = grpc_error_handle parse_error =
ParseChannelCredsArray(*creds_array, &server); ParseChannelCredsArray(*creds_array, &server);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
const Json::Array* server_features_array = nullptr; const Json::Array* server_features_array = nullptr;
ParseJsonObjectField(json.object_value(), "server_features", ParseJsonObjectField(json.object_value(), "server_features",
@ -169,7 +169,7 @@ bool XdsBootstrap::XdsServer::ShouldUseV3() const {
std::unique_ptr<XdsBootstrap> XdsBootstrap::Create( std::unique_ptr<XdsBootstrap> XdsBootstrap::Create(
absl::string_view json_string, grpc_error_handle* error) { absl::string_view json_string, grpc_error_handle* error) {
Json json = Json::Parse(json_string, error); Json json = Json::Parse(json_string, error);
if (*error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(*error)) {
grpc_error_handle error_out = grpc_error_handle error_out =
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to parse bootstrap JSON string", error, 1); "Failed to parse bootstrap JSON string", error, 1);
@ -196,7 +196,7 @@ XdsBootstrap::XdsBootstrap(Json json, grpc_error_handle* error) {
"\"xds_servers\" field is not an array")); "\"xds_servers\" field is not an array"));
} else { } else {
grpc_error_handle parse_error = ParseXdsServerList(&it->second, &servers_); grpc_error_handle parse_error = ParseXdsServerList(&it->second, &servers_);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
it = json.mutable_object()->find("node"); it = json.mutable_object()->find("node");
if (it != json.mutable_object()->end()) { if (it != json.mutable_object()->end()) {
@ -205,7 +205,7 @@ XdsBootstrap::XdsBootstrap(Json json, grpc_error_handle* error) {
"\"node\" field is not an object")); "\"node\" field is not an object"));
} else { } else {
grpc_error_handle parse_error = ParseNode(&it->second); grpc_error_handle parse_error = ParseNode(&it->second);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
if (XdsFederationEnabled()) { if (XdsFederationEnabled()) {
@ -216,7 +216,7 @@ XdsBootstrap::XdsBootstrap(Json json, grpc_error_handle* error) {
"\"authorities\" field is not an object")); "\"authorities\" field is not an object"));
} else { } else {
grpc_error_handle parse_error = ParseAuthorities(&it->second); grpc_error_handle parse_error = ParseAuthorities(&it->second);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
it = json.mutable_object()->find( it = json.mutable_object()->find(
@ -249,7 +249,7 @@ XdsBootstrap::XdsBootstrap(Json json, grpc_error_handle* error) {
"\"certificate_providers\" field is not an object")); "\"certificate_providers\" field is not an object"));
} else { } else {
grpc_error_handle parse_error = ParseCertificateProviders(&it->second); grpc_error_handle parse_error = ParseCertificateProviders(&it->second);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
*error = GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing xds bootstrap file", *error = GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing xds bootstrap file",
@ -287,7 +287,7 @@ grpc_error_handle XdsBootstrap::ParseXdsServerList(
} else { } else {
grpc_error_handle parse_error; grpc_error_handle parse_error;
servers->emplace_back(XdsServer::Parse(child, &parse_error)); servers->emplace_back(XdsServer::Parse(child, &parse_error));
if (parse_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parse_error)) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING( error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrCat("errors parsing index ", i))); absl::StrCat("errors parsing index ", i)));
error_list.push_back(parse_error); error_list.push_back(parse_error);
@ -307,7 +307,7 @@ grpc_error_handle XdsBootstrap::ParseAuthorities(Json* json) {
continue; continue;
} }
grpc_error_handle parse_error = ParseAuthority(&p.second, p.first); grpc_error_handle parse_error = ParseAuthority(&p.second, p.first);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing \"authorities\"", return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing \"authorities\"",
&error_list); &error_list);
@ -344,7 +344,7 @@ grpc_error_handle XdsBootstrap::ParseAuthority(Json* json,
} else { } else {
grpc_error_handle parse_error = grpc_error_handle parse_error =
ParseXdsServerList(&it->second, &authority.xds_servers); ParseXdsServerList(&it->second, &authority.xds_servers);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
if (error_list.empty()) { if (error_list.empty()) {
@ -382,7 +382,7 @@ grpc_error_handle XdsBootstrap::ParseNode(Json* json) {
"\"locality\" field is not an object")); "\"locality\" field is not an object"));
} else { } else {
grpc_error_handle parse_error = ParseLocality(&it->second); grpc_error_handle parse_error = ParseLocality(&it->second);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
it = json->mutable_object()->find("metadata"); it = json->mutable_object()->find("metadata");
@ -440,7 +440,7 @@ grpc_error_handle XdsBootstrap::ParseCertificateProviders(Json* json) {
} else { } else {
grpc_error_handle parse_error = ParseCertificateProvider( grpc_error_handle parse_error = ParseCertificateProvider(
certificate_provider.first, &certificate_provider.second); certificate_provider.first, &certificate_provider.second);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
} }
return GRPC_ERROR_CREATE_FROM_VECTOR( return GRPC_ERROR_CREATE_FROM_VECTOR(
@ -476,14 +476,16 @@ grpc_error_handle XdsBootstrap::ParseCertificateProvider(
grpc_error_handle parse_error = GRPC_ERROR_NONE; grpc_error_handle parse_error = GRPC_ERROR_NONE;
config = factory->CreateCertificateProviderConfig(it->second, config = factory->CreateCertificateProviderConfig(it->second,
&parse_error); &parse_error);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) {
error_list.push_back(parse_error);
}
} }
} else { } else {
// "config" is an optional field, so create an empty JSON object. // "config" is an optional field, so create an empty JSON object.
grpc_error_handle parse_error = GRPC_ERROR_NONE; grpc_error_handle parse_error = GRPC_ERROR_NONE;
config = factory->CreateCertificateProviderConfig(Json::Object(), config = factory->CreateCertificateProviderConfig(Json::Object(),
&parse_error); &parse_error);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (!GRPC_ERROR_IS_NONE(parse_error)) error_list.push_back(parse_error);
} }
certificate_providers_.insert( certificate_providers_.insert(
{instance_name, {std::move(plugin_name), std::move(config)}}); {instance_name, {std::move(plugin_name), std::move(config)}});

@ -60,7 +60,7 @@ class RootCertificatesWatcher
void OnError(grpc_error_handle root_cert_error, void OnError(grpc_error_handle root_cert_error,
grpc_error_handle identity_cert_error) override { grpc_error_handle identity_cert_error) override {
if (root_cert_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(root_cert_error)) {
parent_->SetErrorForCert(cert_name_, root_cert_error /* pass the ref */, parent_->SetErrorForCert(cert_name_, root_cert_error /* pass the ref */,
absl::nullopt); absl::nullopt);
} }
@ -95,7 +95,7 @@ class IdentityCertificatesWatcher
void OnError(grpc_error_handle root_cert_error, void OnError(grpc_error_handle root_cert_error,
grpc_error_handle identity_cert_error) override { grpc_error_handle identity_cert_error) override {
if (identity_cert_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(identity_cert_error)) {
parent_->SetErrorForCert(cert_name_, absl::nullopt, parent_->SetErrorForCert(cert_name_, absl::nullopt,
identity_cert_error /* pass the ref */); identity_cert_error /* pass the ref */);
} }

@ -271,7 +271,7 @@ class XdsClient::ChannelState::AdsCallState
void OnTimerLocked(grpc_error_handle error) void OnTimerLocked(grpc_error_handle error)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsClient::mu_) { ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsClient::mu_) {
if (error == GRPC_ERROR_NONE && timer_pending_) { if (GRPC_ERROR_IS_NONE(error) && timer_pending_) {
timer_pending_ = false; timer_pending_ = false;
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -744,7 +744,7 @@ template <typename T>
void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked( void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked(
grpc_error_handle error) { grpc_error_handle error) {
retry_timer_callback_pending_ = false; retry_timer_callback_pending_ = false;
if (!shutting_down_ && error == GRPC_ERROR_NONE) { if (!shutting_down_ && GRPC_ERROR_IS_NONE(error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[xds_client %p] xds server %s: retry timer fired (retryable " "[xds_client %p] xds server %s: retry timer fired (retryable "
@ -1143,7 +1143,7 @@ void XdsClient::ChannelState::AdsCallState::OnRequestSent(
void XdsClient::ChannelState::AdsCallState::OnRequestSentLocked( void XdsClient::ChannelState::AdsCallState::OnRequestSentLocked(
grpc_error_handle error) { grpc_error_handle error) {
if (IsCurrentCallOnChannel() && error == GRPC_ERROR_NONE) { if (IsCurrentCallOnChannel() && GRPC_ERROR_IS_NONE(error)) {
// Clean up the sent message. // Clean up the sent message.
grpc_byte_buffer_destroy(send_message_payload_); grpc_byte_buffer_destroy(send_message_payload_);
send_message_payload_ = nullptr; send_message_payload_ = nullptr;
@ -1382,7 +1382,7 @@ void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimer(
bool XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked( bool XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked(
grpc_error_handle error) { grpc_error_handle error) {
next_report_timer_callback_pending_ = false; next_report_timer_callback_pending_ = false;
if (error != GRPC_ERROR_NONE || !IsCurrentReporterOnCall()) { if (!GRPC_ERROR_IS_NONE(error) || !IsCurrentReporterOnCall()) {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return true; return true;
} }
@ -1474,7 +1474,7 @@ bool XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return true; return true;
} }
if (error != GRPC_ERROR_NONE || !IsCurrentReporterOnCall()) { if (!GRPC_ERROR_IS_NONE(error) || !IsCurrentReporterOnCall()) {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
// If this reporter is no longer the current one on the call, the reason // If this reporter is no longer the current one on the call, the reason
// might be that it was orphaned for a new one due to config update. // might be that it was orphaned for a new one due to config update.
@ -1684,7 +1684,7 @@ bool XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() {
grpc_error_handle parse_error = xds_client()->api_.ParseLrsResponse( grpc_error_handle parse_error = xds_client()->api_.ParseLrsResponse(
response_slice, &send_all_clusters, &new_cluster_names, response_slice, &send_all_clusters, &new_cluster_names,
&new_load_reporting_interval); &new_load_reporting_interval);
if (parse_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parse_error)) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"[xds_client %p] xds server %s: LRS response parsing failed: %s", "[xds_client %p] xds server %s: LRS response parsing failed: %s",
xds_client(), chand()->server_.server_uri.c_str(), xds_client(), chand()->server_.server_uri.c_str(),
@ -2399,7 +2399,7 @@ std::string GetBootstrapContents(const char* fallback_config,
grpc_slice contents; grpc_slice contents;
*error = *error =
grpc_load_file(path.get(), /*add_null_terminator=*/true, &contents); grpc_load_file(path.get(), /*add_null_terminator=*/true, &contents);
if (*error != GRPC_ERROR_NONE) return ""; if (!GRPC_ERROR_IS_NONE(*error)) return "";
std::string contents_str(StringViewFromSlice(contents)); std::string contents_str(StringViewFromSlice(contents));
grpc_slice_unref_internal(contents); grpc_slice_unref_internal(contents);
return contents_str; return contents_str;
@ -2440,7 +2440,7 @@ RefCountedPtr<XdsClient> XdsClient::GetOrCreate(const grpc_channel_args* args,
if (bootstrap_config != nullptr) { if (bootstrap_config != nullptr) {
std::unique_ptr<XdsBootstrap> bootstrap = std::unique_ptr<XdsBootstrap> bootstrap =
XdsBootstrap::Create(bootstrap_config, error); XdsBootstrap::Create(bootstrap_config, error);
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
grpc_channel_args* xds_channel_args = grpc_channel_args* xds_channel_args =
grpc_channel_args_find_pointer<grpc_channel_args>( grpc_channel_args_find_pointer<grpc_channel_args>(
args, args,
@ -2459,7 +2459,7 @@ RefCountedPtr<XdsClient> XdsClient::GetOrCreate(const grpc_channel_args* args,
// Find bootstrap contents. // Find bootstrap contents.
std::string bootstrap_contents = std::string bootstrap_contents =
GetBootstrapContents(g_fallback_bootstrap_config, error); GetBootstrapContents(g_fallback_bootstrap_config, error);
if (*error != GRPC_ERROR_NONE) return nullptr; if (!GRPC_ERROR_IS_NONE(*error)) return nullptr;
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "xDS bootstrap contents: %s", gpr_log(GPR_INFO, "xDS bootstrap contents: %s",
bootstrap_contents.c_str()); bootstrap_contents.c_str());
@ -2467,7 +2467,7 @@ RefCountedPtr<XdsClient> XdsClient::GetOrCreate(const grpc_channel_args* args,
// Parse bootstrap. // Parse bootstrap.
std::unique_ptr<XdsBootstrap> bootstrap = std::unique_ptr<XdsBootstrap> bootstrap =
XdsBootstrap::Create(bootstrap_contents, error); XdsBootstrap::Create(bootstrap_contents, error);
if (*error != GRPC_ERROR_NONE) return nullptr; if (!GRPC_ERROR_IS_NONE(*error)) return nullptr;
// Instantiate XdsClient. // Instantiate XdsClient.
xds_client = xds_client =
MakeRefCounted<XdsClient>(std::move(bootstrap), g_channel_args); MakeRefCounted<XdsClient>(std::move(bootstrap), g_channel_args);
@ -2544,7 +2544,7 @@ grpc_slice grpc_dump_xds_configs() {
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
auto xds_client = grpc_core::XdsClient::GetOrCreate(nullptr, &error); auto xds_client = grpc_core::XdsClient::GetOrCreate(nullptr, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// If we isn't using xDS, just return an empty string. // If we isn't using xDS, just return an empty string.
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return grpc_empty_slice(); return grpc_empty_slice();

@ -135,7 +135,7 @@ grpc_error_handle UpstreamTlsContextParse(
if (common_tls_context_proto != nullptr) { if (common_tls_context_proto != nullptr) {
grpc_error_handle error = CommonTlsContext::Parse( grpc_error_handle error = CommonTlsContext::Parse(
context, common_tls_context_proto, common_tls_context); context, common_tls_context_proto, common_tls_context);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
return grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING( return grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error parsing UpstreamTlsContext"), "Error parsing UpstreamTlsContext"),
error); error);
@ -253,7 +253,7 @@ grpc_error_handle CdsResourceParse(
envoy_config_cluster_v3_Cluster_LOGICAL_DNS) { envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
cds_update->cluster_type = XdsClusterResource::ClusterType::LOGICAL_DNS; cds_update->cluster_type = XdsClusterResource::ClusterType::LOGICAL_DNS;
grpc_error_handle error = CdsLogicalDnsParse(cluster, cds_update); grpc_error_handle error = CdsLogicalDnsParse(cluster, cds_update);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} else { } else {
if (!envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) { if (!envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
errors.push_back( errors.push_back(
@ -354,7 +354,7 @@ grpc_error_handle CdsResourceParse(
if (transport_socket != nullptr) { if (transport_socket != nullptr) {
grpc_error_handle error = UpstreamTlsContextParse( grpc_error_handle error = UpstreamTlsContextParse(
context, transport_socket, &cds_update->common_tls_context); context, transport_socket, &cds_update->common_tls_context);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
errors.push_back( errors.push_back(
grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING( grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error parsing security configuration"), "Error parsing security configuration"),
@ -534,7 +534,7 @@ absl::StatusOr<XdsResourceType::DecodeResult> XdsClusterResourceType::Decode(
auto cluster_data = absl::make_unique<ResourceDataSubclass>(); auto cluster_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error = grpc_error_handle error =
CdsResourceParse(context, resource, is_v2, &cluster_data->resource); CdsResourceParse(context, resource, is_v2, &cluster_data->resource);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
std::string error_str = grpc_error_std_string(error); std::string error_str = grpc_error_std_string(error);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) { if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {

@ -81,7 +81,7 @@ XdsRouteLookupClusterSpecifierPlugin::GenerateLoadBalancingPolicyConfig(
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
rls_policy["routeLookupConfig"] = rls_policy["routeLookupConfig"] =
Json::Parse(reinterpret_cast<char*>(buf), &error); Json::Parse(reinterpret_cast<char*>(buf), &error);
GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(error));
Json::Object cds_policy; Json::Object cds_policy;
cds_policy["cds_experimental"] = Json::Object(); cds_policy["cds_experimental"] = Json::Object();
Json::Array child_policy; Json::Array child_policy;
@ -100,7 +100,7 @@ XdsRouteLookupClusterSpecifierPlugin::GenerateLoadBalancingPolicyConfig(
// itself. // itself.
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(lb_policy_config, LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(lb_policy_config,
&parse_error); &parse_error);
if (parse_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(parse_error)) {
absl::Status status = absl::InvalidArgumentError(absl::StrCat( absl::Status status = absl::InvalidArgumentError(absl::StrCat(
kXdsRouteLookupClusterSpecifierPluginConfigName, kXdsRouteLookupClusterSpecifierPluginConfigName,
" ClusterSpecifierPlugin returned invalid LB policy config: ", " ClusterSpecifierPlugin returned invalid LB policy config: ",

@ -230,7 +230,7 @@ grpc_error_handle CertificateValidationContextParse(
grpc_error_handle error = CertificateProviderPluginInstanceParse( grpc_error_handle error = CertificateProviderPluginInstanceParse(
context, ca_certificate_provider_instance, context, ca_certificate_provider_instance,
&certificate_validation_context->ca_certificate_provider_instance); &certificate_validation_context->ca_certificate_provider_instance);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_spki( if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_spki(
certificate_validation_context_proto, nullptr) != nullptr) { certificate_validation_context_proto, nullptr) != nullptr) {
@ -290,7 +290,7 @@ grpc_error_handle CommonTlsContext::Parse(
grpc_error_handle error = CertificateValidationContextParse( grpc_error_handle error = CertificateValidationContextParse(
context, default_validation_context, context, default_validation_context,
&common_tls_context->certificate_validation_context); &common_tls_context->certificate_validation_context);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
// If after parsing default_validation_context, // If after parsing default_validation_context,
// common_tls_context->certificate_validation_context.ca_certificate_provider_instance // common_tls_context->certificate_validation_context.ca_certificate_provider_instance
@ -309,7 +309,7 @@ grpc_error_handle CommonTlsContext::Parse(
context, validation_context_certificate_provider_instance, context, validation_context_certificate_provider_instance,
&common_tls_context->certificate_validation_context &common_tls_context->certificate_validation_context
.ca_certificate_provider_instance); .ca_certificate_provider_instance);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
} else { } else {
auto* validation_context = auto* validation_context =
@ -319,7 +319,7 @@ grpc_error_handle CommonTlsContext::Parse(
grpc_error_handle error = CertificateValidationContextParse( grpc_error_handle error = CertificateValidationContextParse(
context, validation_context, context, validation_context,
&common_tls_context->certificate_validation_context); &common_tls_context->certificate_validation_context);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} else if ( } else if (
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_sds_secret_config( envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_sds_secret_config(
common_tls_context_proto)) { common_tls_context_proto)) {
@ -334,7 +334,7 @@ grpc_error_handle CommonTlsContext::Parse(
grpc_error_handle error = CertificateProviderPluginInstanceParse( grpc_error_handle error = CertificateProviderPluginInstanceParse(
context, tls_certificate_provider_instance, context, tls_certificate_provider_instance,
&common_tls_context->tls_certificate_provider_instance); &common_tls_context->tls_certificate_provider_instance);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} else { } else {
// Fall back onto 'tls_certificate_certificate_provider_instance'. Note that // Fall back onto 'tls_certificate_certificate_provider_instance'. Note that
// this way of fetching identity certificates is deprecated and will be // this way of fetching identity certificates is deprecated and will be
@ -347,7 +347,7 @@ grpc_error_handle CommonTlsContext::Parse(
grpc_error_handle error = CertificateProviderInstanceParse( grpc_error_handle error = CertificateProviderInstanceParse(
context, tls_certificate_certificate_provider_instance, context, tls_certificate_certificate_provider_instance,
&common_tls_context->tls_certificate_provider_instance); &common_tls_context->tls_certificate_provider_instance);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} else { } else {
if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificates( if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificates(
common_tls_context_proto)) { common_tls_context_proto)) {

@ -178,7 +178,7 @@ grpc_error_handle ServerAddressParseAndAppend(
grpc_resolved_address addr; grpc_resolved_address addr;
grpc_error_handle error = grpc_error_handle error =
grpc_string_to_sockaddr(&addr, address_str.c_str(), port); grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
// Append the address to the list. // Append the address to the list.
std::map<const char*, std::unique_ptr<ServerAddress::AttributeInterface>> std::map<const char*, std::unique_ptr<ServerAddress::AttributeInterface>>
attributes; attributes;
@ -225,7 +225,7 @@ grpc_error_handle LocalityParse(
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
grpc_error_handle error = ServerAddressParseAndAppend( grpc_error_handle error = ServerAddressParseAndAppend(
lb_endpoints[i], &output_locality->endpoints); lb_endpoints[i], &output_locality->endpoints);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
// Parse the priority. // Parse the priority.
*priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority( *priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
@ -287,7 +287,7 @@ grpc_error_handle EdsResourceParse(
size_t priority; size_t priority;
XdsEndpointResource::Priority::Locality locality; XdsEndpointResource::Priority::Locality locality;
grpc_error_handle error = LocalityParse(endpoints[j], &locality, &priority); grpc_error_handle error = LocalityParse(endpoints[j], &locality, &priority);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
errors.push_back(error); errors.push_back(error);
continue; continue;
} }
@ -328,7 +328,7 @@ grpc_error_handle EdsResourceParse(
for (size_t j = 0; j < drop_size; ++j) { for (size_t j = 0; j < drop_size; ++j) {
grpc_error_handle error = grpc_error_handle error =
DropParseAndAppend(drop_overload[j], eds_update->drop_config.get()); DropParseAndAppend(drop_overload[j], eds_update->drop_config.get());
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
errors.push_back( errors.push_back(
grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING( grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"drop config validation error"), "drop config validation error"),
@ -359,7 +359,7 @@ absl::StatusOr<XdsResourceType::DecodeResult> XdsEndpointResourceType::Decode(
auto endpoint_data = absl::make_unique<ResourceDataSubclass>(); auto endpoint_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error = grpc_error_handle error =
EdsResourceParse(context, resource, is_v2, &endpoint_data->resource); EdsResourceParse(context, resource, is_v2, &endpoint_data->resource);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
std::string error_str = grpc_error_std_string(error); std::string error_str = grpc_error_std_string(error);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) { if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {

@ -168,7 +168,7 @@ absl::StatusOr<Json> ParseStructToJson(const XdsEncodingContext& context,
reinterpret_cast<char*>(buf), json_size + 1, status.ptr()); reinterpret_cast<char*>(buf), json_size + 1, status.ptr());
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
auto json = Json::Parse(reinterpret_cast<char*>(buf), &error); auto json = Json::Parse(reinterpret_cast<char*>(buf), &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
// This should not happen // This should not happen
auto ret_status = absl::InternalError( auto ret_status = absl::InternalError(
absl::StrCat("Error parsing JSON form of google::Protobuf::Struct " absl::StrCat("Error parsing JSON form of google::Protobuf::Struct "

@ -433,7 +433,7 @@ grpc_error_handle HttpConnectionManagerParse(
XdsRouteConfigResource rds_update; XdsRouteConfigResource rds_update;
grpc_error_handle error = grpc_error_handle error =
XdsRouteConfigResource::Parse(context, route_config, &rds_update); XdsRouteConfigResource::Parse(context, route_config, &rds_update);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
http_connection_manager->rds_update = std::move(rds_update); http_connection_manager->rds_update = std::move(rds_update);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -517,7 +517,7 @@ grpc_error_handle DownstreamTlsContextParse(
grpc_error_handle error = grpc_error_handle error =
CommonTlsContext::Parse(context, common_tls_context, CommonTlsContext::Parse(context, common_tls_context,
&downstream_tls_context->common_tls_context); &downstream_tls_context->common_tls_context);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
auto* require_client_certificate = auto* require_client_certificate =
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate( envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(
@ -570,7 +570,7 @@ grpc_error_handle CidrRangeParse(
envoy_config_core_v3_CidrRange_address_prefix(cidr_range_proto)); envoy_config_core_v3_CidrRange_address_prefix(cidr_range_proto));
grpc_error_handle error = grpc_error_handle error =
grpc_string_to_sockaddr(&cidr_range->address, address_prefix.c_str(), 0); grpc_string_to_sockaddr(&cidr_range->address, address_prefix.c_str(), 0);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
cidr_range->prefix_len = 0; cidr_range->prefix_len = 0;
auto* prefix_len_proto = auto* prefix_len_proto =
envoy_config_core_v3_CidrRange_prefix_len(cidr_range_proto); envoy_config_core_v3_CidrRange_prefix_len(cidr_range_proto);
@ -604,7 +604,7 @@ grpc_error_handle FilterChainMatchParse(
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
XdsListenerResource::FilterChainMap::CidrRange cidr_range; XdsListenerResource::FilterChainMap::CidrRange cidr_range;
grpc_error_handle error = CidrRangeParse(prefix_ranges[i], &cidr_range); grpc_error_handle error = CidrRangeParse(prefix_ranges[i], &cidr_range);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
filter_chain_match->prefix_ranges.push_back(cidr_range); filter_chain_match->prefix_ranges.push_back(cidr_range);
} }
filter_chain_match->source_type = filter_chain_match->source_type =
@ -619,7 +619,7 @@ grpc_error_handle FilterChainMatchParse(
XdsListenerResource::FilterChainMap::CidrRange cidr_range; XdsListenerResource::FilterChainMap::CidrRange cidr_range;
grpc_error_handle error = grpc_error_handle error =
CidrRangeParse(source_prefix_ranges[i], &cidr_range); CidrRangeParse(source_prefix_ranges[i], &cidr_range);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
filter_chain_match->source_prefix_ranges.push_back(cidr_range); filter_chain_match->source_prefix_ranges.push_back(cidr_range);
} }
auto* source_ports = envoy_config_listener_v3_FilterChainMatch_source_ports( auto* source_ports = envoy_config_listener_v3_FilterChainMatch_source_ports(
@ -658,7 +658,7 @@ grpc_error_handle FilterChainParse(
if (filter_chain_match != nullptr) { if (filter_chain_match != nullptr) {
grpc_error_handle error = FilterChainMatchParse( grpc_error_handle error = FilterChainMatchParse(
filter_chain_match, &filter_chain->filter_chain_match); filter_chain_match, &filter_chain->filter_chain_match);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
filter_chain->filter_chain_data = filter_chain->filter_chain_data =
std::make_shared<XdsListenerResource::FilterChainData>(); std::make_shared<XdsListenerResource::FilterChainData>();
@ -700,7 +700,7 @@ grpc_error_handle FilterChainParse(
grpc_error_handle error = HttpConnectionManagerParse( grpc_error_handle error = HttpConnectionManagerParse(
false /* is_client */, context, http_connection_manager, is_v2, false /* is_client */, context, http_connection_manager, is_v2,
&filter_chain->filter_chain_data->http_connection_manager); &filter_chain->filter_chain_data->http_connection_manager);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
} }
} }
@ -711,7 +711,7 @@ grpc_error_handle FilterChainParse(
grpc_error_handle error = DownstreamTlsContextParse( grpc_error_handle error = DownstreamTlsContextParse(
context, transport_socket, context, transport_socket,
&filter_chain->filter_chain_data->downstream_tls_context); &filter_chain->filter_chain_data->downstream_tls_context);
if (error != GRPC_ERROR_NONE) errors.push_back(error); if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
} }
return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing FilterChain", &errors); return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing FilterChain", &errors);
} }
@ -780,7 +780,7 @@ grpc_error_handle AddFilterChainDataForSourcePorts(
for (uint32_t port : filter_chain.filter_chain_match.source_ports) { for (uint32_t port : filter_chain.filter_chain_match.source_ports) {
grpc_error_handle error = grpc_error_handle error =
AddFilterChainDataForSourcePort(filter_chain, ports_map, port); AddFilterChainDataForSourcePort(filter_chain, ports_map, port);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
} }
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -809,7 +809,7 @@ grpc_error_handle AddFilterChainDataForSourceIpRange(
} }
grpc_error_handle error = AddFilterChainDataForSourcePorts( grpc_error_handle error = AddFilterChainDataForSourcePorts(
filter_chain, &insert_result.first->second.ports_map); filter_chain, &insert_result.first->second.ports_map);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
} }
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -896,7 +896,7 @@ grpc_error_handle AddFilterChainDataForDestinationIpRange(
} }
grpc_error_handle error = AddFilterChainDataForServerNames( grpc_error_handle error = AddFilterChainDataForServerNames(
filter_chain, &insert_result.first->second); filter_chain, &insert_result.first->second);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
} }
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -930,7 +930,7 @@ grpc_error_handle BuildFilterChainMap(
if (filter_chain.filter_chain_match.destination_port != 0) continue; if (filter_chain.filter_chain_match.destination_port != 0) continue;
grpc_error_handle error = AddFilterChainDataForDestinationIpRange( grpc_error_handle error = AddFilterChainDataForDestinationIpRange(
filter_chain, &internal_filter_chain_map.destination_ip_map); filter_chain, &internal_filter_chain_map.destination_ip_map);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
*filter_chain_map = *filter_chain_map =
BuildFromInternalFilterChainMap(&internal_filter_chain_map); BuildFromInternalFilterChainMap(&internal_filter_chain_map);
@ -945,7 +945,7 @@ grpc_error_handle LdsResourceParseServer(
grpc_error_handle error = grpc_error_handle error =
AddressParse(envoy_config_listener_v3_Listener_address(listener), AddressParse(envoy_config_listener_v3_Listener_address(listener),
&lds_update->address); &lds_update->address);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
const auto* use_original_dst = const auto* use_original_dst =
envoy_config_listener_v3_Listener_use_original_dst(listener); envoy_config_listener_v3_Listener_use_original_dst(listener);
if (use_original_dst != nullptr) { if (use_original_dst != nullptr) {
@ -962,19 +962,19 @@ grpc_error_handle LdsResourceParseServer(
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
FilterChain filter_chain; FilterChain filter_chain;
error = FilterChainParse(context, filter_chains[i], is_v2, &filter_chain); error = FilterChainParse(context, filter_chains[i], is_v2, &filter_chain);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
parsed_filter_chains.push_back(std::move(filter_chain)); parsed_filter_chains.push_back(std::move(filter_chain));
} }
error = error =
BuildFilterChainMap(parsed_filter_chains, &lds_update->filter_chain_map); BuildFilterChainMap(parsed_filter_chains, &lds_update->filter_chain_map);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
auto* default_filter_chain = auto* default_filter_chain =
envoy_config_listener_v3_Listener_default_filter_chain(listener); envoy_config_listener_v3_Listener_default_filter_chain(listener);
if (default_filter_chain != nullptr) { if (default_filter_chain != nullptr) {
FilterChain filter_chain; FilterChain filter_chain;
error = error =
FilterChainParse(context, default_filter_chain, is_v2, &filter_chain); FilterChainParse(context, default_filter_chain, is_v2, &filter_chain);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
if (filter_chain.filter_chain_data != nullptr) { if (filter_chain.filter_chain_data != nullptr) {
lds_update->default_filter_chain = lds_update->default_filter_chain =
std::move(*filter_chain.filter_chain_data); std::move(*filter_chain.filter_chain_data);
@ -1046,7 +1046,7 @@ absl::StatusOr<XdsResourceType::DecodeResult> XdsListenerResourceType::Decode(
auto listener_data = absl::make_unique<ResourceDataSubclass>(); auto listener_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error = grpc_error_handle error =
LdsResourceParse(context, resource, is_v2, &listener_data->resource); LdsResourceParse(context, resource, is_v2, &listener_data->resource);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
std::string error_str = grpc_error_std_string(error); std::string error_str = grpc_error_std_string(error);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) { if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {

@ -796,7 +796,7 @@ grpc_error_handle RouteActionParse(
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_key, envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_key,
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_value, envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_value,
&cluster.typed_per_filter_config); &cluster.typed_per_filter_config);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
action_weighted_clusters.emplace_back(std::move(cluster)); action_weighted_clusters.emplace_back(std::move(cluster));
} }
@ -935,7 +935,7 @@ grpc_error_handle RouteActionParse(
if (retry_policy != nullptr) { if (retry_policy != nullptr) {
absl::optional<XdsRouteConfigResource::RetryPolicy> retry; absl::optional<XdsRouteConfigResource::RetryPolicy> retry;
grpc_error_handle error = RetryPolicyParse(context, retry_policy, &retry); grpc_error_handle error = RetryPolicyParse(context, retry_policy, &retry);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
route->retry_policy = retry; route->retry_policy = retry;
} }
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -951,7 +951,7 @@ grpc_error_handle XdsRouteConfigResource::Parse(
if (XdsRlsEnabled()) { if (XdsRlsEnabled()) {
grpc_error_handle error = grpc_error_handle error =
ClusterSpecifierPluginParse(context, route_config, rds_update); ClusterSpecifierPluginParse(context, route_config, rds_update);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
// Get the virtual hosts. // Get the virtual hosts.
size_t num_virtual_hosts; size_t num_virtual_hosts;
@ -987,7 +987,7 @@ grpc_error_handle XdsRouteConfigResource::Parse(
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_key, envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_key,
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_value, envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_value,
&vhost.typed_per_filter_config); &vhost.typed_per_filter_config);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
// Parse retry policy. // Parse retry policy.
absl::optional<XdsRouteConfigResource::RetryPolicy> absl::optional<XdsRouteConfigResource::RetryPolicy>
@ -997,7 +997,7 @@ grpc_error_handle XdsRouteConfigResource::Parse(
if (retry_policy != nullptr) { if (retry_policy != nullptr) {
grpc_error_handle error = grpc_error_handle error =
RetryPolicyParse(context, retry_policy, &virtual_host_retry_policy); RetryPolicyParse(context, retry_policy, &virtual_host_retry_policy);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
// Parse routes. // Parse routes.
size_t num_routes; size_t num_routes;
@ -1030,12 +1030,12 @@ grpc_error_handle XdsRouteConfigResource::Parse(
bool ignore_route = false; bool ignore_route = false;
grpc_error_handle error = grpc_error_handle error =
RoutePathMatchParse(match, &route, &ignore_route); RoutePathMatchParse(match, &route, &ignore_route);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
if (ignore_route) continue; if (ignore_route) continue;
error = RouteHeaderMatchersParse(match, &route); error = RouteHeaderMatchersParse(match, &route);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
error = RouteRuntimeFractionParse(match, &route); error = RouteRuntimeFractionParse(match, &route);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
if (envoy_config_route_v3_Route_has_route(routes[j])) { if (envoy_config_route_v3_Route_has_route(routes[j])) {
route.action.emplace<XdsRouteConfigResource::Route::RouteAction>(); route.action.emplace<XdsRouteConfigResource::Route::RouteAction>();
auto& route_action = auto& route_action =
@ -1043,7 +1043,7 @@ grpc_error_handle XdsRouteConfigResource::Parse(
error = RouteActionParse(context, routes[j], error = RouteActionParse(context, routes[j],
rds_update->cluster_specifier_plugin_map, rds_update->cluster_specifier_plugin_map,
&route_action, &ignore_route); &route_action, &ignore_route);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
if (ignore_route) continue; if (ignore_route) continue;
if (route_action.retry_policy == absl::nullopt && if (route_action.retry_policy == absl::nullopt &&
retry_policy != nullptr) { retry_policy != nullptr) {
@ -1071,7 +1071,7 @@ grpc_error_handle XdsRouteConfigResource::Parse(
envoy_config_route_v3_Route_TypedPerFilterConfigEntry_key, envoy_config_route_v3_Route_TypedPerFilterConfigEntry_key,
envoy_config_route_v3_Route_TypedPerFilterConfigEntry_value, envoy_config_route_v3_Route_TypedPerFilterConfigEntry_value,
&route.typed_per_filter_config); &route.typed_per_filter_config);
if (error != GRPC_ERROR_NONE) return error; if (!GRPC_ERROR_IS_NONE(error)) return error;
} }
vhost.routes.emplace_back(std::move(route)); vhost.routes.emplace_back(std::move(route));
} }
@ -1129,7 +1129,7 @@ XdsRouteConfigResourceType::Decode(const XdsEncodingContext& context,
auto route_config_data = absl::make_unique<ResourceDataSubclass>(); auto route_config_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error = XdsRouteConfigResource::Parse( grpc_error_handle error = XdsRouteConfigResource::Parse(
context, resource, &route_config_data->resource); context, resource, &route_config_data->resource);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
std::string error_str = grpc_error_std_string(error); std::string error_str = grpc_error_std_string(error);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) { if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {

@ -950,7 +950,7 @@ const XdsListenerResource::FilterChainData* FindFilterChainDataForSourceType(
grpc_resolved_address source_addr; grpc_resolved_address source_addr;
grpc_error_handle error = grpc_string_to_sockaddr( grpc_error_handle error = grpc_string_to_sockaddr(
&source_addr, host.c_str(), 0 /* port doesn't matter here */); &source_addr, host.c_str(), 0 /* port doesn't matter here */);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_DEBUG, "Could not parse string to socket address: %s", gpr_log(GPR_DEBUG, "Could not parse string to socket address: %s",
host.c_str()); host.c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -1001,7 +1001,7 @@ const XdsListenerResource::FilterChainData* FindFilterChainDataForDestinationIp(
grpc_resolved_address destination_addr; grpc_resolved_address destination_addr;
grpc_error_handle error = grpc_string_to_sockaddr( grpc_error_handle error = grpc_string_to_sockaddr(
&destination_addr, host.c_str(), 0 /* port doesn't matter here */); &destination_addr, host.c_str(), 0 /* port doesn't matter here */);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_DEBUG, "Could not parse string to socket address: %s", gpr_log(GPR_DEBUG, "Could not parse string to socket address: %s",
host.c_str()); host.c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -1146,7 +1146,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
XdsRouting::GeneratePerHttpFilterConfigsResult result = XdsRouting::GeneratePerHttpFilterConfigsResult result =
XdsRouting::GeneratePerHTTPFilterConfigs(http_filters, vhost, route, XdsRouting::GeneratePerHTTPFilterConfigs(http_filters, vhost, route,
nullptr, nullptr); nullptr, nullptr);
if (result.error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(result.error)) {
return grpc_error_to_absl_status(result.error); return grpc_error_to_absl_status(result.error);
} }
std::vector<std::string> fields; std::vector<std::string> fields;
@ -1170,7 +1170,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
config_selector_route.method_config = config_selector_route.method_config =
ServiceConfigImpl::Create(result.args, json.c_str(), &error); ServiceConfigImpl::Create(result.args, json.c_str(), &error);
GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(error));
} }
grpc_channel_args_destroy(result.args); grpc_channel_args_destroy(result.args);
} }
@ -1347,7 +1347,7 @@ grpc_server_config_fetcher* grpc_server_config_fetcher_xds_create(
grpc_core::RefCountedPtr<grpc_core::XdsClient> xds_client = grpc_core::RefCountedPtr<grpc_core::XdsClient> xds_client =
grpc_core::XdsClient::GetOrCreate(args, &error); grpc_core::XdsClient::GetOrCreate(args, &error);
grpc_channel_args_destroy(args); grpc_channel_args_destroy(args);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "Failed to create xds client: %s", gpr_log(GPR_ERROR, "Failed to create xds client: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

@ -55,7 +55,7 @@ bool grpc_parse_unix(const grpc_core::URI& uri,
} }
grpc_error_handle error = grpc_error_handle error =
grpc_core::UnixSockaddrPopulate(uri.path(), resolved_addr); grpc_core::UnixSockaddrPopulate(uri.path(), resolved_addr);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str()); gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return false; return false;
@ -72,7 +72,7 @@ bool grpc_parse_unix_abstract(const grpc_core::URI& uri,
} }
grpc_error_handle error = grpc_error_handle error =
grpc_core::UnixAbstractSockaddrPopulate(uri.path(), resolved_addr); grpc_core::UnixAbstractSockaddrPopulate(uri.path(), resolved_addr);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str()); gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return false; return false;

@ -143,8 +143,8 @@ grpc_error_handle grpc_channel_stack_init(
elems[i].channel_data = user_data; elems[i].channel_data = user_data;
grpc_error_handle error = grpc_error_handle error =
elems[i].filter->init_channel_elem(&elems[i], &args); elems[i].filter->init_channel_elem(&elems[i], &args);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (first_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(first_error)) {
first_error = error; first_error = error;
} else { } else {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -205,8 +205,8 @@ grpc_error_handle grpc_call_stack_init(
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
grpc_error_handle error = grpc_error_handle error =
call_elems[i].filter->init_call_elem(&call_elems[i], elem_args); call_elems[i].filter->init_call_elem(&call_elems[i], elem_args);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
if (first_error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(first_error)) {
first_error = error; first_error = error;
} else { } else {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

@ -77,7 +77,7 @@ ChannelStackBuilderImpl::Build() {
channel_stack); channel_stack);
grpc_channel_args_destroy(c_args); grpc_channel_args_destroy(c_args);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_channel_stack_destroy(channel_stack); grpc_channel_stack_destroy(channel_stack);
gpr_free(channel_stack); gpr_free(channel_stack);
auto status = grpc_error_to_absl_status(error); auto status = grpc_error_to_absl_status(error);

@ -437,7 +437,7 @@ void PopulateSocketAddressJson(Json::Object* json, const char* name,
grpc_resolved_address resolved_host; grpc_resolved_address resolved_host;
grpc_error_handle error = grpc_error_handle error =
grpc_string_to_sockaddr(&resolved_host, host.c_str(), port_num); grpc_string_to_sockaddr(&resolved_host, host.c_str(), port_num);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
std::string packed_host = grpc_sockaddr_get_packed_host(&resolved_host); std::string packed_host = grpc_sockaddr_get_packed_host(&resolved_host);
std::string b64_host = absl::Base64Escape(packed_host); std::string b64_host = absl::Base64Escape(packed_host);
data["tcpip_address"] = Json::Object{ data["tcpip_address"] = Json::Object{

@ -587,7 +587,7 @@ void ClientCallData::StartBatch(grpc_transport_stream_op_batch* b) {
recv_trailing_state_ = RecvTrailingState::kForwarded; recv_trailing_state_ = RecvTrailingState::kForwarded;
HookRecvTrailingMetadata(batch); HookRecvTrailingMetadata(batch);
} }
} else if (cancelled_error_ != GRPC_ERROR_NONE) { } else if (!GRPC_ERROR_IS_NONE(cancelled_error_)) {
batch.CancelWith(GRPC_ERROR_REF(cancelled_error_), &flusher); batch.CancelWith(GRPC_ERROR_REF(cancelled_error_), &flusher);
} }
@ -698,7 +698,7 @@ void ClientCallData::RecvInitialMetadataReady(grpc_error_handle error) {
abort(); // unreachable abort(); // unreachable
} }
Flusher flusher(this); Flusher flusher(this);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
recv_initial_metadata_->state = RecvInitialMetadata::kResponded; recv_initial_metadata_->state = RecvInitialMetadata::kResponded;
flusher.AddClosure( flusher.AddClosure(
absl::exchange(recv_initial_metadata_->original_on_ready, nullptr), absl::exchange(recv_initial_metadata_->original_on_ready, nullptr),
@ -835,7 +835,7 @@ void ClientCallData::RecvTrailingMetadataReady(grpc_error_handle error) {
} }
// If there was an error, we'll put that into the trailing metadata and // If there was an error, we'll put that into the trailing metadata and
// proceed as if there was not. // proceed as if there was not.
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
SetStatusFromError(recv_trailing_metadata_, error); SetStatusFromError(recv_trailing_metadata_, error);
} }
// Record that we've got the callback. // Record that we've got the callback.
@ -1155,7 +1155,7 @@ void ServerCallData::RecvInitialMetadataReady(grpc_error_handle error) {
Flusher flusher(this); Flusher flusher(this);
GPR_ASSERT(recv_initial_state_ == RecvInitialState::kForwarded); GPR_ASSERT(recv_initial_state_ == RecvInitialState::kForwarded);
// If there was an error we just propagate that through // If there was an error we just propagate that through
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
recv_initial_state_ = RecvInitialState::kResponded; recv_initial_state_ = RecvInitialState::kResponded;
flusher.AddClosure( flusher.AddClosure(
absl::exchange(original_recv_initial_metadata_ready_, nullptr), absl::exchange(original_recv_initial_metadata_ready_, nullptr),

@ -234,7 +234,7 @@ void HttpRequest::Orphan() {
} }
void HttpRequest::AppendError(grpc_error_handle error) { void HttpRequest::AppendError(grpc_error_handle error) {
if (overall_error_ == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(overall_error_)) {
overall_error_ = overall_error_ =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request"); GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request");
} }
@ -253,7 +253,7 @@ void HttpRequest::OnReadInternal(grpc_error_handle error) {
have_read_byte_ = 1; have_read_byte_ = 1;
grpc_error_handle err = grpc_error_handle err =
grpc_http_parser_parse(&parser_, incoming_.slices[i], nullptr); grpc_http_parser_parse(&parser_, incoming_.slices[i], nullptr);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
Finish(err); Finish(err);
return; return;
} }
@ -262,7 +262,7 @@ void HttpRequest::OnReadInternal(grpc_error_handle error) {
if (cancelled_) { if (cancelled_) {
Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"HTTP1 request cancelled during read", &overall_error_, 1)); "HTTP1 request cancelled during read", &overall_error_, 1));
} else if (error == GRPC_ERROR_NONE) { } else if (GRPC_ERROR_IS_NONE(error)) {
DoRead(); DoRead();
} else if (!have_read_byte_) { } else if (!have_read_byte_) {
NextAddress(GRPC_ERROR_REF(error)); NextAddress(GRPC_ERROR_REF(error));
@ -275,7 +275,7 @@ void HttpRequest::ContinueDoneWriteAfterScheduleOnExecCtx(
void* arg, grpc_error_handle error) { void* arg, grpc_error_handle error) {
RefCountedPtr<HttpRequest> req(static_cast<HttpRequest*>(arg)); RefCountedPtr<HttpRequest> req(static_cast<HttpRequest*>(arg));
MutexLock lock(&req->mu_); MutexLock lock(&req->mu_);
if (error == GRPC_ERROR_NONE && !req->cancelled_) { if (GRPC_ERROR_IS_NONE(error) && !req->cancelled_) {
req->OnWritten(); req->OnWritten();
} else { } else {
req->NextAddress(GRPC_ERROR_REF(error)); req->NextAddress(GRPC_ERROR_REF(error));
@ -300,7 +300,7 @@ void HttpRequest::OnHandshakeDone(void* arg, grpc_error_handle error) {
} }
MutexLock lock(&req->mu_); MutexLock lock(&req->mu_);
req->own_endpoint_ = true; req->own_endpoint_ = true;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
req->handshake_mgr_.reset(); req->handshake_mgr_.reset();
req->NextAddress(GRPC_ERROR_REF(error)); req->NextAddress(GRPC_ERROR_REF(error));
return; return;
@ -364,7 +364,7 @@ void HttpRequest::DoHandshake(const grpc_resolved_address* addr) {
} }
void HttpRequest::NextAddress(grpc_error_handle error) { void HttpRequest::NextAddress(grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
AppendError(error); AppendError(error);
} }
if (cancelled_) { if (cancelled_) {

@ -236,7 +236,7 @@ static grpc_error_handle add_header(grpc_http_parser* parser) {
(*hdrs)[(*hdr_count)++] = hdr; (*hdrs)[(*hdr_count)++] = hdr;
done: done:
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_free(hdr.key); gpr_free(hdr.key);
gpr_free(hdr.value); gpr_free(hdr.value);
} }
@ -249,7 +249,7 @@ static grpc_error_handle finish_line(grpc_http_parser* parser,
switch (parser->state) { switch (parser->state) {
case GRPC_HTTP_FIRST_LINE: case GRPC_HTTP_FIRST_LINE:
err = handle_first_line(parser); err = handle_first_line(parser);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
parser->state = GRPC_HTTP_HEADERS; parser->state = GRPC_HTTP_HEADERS;
break; break;
case GRPC_HTTP_HEADERS: case GRPC_HTTP_HEADERS:
@ -264,7 +264,7 @@ static grpc_error_handle finish_line(grpc_http_parser* parser,
break; break;
} else { } else {
err = add_header(parser); err = add_header(parser);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
} }
@ -449,7 +449,7 @@ grpc_error_handle grpc_http_parser_parse(grpc_http_parser* parser,
bool found_body_start = false; bool found_body_start = false;
grpc_error_handle err = grpc_error_handle err =
addbyte(parser, GRPC_SLICE_START_PTR(slice)[i], &found_body_start); addbyte(parser, GRPC_SLICE_START_PTR(slice)[i], &found_body_start);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
if (found_body_start && start_of_body != nullptr) *start_of_body = i + 1; if (found_body_start && start_of_body != nullptr) *start_of_body = i + 1;
} }
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;

@ -217,7 +217,7 @@ void CallCombiner::SetNotifyOnCancel(grpc_closure* closure) {
grpc_error_handle original_error = DecodeCancelStateError(original_state); grpc_error_handle original_error = DecodeCancelStateError(original_state);
// If error is set, invoke the cancellation closure immediately. // If error is set, invoke the cancellation closure immediately.
// Otherwise, store the new closure. // Otherwise, store the new closure.
if (original_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(original_error)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_call_combiner_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_call_combiner_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"call_combiner=%p: scheduling notify_on_cancel callback=%p " "call_combiner=%p: scheduling notify_on_cancel callback=%p "
@ -263,7 +263,7 @@ void CallCombiner::Cancel(grpc_error_handle error) {
while (true) { while (true) {
gpr_atm original_state = gpr_atm_acq_load(&cancel_state_); gpr_atm original_state = gpr_atm_acq_load(&cancel_state_);
grpc_error_handle original_error = DecodeCancelStateError(original_state); grpc_error_handle original_error = DecodeCancelStateError(original_state);
if (original_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(original_error)) {
#ifdef GRPC_ERROR_IS_ABSEIL_STATUS #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
internal::StatusFreeHeapPtr(status_ptr); internal::StatusFreeHeapPtr(status_ptr);
#else #else

@ -56,7 +56,7 @@ struct grpc_endpoint_vtable {
Callback success indicates that the endpoint can accept more reads, failure Callback success indicates that the endpoint can accept more reads, failure
indicates the endpoint is closed. indicates the endpoint is closed.
Valid slices may be placed into \a slices even when the callback is Valid slices may be placed into \a slices even when the callback is
invoked with error != GRPC_ERROR_NONE. */ invoked with !GRPC_ERROR_IS_NONE(error). */
void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices, void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb, bool urgent, int min_progress_size); grpc_closure* cb, bool urgent, int min_progress_size);

@ -147,7 +147,7 @@ static void CallWriteCb(CFStreamEndpoint* ep, grpc_error_handle error) {
static void ReadAction(void* arg, grpc_error_handle error) { static void ReadAction(void* arg, grpc_error_handle error) {
CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg); CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg);
GPR_ASSERT(ep->read_cb != nullptr); GPR_ASSERT(ep->read_cb != nullptr);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_slice_buffer_reset_and_unref_internal(ep->read_slices); grpc_slice_buffer_reset_and_unref_internal(ep->read_slices);
CallReadCb(ep, GRPC_ERROR_REF(error)); CallReadCb(ep, GRPC_ERROR_REF(error));
EP_UNREF(ep, "read"); EP_UNREF(ep, "read");
@ -189,7 +189,7 @@ static void ReadAction(void* arg, grpc_error_handle error) {
static void WriteAction(void* arg, grpc_error_handle error) { static void WriteAction(void* arg, grpc_error_handle error) {
CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg); CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg);
GPR_ASSERT(ep->write_cb != nullptr); GPR_ASSERT(ep->write_cb != nullptr);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_slice_buffer_reset_and_unref_internal(ep->write_slices); grpc_slice_buffer_reset_and_unref_internal(ep->write_slices);
CallWriteCb(ep, GRPC_ERROR_REF(error)); CallWriteCb(ep, GRPC_ERROR_REF(error));
EP_UNREF(ep, "write"); EP_UNREF(ep, "write");

@ -97,7 +97,7 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
grpc_error_handle grpc_error_set_int(grpc_error_handle src, grpc_error_handle grpc_error_set_int(grpc_error_handle src,
grpc_error_ints which, intptr_t value) { grpc_error_ints which, intptr_t value) {
if (src == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(src)) {
src = absl::UnknownError(""); src = absl::UnknownError("");
StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus, StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_OK); GRPC_STATUS_OK);
@ -138,7 +138,7 @@ bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which,
grpc_error_handle grpc_error_set_str(grpc_error_handle src, grpc_error_handle grpc_error_set_str(grpc_error_handle src,
grpc_error_strs which, grpc_error_strs which,
absl::string_view str) { absl::string_view str) {
if (src == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(src)) {
src = absl::UnknownError(""); src = absl::UnknownError("");
StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus, StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_OK); GRPC_STATUS_OK);
@ -213,7 +213,7 @@ grpc_error_handle grpc_error_add_child(grpc_error_handle src,
bool grpc_log_error(const char* what, grpc_error_handle error, const char* file, bool grpc_log_error(const char* what, grpc_error_handle error, const char* file,
int line) { int line) {
GPR_DEBUG_ASSERT(error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(error));
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what,
grpc_core::StatusToString(error).c_str()); grpc_core::StatusToString(error).c_str());
return false; return false;
@ -564,7 +564,7 @@ static grpc_error_handle copy_error_and_unref(grpc_error_handle in) {
grpc_error_handle out; grpc_error_handle out;
if (grpc_error_is_special(in)) { if (grpc_error_is_special(in)) {
out = GRPC_ERROR_CREATE_FROM_STATIC_STRING("unknown"); out = GRPC_ERROR_CREATE_FROM_STATIC_STRING("unknown");
if (in == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(in)) {
internal_set_str(&out, GRPC_ERROR_STR_DESCRIPTION, internal_set_str(&out, GRPC_ERROR_STR_DESCRIPTION,
grpc_slice_from_static_string("no error")); grpc_slice_from_static_string("no error"));
internal_set_int(&out, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK); internal_set_int(&out, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK);
@ -677,8 +677,8 @@ bool grpc_error_get_str(grpc_error_handle err, grpc_error_strs which,
grpc_error_handle grpc_error_add_child(grpc_error_handle src, grpc_error_handle grpc_error_add_child(grpc_error_handle src,
grpc_error_handle child) { grpc_error_handle child) {
if (src != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(src)) {
if (child == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(child)) {
/* \a child is empty. Simply return the ref to \a src */ /* \a child is empty. Simply return the ref to \a src */
return src; return src;
} else if (child != src) { } else if (child != src) {
@ -908,7 +908,7 @@ static char* finish_kvs(kv_pairs* kvs) {
} }
const char* grpc_error_string(grpc_error_handle err) { const char* grpc_error_string(grpc_error_handle err) {
if (err == GRPC_ERROR_NONE) return no_error_string; if (GRPC_ERROR_IS_NONE(err)) return no_error_string;
if (err == GRPC_ERROR_OOM) return oom_error_string; if (err == GRPC_ERROR_OOM) return oom_error_string;
if (err == GRPC_ERROR_CANCELLED) return cancelled_error_string; if (err == GRPC_ERROR_CANCELLED) return cancelled_error_string;
@ -980,7 +980,7 @@ grpc_error_handle grpc_wsa_error(const char* file, int line, int err,
bool grpc_log_error(const char* what, grpc_error_handle error, const char* file, bool grpc_log_error(const char* what, grpc_error_handle error, const char* file,
int line) { int line) {
GPR_DEBUG_ASSERT(error != GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(!GRPC_ERROR_IS_NONE(error));
const char* msg = grpc_error_string(error); const char* msg = grpc_error_string(error);
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, msg); gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, msg);
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

@ -161,6 +161,8 @@ void grpc_enable_error_creation();
#define GRPC_ERROR_REF(err) (err) #define GRPC_ERROR_REF(err) (err)
#define GRPC_ERROR_UNREF(err) (void)(err) #define GRPC_ERROR_UNREF(err) (void)(err)
#define GRPC_ERROR_IS_NONE(err) (err).ok()
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \ #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \
StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {}) StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
#define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \ #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \
@ -208,7 +210,7 @@ absl::Status grpc_os_error(const grpc_core::DebugLocation& location, int err,
const char* call_name) GRPC_MUST_USE_RESULT; const char* call_name) GRPC_MUST_USE_RESULT;
inline absl::Status grpc_assert_never_ok(absl::Status error) { inline absl::Status grpc_assert_never_ok(absl::Status error) {
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
return error; return error;
} }
@ -236,6 +238,8 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
#define GRPC_ERROR_CANCELLED ((grpc_error_handle)4) #define GRPC_ERROR_CANCELLED ((grpc_error_handle)4)
#define GRPC_ERROR_SPECIAL_MAX GRPC_ERROR_CANCELLED #define GRPC_ERROR_SPECIAL_MAX GRPC_ERROR_CANCELLED
#define GRPC_ERROR_IS_NONE(err) ((err) == GRPC_ERROR_NONE)
inline bool grpc_error_is_special(grpc_error_handle err) { inline bool grpc_error_is_special(grpc_error_handle err) {
return err <= GRPC_ERROR_SPECIAL_MAX; return err <= GRPC_ERROR_SPECIAL_MAX;
} }
@ -340,7 +344,7 @@ grpc_error_handle grpc_os_error(const char* file, int line, int err,
const char* call_name) GRPC_MUST_USE_RESULT; const char* call_name) GRPC_MUST_USE_RESULT;
inline grpc_error_handle grpc_assert_never_ok(grpc_error_handle error) { inline grpc_error_handle grpc_assert_never_ok(grpc_error_handle error) {
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
return error; return error;
} }
@ -387,8 +391,8 @@ bool grpc_log_error(const char* what, grpc_error_handle error, const char* file,
int line); int line);
inline bool grpc_log_if_error(const char* what, grpc_error_handle error, inline bool grpc_log_if_error(const char* what, grpc_error_handle error,
const char* file, int line) { const char* file, int line) {
return error == GRPC_ERROR_NONE ? true return GRPC_ERROR_IS_NONE(error) ? true
: grpc_log_error(what, error, file, line); : grpc_log_error(what, error, file, line);
} }
#define GRPC_LOG_IF_ERROR(what, error) \ #define GRPC_LOG_IF_ERROR(what, error) \
@ -413,7 +417,7 @@ class AtomicError {
/// returns get() == GRPC_ERROR_NONE /// returns get() == GRPC_ERROR_NONE
bool ok() { bool ok() {
gpr_spinlock_lock(&lock_); gpr_spinlock_lock(&lock_);
bool ret = error_ == GRPC_ERROR_NONE; bool ret = GRPC_ERROR_IS_NONE(error_);
gpr_spinlock_unlock(&lock_); gpr_spinlock_unlock(&lock_);
return ret; return ret;
} }

@ -242,8 +242,8 @@ struct grpc_pollset_set {
static bool append_error(grpc_error_handle* composite, grpc_error_handle error, static bool append_error(grpc_error_handle* composite, grpc_error_handle error,
const char* desc) { const char* desc) {
if (error == GRPC_ERROR_NONE) return true; if (GRPC_ERROR_IS_NONE(error)) return true;
if (*composite == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*composite)) {
*composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc); *composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
} }
*composite = grpc_error_add_child(*composite, error); *composite = grpc_error_add_child(*composite, error);
@ -517,7 +517,7 @@ static grpc_error_handle pollset_global_init(void) {
gpr_atm_no_barrier_store(&g_active_poller, 0); gpr_atm_no_barrier_store(&g_active_poller, 0);
global_wakeup_fd.read_fd = -1; global_wakeup_fd.read_fd = -1;
grpc_error_handle err = grpc_wakeup_fd_init(&global_wakeup_fd); grpc_error_handle err = grpc_wakeup_fd_init(&global_wakeup_fd);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
struct epoll_event ev; struct epoll_event ev;
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET); ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
ev.data.ptr = &global_wakeup_fd; ev.data.ptr = &global_wakeup_fd;

@ -757,8 +757,8 @@ static void push_front_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
static void kick_append_error(grpc_error_handle* composite, static void kick_append_error(grpc_error_handle* composite,
grpc_error_handle error) { grpc_error_handle error) {
if (error == GRPC_ERROR_NONE) return; if (GRPC_ERROR_IS_NONE(error)) return;
if (*composite == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*composite)) {
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Kick Failure"); *composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Kick Failure");
} }
*composite = grpc_error_add_child(*composite, error); *composite = grpc_error_add_child(*composite, error);
@ -904,8 +904,8 @@ static void finish_shutdown(grpc_pollset* pollset) {
static void work_combine_error(grpc_error_handle* composite, static void work_combine_error(grpc_error_handle* composite,
grpc_error_handle error) { grpc_error_handle error) {
if (error == GRPC_ERROR_NONE) return; if (GRPC_ERROR_IS_NONE(error)) return;
if (*composite == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*composite)) {
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("pollset_work"); *composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("pollset_work");
} }
*composite = grpc_error_add_child(*composite, error); *composite = grpc_error_add_child(*composite, error);
@ -940,7 +940,7 @@ static grpc_error_handle pollset_work(grpc_pollset* pollset,
gpr_malloc(sizeof(*worker.wakeup_fd))); gpr_malloc(sizeof(*worker.wakeup_fd)));
error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd); error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
fork_fd_list_add_wakeup_fd(worker.wakeup_fd); fork_fd_list_add_wakeup_fd(worker.wakeup_fd);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error)); GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
return error; return error;
} }
@ -1100,7 +1100,7 @@ static grpc_error_handle pollset_work(grpc_pollset* pollset,
/* If we're forced to re-evaluate polling (via pollset_kick with /* If we're forced to re-evaluate polling (via pollset_kick with
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) then we land here and force GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) then we land here and force
a loop */ a loop */
if (worker.reevaluate_polling_on_wakeup && error == GRPC_ERROR_NONE) { if (worker.reevaluate_polling_on_wakeup && GRPC_ERROR_IS_NONE(error)) {
worker.reevaluate_polling_on_wakeup = 0; worker.reevaluate_polling_on_wakeup = 0;
pollset->kicked_without_pollers = 0; pollset->kicked_without_pollers = 0;
if (queued_work || worker.kicked_specifically) { if (queued_work || worker.kicked_specifically) {

@ -66,7 +66,7 @@ grpc_error_handle grpc_load_file(const char* filename, int add_null_terminator,
end: end:
*output = result; *output = result;
if (file != nullptr) fclose(file); if (file != nullptr) fclose(file);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_error_handle error_out = grpc_error_handle error_out =
grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to load file", &error, 1), "Failed to load file", &error, 1),

@ -165,7 +165,7 @@ done:
if (result) { if (result) {
freeaddrinfo(result); freeaddrinfo(result);
} }
if (err == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(err)) {
return addresses; return addresses;
} }
auto error_result = grpc_error_to_absl_status(err); auto error_result = grpc_error_to_absl_status(err);

@ -149,7 +149,7 @@ done:
if (result) { if (result) {
freeaddrinfo(result); freeaddrinfo(result);
} }
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
return addresses; return addresses;
} }
auto error_result = grpc_error_to_absl_status(error); auto error_result = grpc_error_to_absl_status(error);

@ -116,7 +116,7 @@ static void OnOpen(void* arg, grpc_error_handle error) {
gpr_mu_unlock(&connect->mu); gpr_mu_unlock(&connect->mu);
CFStreamConnectCleanup(connect); CFStreamConnectCleanup(connect);
} else { } else {
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
CFErrorRef stream_error = CFReadStreamCopyError(connect->read_stream); CFErrorRef stream_error = CFReadStreamCopyError(connect->read_stream);
if (stream_error == NULL) { if (stream_error == NULL) {
stream_error = CFWriteStreamCopyError(connect->write_stream); stream_error = CFWriteStreamCopyError(connect->write_stream);
@ -125,7 +125,7 @@ static void OnOpen(void* arg, grpc_error_handle error) {
error = GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "connect() error"); error = GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "connect() error");
CFRelease(stream_error); CFRelease(stream_error);
} }
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
*endpoint = grpc_cfstream_endpoint_create( *endpoint = grpc_cfstream_endpoint_create(
connect->read_stream, connect->write_stream, connect->read_stream, connect->write_stream,
connect->addr_name.c_str(), connect->stream_handle); connect->addr_name.c_str(), connect->stream_handle);

@ -72,24 +72,24 @@ static grpc_error_handle prepare_socket(const grpc_resolved_address* addr,
GPR_ASSERT(fd >= 0); GPR_ASSERT(fd >= 0);
err = grpc_set_socket_nonblocking(fd, 1); err = grpc_set_socket_nonblocking(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_set_socket_cloexec(fd, 1); err = grpc_set_socket_cloexec(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
if (!grpc_is_unix_socket(addr)) { if (!grpc_is_unix_socket(addr)) {
err = grpc_set_socket_low_latency(fd, 1); err = grpc_set_socket_low_latency(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_set_socket_reuse_addr(fd, 1); err = grpc_set_socket_reuse_addr(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_set_socket_tcp_user_timeout(fd, channel_args, err = grpc_set_socket_tcp_user_timeout(fd, channel_args,
true /* is_client */); true /* is_client */);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
} }
err = grpc_set_socket_no_sigpipe_if_possible(fd); err = grpc_set_socket_no_sigpipe_if_possible(fd);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_CLIENT_CONNECTION_USAGE, err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_CLIENT_CONNECTION_USAGE,
channel_args); channel_args);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
goto done; goto done;
@ -155,7 +155,7 @@ static void on_writable(void* acp, grpc_error_handle error) {
grpc_timer_cancel(&ac->alarm); grpc_timer_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu); gpr_mu_lock(&ac->mu);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
error = error =
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, "Timeout occurred"); grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, "Timeout occurred");
goto finish; goto finish;
@ -215,7 +215,7 @@ finish:
} }
done = (--ac->refs == 0); done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu); gpr_mu_unlock(&ac->mu);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
std::string str; std::string str;
bool ret = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str); bool ret = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str);
GPR_ASSERT(ret); GPR_ASSERT(ret);
@ -251,7 +251,7 @@ grpc_error_handle grpc_tcp_client_prepare_fd(
} }
error = error =
grpc_create_dualstack_socket(mapped_addr, SOCK_STREAM, 0, &dsmode, fd); grpc_create_dualstack_socket(mapped_addr, SOCK_STREAM, 0, &dsmode, fd);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
return error; return error;
} }
if (dsmode == GRPC_DSMODE_IPV4) { if (dsmode == GRPC_DSMODE_IPV4) {

@ -93,7 +93,7 @@ static void on_connect(void* acp, grpc_error_handle error) {
gpr_mu_lock(&ac->mu); gpr_mu_lock(&ac->mu);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (socket != NULL) { if (socket != NULL) {
DWORD transfered_bytes = 0; DWORD transfered_bytes = 0;
DWORD flags; DWORD flags;
@ -161,7 +161,7 @@ static void tcp_connect(grpc_closure* on_done, grpc_endpoint** endpoint,
} }
error = grpc_tcp_prepare_socket(sock); error = grpc_tcp_prepare_socket(sock);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
goto failure; goto failure;
} }
@ -219,7 +219,7 @@ static void tcp_connect(grpc_closure* on_done, grpc_endpoint** endpoint,
return; return;
failure: failure:
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
grpc_error_handle final_error = grpc_error_set_str( grpc_error_handle final_error = grpc_error_set_str(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Failed to connect", GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Failed to connect",
&error, 1), &error, 1),

@ -889,7 +889,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error) {
} }
tcp->read_mu.Lock(); tcp->read_mu.Lock();
grpc_error_handle tcp_read_error; grpc_error_handle tcp_read_error;
if (GPR_LIKELY(error == GRPC_ERROR_NONE)) { if (GPR_LIKELY(GRPC_ERROR_IS_NONE(error))) {
maybe_make_read_slices(tcp); maybe_make_read_slices(tcp);
if (!tcp_do_read(tcp, &tcp_read_error)) { if (!tcp_do_read(tcp, &tcp_read_error)) {
/* We've consumed the edge, request a new one */ /* We've consumed the edge, request a new one */
@ -1231,7 +1231,7 @@ static void tcp_handle_error(void* arg /* grpc_tcp */,
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
} }
if (error != GRPC_ERROR_NONE || if (!GRPC_ERROR_IS_NONE(error) ||
static_cast<bool>(gpr_atm_acq_load(&tcp->stop_error_notification))) { static_cast<bool>(gpr_atm_acq_load(&tcp->stop_error_notification))) {
/* We aren't going to register to hear on error anymore, so it is safe to /* We aren't going to register to hear on error anymore, so it is safe to
* unref. */ * unref. */
@ -1537,7 +1537,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */,
grpc_tcp* tcp = static_cast<grpc_tcp*>(arg); grpc_tcp* tcp = static_cast<grpc_tcp*>(arg);
grpc_closure* cb; grpc_closure* cb;
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
cb = tcp->write_cb; cb = tcp->write_cb;
tcp->write_cb = nullptr; tcp->write_cb = nullptr;
if (tcp->current_zerocopy_send != nullptr) { if (tcp->current_zerocopy_send != nullptr) {
@ -1560,7 +1560,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */,
} }
notify_on_write(tcp); notify_on_write(tcp);
// tcp_flush does not populate error if it has returned false. // tcp_flush does not populate error if it has returned false.
GPR_DEBUG_ASSERT(error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(GRPC_ERROR_IS_NONE(error));
} else { } else {
cb = tcp->write_cb; cb = tcp->write_cb;
tcp->write_cb = nullptr; tcp->write_cb = nullptr;

@ -191,7 +191,7 @@ static void tcp_server_destroy(grpc_tcp_server* s) {
static void on_read(void* arg, grpc_error_handle err) { static void on_read(void* arg, grpc_error_handle err) {
grpc_tcp_listener* sp = static_cast<grpc_tcp_listener*>(arg); grpc_tcp_listener* sp = static_cast<grpc_tcp_listener*>(arg);
grpc_pollset* read_notifier_pollset; grpc_pollset* read_notifier_pollset;
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
goto error; goto error;
} }
@ -253,7 +253,7 @@ static void on_read(void* arg, grpc_error_handle err) {
err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_CONNECTION_USAGE, err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_CONNECTION_USAGE,
sp->server->channel_args); sp->server->channel_args);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
goto error; goto error;
} }
@ -344,14 +344,14 @@ static grpc_error_handle add_wildcard_addrs_to_server(grpc_tcp_server* s,
} }
} }
if (*out_port > 0) { if (*out_port > 0) {
if (v6_err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(v6_err)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"Failed to add :: listener, " "Failed to add :: listener, "
"the environment may not support IPv6: %s", "the environment may not support IPv6: %s",
grpc_error_std_string(v6_err).c_str()); grpc_error_std_string(v6_err).c_str());
GRPC_ERROR_UNREF(v6_err); GRPC_ERROR_UNREF(v6_err);
} }
if (v4_err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(v4_err)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"Failed to add 0.0.0.0 listener, " "Failed to add 0.0.0.0 listener, "
"the environment may not support IPv4: %s", "the environment may not support IPv4: %s",
@ -362,7 +362,7 @@ static grpc_error_handle add_wildcard_addrs_to_server(grpc_tcp_server* s,
} else { } else {
grpc_error_handle root_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING( grpc_error_handle root_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to add any wildcard listeners"); "Failed to add any wildcard listeners");
GPR_ASSERT(v6_err != GRPC_ERROR_NONE && v4_err != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(v6_err) && !GRPC_ERROR_IS_NONE(v4_err));
root_err = grpc_error_add_child(root_err, v6_err); root_err = grpc_error_add_child(root_err, v6_err);
root_err = grpc_error_add_child(root_err, v4_err); root_err = grpc_error_add_child(root_err, v4_err);
return root_err; return root_err;
@ -385,10 +385,10 @@ static grpc_error_handle clone_port(grpc_tcp_listener* listener,
grpc_dualstack_mode dsmode; grpc_dualstack_mode dsmode;
err = grpc_create_dualstack_socket(&listener->addr, SOCK_STREAM, 0, &dsmode, err = grpc_create_dualstack_socket(&listener->addr, SOCK_STREAM, 0, &dsmode,
&fd); &fd);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
err = grpc_tcp_server_prepare_socket(listener->server, fd, &listener->addr, err = grpc_tcp_server_prepare_socket(listener->server, fd, &listener->addr,
true, &port); true, &port);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
listener->server->nports++; listener->server->nports++;
addr_str = grpc_sockaddr_to_string(&listener->addr, true); addr_str = grpc_sockaddr_to_string(&listener->addr, true);
if (!addr_str.ok()) { if (!addr_str.ok()) {

@ -90,7 +90,7 @@ static grpc_error_handle add_socket_to_server(grpc_tcp_server* s, int fd,
grpc_error_handle err = grpc_error_handle err =
grpc_tcp_server_prepare_socket(s, fd, addr, s->so_reuseport, &port); grpc_tcp_server_prepare_socket(s, fd, addr, s->so_reuseport, &port);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
GPR_ASSERT(port > 0); GPR_ASSERT(port > 0);
absl::StatusOr<std::string> addr_str = grpc_sockaddr_to_string(addr, true); absl::StatusOr<std::string> addr_str = grpc_sockaddr_to_string(addr, true);
if (!addr_str.ok()) { if (!addr_str.ok()) {
@ -137,7 +137,7 @@ grpc_error_handle grpc_tcp_server_add_addr(grpc_tcp_server* s,
int fd; int fd;
grpc_error_handle err = grpc_error_handle err =
grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, dsmode, &fd); grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, dsmode, &fd);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
if (*dsmode == GRPC_DSMODE_IPV4 && if (*dsmode == GRPC_DSMODE_IPV4 &&
@ -158,36 +158,36 @@ grpc_error_handle grpc_tcp_server_prepare_socket(
if (so_reuseport && !grpc_is_unix_socket(addr)) { if (so_reuseport && !grpc_is_unix_socket(addr)) {
err = grpc_set_socket_reuse_port(fd, 1); err = grpc_set_socket_reuse_port(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
} }
#ifdef GRPC_LINUX_ERRQUEUE #ifdef GRPC_LINUX_ERRQUEUE
err = grpc_set_socket_zerocopy(fd); err = grpc_set_socket_zerocopy(fd);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
/* it's not fatal, so just log it. */ /* it's not fatal, so just log it. */
gpr_log(GPR_DEBUG, "Node does not support SO_ZEROCOPY, continuing."); gpr_log(GPR_DEBUG, "Node does not support SO_ZEROCOPY, continuing.");
GRPC_ERROR_UNREF(err); GRPC_ERROR_UNREF(err);
} }
#endif #endif
err = grpc_set_socket_nonblocking(fd, 1); err = grpc_set_socket_nonblocking(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_set_socket_cloexec(fd, 1); err = grpc_set_socket_cloexec(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
if (!grpc_is_unix_socket(addr)) { if (!grpc_is_unix_socket(addr)) {
err = grpc_set_socket_low_latency(fd, 1); err = grpc_set_socket_low_latency(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_set_socket_reuse_addr(fd, 1); err = grpc_set_socket_reuse_addr(fd, 1);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_set_socket_tcp_user_timeout(fd, s->channel_args, err = grpc_set_socket_tcp_user_timeout(fd, s->channel_args,
false /* is_client */); false /* is_client */);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
} }
err = grpc_set_socket_no_sigpipe_if_possible(fd); err = grpc_set_socket_no_sigpipe_if_possible(fd);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_LISTENER_USAGE, err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_LISTENER_USAGE,
s->channel_args); s->channel_args);
if (err != GRPC_ERROR_NONE) goto error; if (!GRPC_ERROR_IS_NONE(err)) goto error;
if (bind(fd, reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr)), if (bind(fd, reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr)),
addr->len) < 0) { addr->len) < 0) {
@ -212,7 +212,7 @@ grpc_error_handle grpc_tcp_server_prepare_socket(
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
error: error:
GPR_ASSERT(err != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(err));
if (fd >= 0) { if (fd >= 0) {
close(fd); close(fd);
} }

@ -65,7 +65,7 @@ static grpc_error_handle get_unused_port(int* port) {
int fd; int fd;
grpc_error_handle err = grpc_error_handle err =
grpc_create_dualstack_socket(&wild, SOCK_STREAM, 0, &dsmode, &fd); grpc_create_dualstack_socket(&wild, SOCK_STREAM, 0, &dsmode, &fd);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} }
if (dsmode == GRPC_DSMODE_IPV4) { if (dsmode == GRPC_DSMODE_IPV4) {
@ -164,7 +164,7 @@ grpc_error_handle grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
} }
} }
freeifaddrs(ifa); freeifaddrs(ifa);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
return err; return err;
} else if (sp == nullptr) { } else if (sp == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No local addresses"); return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No local addresses");

@ -197,7 +197,7 @@ static grpc_error_handle prepare_socket(SOCKET sock,
int sockname_temp_len; int sockname_temp_len;
error = grpc_tcp_prepare_socket(sock); error = grpc_tcp_prepare_socket(sock);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
goto failure; goto failure;
} }
@ -224,7 +224,7 @@ static grpc_error_handle prepare_socket(SOCKET sock,
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
failure: failure:
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
auto addr_uri = grpc_sockaddr_to_uri(addr); auto addr_uri = grpc_sockaddr_to_uri(addr);
grpc_error_set_int( grpc_error_set_int(
grpc_error_set_str( grpc_error_set_str(
@ -267,7 +267,7 @@ static grpc_error_handle start_accept_locked(grpc_tcp_listener* port) {
} }
error = grpc_tcp_prepare_socket(sock); error = grpc_tcp_prepare_socket(sock);
if (error != GRPC_ERROR_NONE) goto failure; if (!GRPC_ERROR_IS_NONE(error)) goto failure;
/* Start the "accept" asynchronously. */ /* Start the "accept" asynchronously. */
success = port->AcceptEx(port->socket->socket, sock, port->addresses, 0, success = port->AcceptEx(port->socket->socket, sock, port->addresses, 0,
@ -292,7 +292,7 @@ static grpc_error_handle start_accept_locked(grpc_tcp_listener* port) {
return error; return error;
failure: failure:
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
if (sock != INVALID_SOCKET) closesocket(sock); if (sock != INVALID_SOCKET) closesocket(sock);
return error; return error;
} }
@ -316,7 +316,7 @@ static void on_accept(void* arg, grpc_error_handle error) {
/* The general mechanism for shutting down is to queue abortion calls. While /* The general mechanism for shutting down is to queue abortion calls. While
this is necessary in the read/write case, it's useless for the accept this is necessary in the read/write case, it's useless for the accept
case. We only need to adjust the pending callback count */ case. We only need to adjust the pending callback count */
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_INFO, "Skipping on_accept due to error: %s", gpr_log(GPR_INFO, "Skipping on_accept due to error: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
@ -419,7 +419,7 @@ static grpc_error_handle add_socket_to_server(grpc_tcp_server* s, SOCKET sock,
} }
error = prepare_socket(sock, addr, &port); error = prepare_socket(sock, addr, &port);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
return error; return error;
} }
@ -511,7 +511,7 @@ static grpc_error_handle tcp_server_add_port(grpc_tcp_server* s,
done: done:
gpr_free(allocated_addr); gpr_free(allocated_addr);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
grpc_error_handle error_out = grpc_error_handle error_out =
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to add port to server", &error, 1); "Failed to add port to server", &error, 1);

@ -89,11 +89,11 @@ static grpc_error_handle enable_socket_low_latency(SOCKET sock) {
grpc_error_handle grpc_tcp_prepare_socket(SOCKET sock) { grpc_error_handle grpc_tcp_prepare_socket(SOCKET sock) {
grpc_error_handle err; grpc_error_handle err;
err = grpc_tcp_set_non_block(sock); err = grpc_tcp_set_non_block(sock);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
err = set_dualstack(sock); err = set_dualstack(sock);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
err = enable_socket_low_latency(sock); err = enable_socket_low_latency(sock);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -186,7 +186,7 @@ static void on_read(void* tcpp, grpc_error_handle error) {
(void)GRPC_ERROR_REF(error); (void)GRPC_ERROR_REF(error);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (info->wsa_error != 0 && !tcp->shutting_down) { if (info->wsa_error != 0 && !tcp->shutting_down) {
char* utf8_message = gpr_format_message(info->wsa_error); char* utf8_message = gpr_format_message(info->wsa_error);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(utf8_message); error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(utf8_message);
@ -331,7 +331,7 @@ static void on_write(void* tcpp, grpc_error_handle error) {
tcp->write_cb = NULL; tcp->write_cb = NULL;
gpr_mu_unlock(&tcp->mu); gpr_mu_unlock(&tcp->mu);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
if (info->wsa_error != 0) { if (info->wsa_error != 0) {
error = GRPC_WSA_ERROR(info->wsa_error, "WSASend"); error = GRPC_WSA_ERROR(info->wsa_error, "WSASend");
} else { } else {

@ -45,7 +45,7 @@ absl::StatusOr<std::vector<grpc_resolved_address>>
grpc_resolve_unix_domain_address(absl::string_view name) { grpc_resolve_unix_domain_address(absl::string_view name) {
grpc_resolved_address addr; grpc_resolved_address addr;
grpc_error_handle error = grpc_core::UnixSockaddrPopulate(name, &addr); grpc_error_handle error = grpc_core::UnixSockaddrPopulate(name, &addr);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
return std::vector<grpc_resolved_address>({addr}); return std::vector<grpc_resolved_address>({addr});
} }
auto result = grpc_error_to_absl_status(error); auto result = grpc_error_to_absl_status(error);
@ -58,7 +58,7 @@ grpc_resolve_unix_abstract_domain_address(const absl::string_view name) {
grpc_resolved_address addr; grpc_resolved_address addr;
grpc_error_handle error = grpc_error_handle error =
grpc_core::UnixAbstractSockaddrPopulate(name, &addr); grpc_core::UnixAbstractSockaddrPopulate(name, &addr);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
return std::vector<grpc_resolved_address>({addr}); return std::vector<grpc_resolved_address>({addr});
} }
auto result = grpc_error_to_absl_status(error); auto result = grpc_error_to_absl_status(error);

@ -41,9 +41,9 @@ static grpc_error_handle pipe_init(grpc_wakeup_fd* fd_info) {
} }
grpc_error_handle err; grpc_error_handle err;
err = grpc_set_socket_nonblocking(pipefd[0], 1); err = grpc_set_socket_nonblocking(pipefd[0], 1);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
err = grpc_set_socket_nonblocking(pipefd[1], 1); err = grpc_set_socket_nonblocking(pipefd[1], 1);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
fd_info->read_fd = pipefd[0]; fd_info->read_fd = pipefd[0];
fd_info->write_fd = pipefd[1]; fd_info->write_fd = pipefd[1];
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;

@ -50,7 +50,7 @@ EvaluateArgs::PerChannelArgs::Address ParseEndpointUri(
address.address_str = std::string(host_view); address.address_str = std::string(host_view);
grpc_error_handle error = grpc_string_to_sockaddr( grpc_error_handle error = grpc_string_to_sockaddr(
&address.address, address.address_str.c_str(), address.port); &address.address, address.address_str.c_str(), address.port);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_DEBUG, "Address %s is not IPv4/IPv6. Error: %s", gpr_log(GPR_DEBUG, "Address %s is not IPv4/IPv6. Error: %s",
address.address_str.c_str(), grpc_error_std_string(error).c_str()); address.address_str.c_str(), grpc_error_std_string(error).c_str());
} }

@ -50,7 +50,7 @@ absl::StatusOr<std::string> ReadPolicyFromFile(absl::string_view policy_path) {
grpc_slice policy_slice = grpc_empty_slice(); grpc_slice policy_slice = grpc_empty_slice();
grpc_error_handle error = grpc_error_handle error =
grpc_load_file(std::string(policy_path).c_str(), 0, &policy_slice); grpc_load_file(std::string(policy_path).c_str(), 0, &policy_slice);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
absl::Status status = absl::Status status =
absl::InvalidArgumentError(grpc_error_std_string(error)); absl::InvalidArgumentError(grpc_error_std_string(error));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

@ -145,7 +145,7 @@ IpAuthorizationMatcher::IpAuthorizationMatcher(Type type, Rbac::CidrRange range)
grpc_error_handle error = grpc_error_handle error =
grpc_string_to_sockaddr(&subnet_address_, range.address_prefix.c_str(), grpc_string_to_sockaddr(&subnet_address_, range.address_prefix.c_str(),
/*port does not matter here*/ 0); /*port does not matter here*/ 0);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
grpc_sockaddr_mask_bits(&subnet_address_, prefix_len_); grpc_sockaddr_mask_bits(&subnet_address_, prefix_len_);
} else { } else {
gpr_log(GPR_DEBUG, "CidrRange address %s is not IPv4/IPv6. Error: %s", gpr_log(GPR_DEBUG, "CidrRange address %s is not IPv4/IPv6. Error: %s",

@ -317,7 +317,7 @@ absl::StatusOr<RbacPolicies> GenerateRbacPolicies(
absl::string_view authz_policy) { absl::string_view authz_policy) {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
Json json = Json::Parse(authz_policy, &error); Json json = Json::Parse(authz_policy, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
absl::Status status = absl::InvalidArgumentError( absl::Status status = absl::InvalidArgumentError(
absl::StrCat("Failed to parse gRPC authorization policy. Error: ", absl::StrCat("Failed to parse gRPC authorization policy. Error: ",
grpc_error_std_string(error))); grpc_error_std_string(error)));

@ -64,7 +64,7 @@ AwsExternalAccountCredentials::Create(Options options,
grpc_error_handle* error) { grpc_error_handle* error) {
auto creds = MakeRefCounted<AwsExternalAccountCredentials>( auto creds = MakeRefCounted<AwsExternalAccountCredentials>(
std::move(options), std::move(scopes), error); std::move(options), std::move(scopes), error);
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
return creds; return creds;
} else { } else {
return nullptr; return nullptr;
@ -191,7 +191,7 @@ void AwsExternalAccountCredentials::OnRetrieveImdsV2SessionToken(
void AwsExternalAccountCredentials::OnRetrieveImdsV2SessionTokenInternal( void AwsExternalAccountCredentials::OnRetrieveImdsV2SessionTokenInternal(
grpc_error_handle error) { grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken("", error); FinishRetrieveSubjectToken("", error);
return; return;
} }
@ -269,7 +269,7 @@ void AwsExternalAccountCredentials::OnRetrieveRegion(void* arg,
void AwsExternalAccountCredentials::OnRetrieveRegionInternal( void AwsExternalAccountCredentials::OnRetrieveRegionInternal(
grpc_error_handle error) { grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken("", error); FinishRetrieveSubjectToken("", error);
return; return;
} }
@ -323,7 +323,7 @@ void AwsExternalAccountCredentials::OnRetrieveRoleName(
void AwsExternalAccountCredentials::OnRetrieveRoleNameInternal( void AwsExternalAccountCredentials::OnRetrieveRoleNameInternal(
grpc_error_handle error) { grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken("", error); FinishRetrieveSubjectToken("", error);
return; return;
} }
@ -389,14 +389,14 @@ void AwsExternalAccountCredentials::OnRetrieveSigningKeys(
void AwsExternalAccountCredentials::OnRetrieveSigningKeysInternal( void AwsExternalAccountCredentials::OnRetrieveSigningKeysInternal(
grpc_error_handle error) { grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken("", error); FinishRetrieveSubjectToken("", error);
return; return;
} }
absl::string_view response_body(ctx_->response.body, absl::string_view response_body(ctx_->response.body,
ctx_->response.body_length); ctx_->response.body_length);
Json json = Json::Parse(response_body, &error); Json json = Json::Parse(response_body, &error);
if (error != GRPC_ERROR_NONE || json.type() != Json::Type::OBJECT) { if (!GRPC_ERROR_IS_NONE(error) || json.type() != Json::Type::OBJECT) {
FinishRetrieveSubjectToken( FinishRetrieveSubjectToken(
"", GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "", GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Invalid retrieve signing keys response.", &error, 1)); "Invalid retrieve signing keys response.", &error, 1));
@ -445,7 +445,7 @@ void AwsExternalAccountCredentials::BuildSubjectToken() {
access_key_id_, secret_access_key_, token_, "POST", access_key_id_, secret_access_key_, token_, "POST",
cred_verification_url_, region_, "", cred_verification_url_, region_, "",
std::map<std::string, std::string>(), &error); std::map<std::string, std::string>(), &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken( FinishRetrieveSubjectToken(
"", GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "", GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Creating aws request signer failed.", &error, 1)); "Creating aws request signer failed.", &error, 1));
@ -454,7 +454,7 @@ void AwsExternalAccountCredentials::BuildSubjectToken() {
} }
} }
auto signed_headers = signer_->GetSignedRequestHeaders(); auto signed_headers = signer_->GetSignedRequestHeaders();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken("", FinishRetrieveSubjectToken("",
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Invalid getting signed request" "Invalid getting signed request"
@ -490,7 +490,7 @@ void AwsExternalAccountCredentials::FinishRetrieveSubjectToken(
auto cb = cb_; auto cb = cb_;
cb_ = nullptr; cb_ = nullptr;
// Invoke the callback. // Invoke the callback.
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
cb("", error); cb("", error);
} else { } else {
cb(subject_token, GRPC_ERROR_NONE); cb(subject_token, GRPC_ERROR_NONE);

@ -87,7 +87,7 @@ bool MatchWorkforcePoolAudience(absl::string_view audience) {
RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create( RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
const Json& json, std::vector<std::string> scopes, const Json& json, std::vector<std::string> scopes,
grpc_error_handle* error) { grpc_error_handle* error) {
GPR_ASSERT(*error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_ERROR_IS_NONE(*error));
Options options; Options options;
options.type = GRPC_AUTH_JSON_TYPE_INVALID; options.type = GRPC_AUTH_JSON_TYPE_INVALID;
if (json.type() != Json::Type::OBJECT) { if (json.type() != Json::Type::OBJECT) {
@ -203,7 +203,7 @@ RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
"Invalid options credential source to create " "Invalid options credential source to create "
"ExternalAccountCredentials."); "ExternalAccountCredentials.");
} }
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
return creds; return creds;
} else { } else {
return nullptr; return nullptr;
@ -255,7 +255,7 @@ void ExternalAccountCredentials::fetch_oauth2(
void ExternalAccountCredentials::OnRetrieveSubjectTokenInternal( void ExternalAccountCredentials::OnRetrieveSubjectTokenInternal(
absl::string_view subject_token, grpc_error_handle error) { absl::string_view subject_token, grpc_error_handle error) {
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishTokenFetch(error); FinishTokenFetch(error);
} else { } else {
ExchangeToken(subject_token); ExchangeToken(subject_token);
@ -355,7 +355,7 @@ void ExternalAccountCredentials::OnExchangeToken(void* arg,
void ExternalAccountCredentials::OnExchangeTokenInternal( void ExternalAccountCredentials::OnExchangeTokenInternal(
grpc_error_handle error) { grpc_error_handle error) {
http_request_.reset(); http_request_.reset();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishTokenFetch(error); FinishTokenFetch(error);
} else { } else {
if (options_.service_account_impersonation_url.empty()) { if (options_.service_account_impersonation_url.empty()) {
@ -382,7 +382,7 @@ void ExternalAccountCredentials::ImpersenateServiceAccount() {
absl::string_view response_body(ctx_->response.body, absl::string_view response_body(ctx_->response.body,
ctx_->response.body_length); ctx_->response.body_length);
Json json = Json::Parse(response_body, &error); Json json = Json::Parse(response_body, &error);
if (error != GRPC_ERROR_NONE || json.type() != Json::Type::OBJECT) { if (!GRPC_ERROR_IS_NONE(error) || json.type() != Json::Type::OBJECT) {
FinishTokenFetch(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( FinishTokenFetch(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Invalid token exchange response.", &error, 1)); "Invalid token exchange response.", &error, 1));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -449,14 +449,14 @@ void ExternalAccountCredentials::OnImpersenateServiceAccount(
void ExternalAccountCredentials::OnImpersenateServiceAccountInternal( void ExternalAccountCredentials::OnImpersenateServiceAccountInternal(
grpc_error_handle error) { grpc_error_handle error) {
http_request_.reset(); http_request_.reset();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishTokenFetch(error); FinishTokenFetch(error);
return; return;
} }
absl::string_view response_body(ctx_->response.body, absl::string_view response_body(ctx_->response.body,
ctx_->response.body_length); ctx_->response.body_length);
Json json = Json::Parse(response_body, &error); Json json = Json::Parse(response_body, &error);
if (error != GRPC_ERROR_NONE || json.type() != Json::Type::OBJECT) { if (!GRPC_ERROR_IS_NONE(error) || json.type() != Json::Type::OBJECT) {
FinishTokenFetch(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( FinishTokenFetch(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Invalid service account impersonation response.", &error, 1)); "Invalid service account impersonation response.", &error, 1));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -525,7 +525,7 @@ grpc_call_credentials* grpc_external_account_credentials_create(
const char* json_string, const char* scopes_string) { const char* json_string, const char* scopes_string) {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
grpc_core::Json json = grpc_core::Json::Parse(json_string, &error); grpc_core::Json json = grpc_core::Json::Parse(json_string, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"External account credentials creation failed. Error: %s.", "External account credentials creation failed. Error: %s.",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
@ -536,7 +536,7 @@ grpc_call_credentials* grpc_external_account_credentials_create(
auto creds = grpc_core::ExternalAccountCredentials::Create( auto creds = grpc_core::ExternalAccountCredentials::Create(
json, std::move(scopes), &error) json, std::move(scopes), &error)
.release(); .release();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"External account credentials creation failed. Error: %s.", "External account credentials creation failed. Error: %s.",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());

@ -30,7 +30,7 @@ FileExternalAccountCredentials::Create(Options options,
grpc_error_handle* error) { grpc_error_handle* error) {
auto creds = MakeRefCounted<FileExternalAccountCredentials>( auto creds = MakeRefCounted<FileExternalAccountCredentials>(
std::move(options), std::move(scopes), error); std::move(options), std::move(scopes), error);
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
return creds; return creds;
} else { } else {
return nullptr; return nullptr;
@ -101,14 +101,15 @@ void FileExternalAccountCredentials::RetrieveSubjectToken(
// request because it may have changed since the last request. // request because it may have changed since the last request.
grpc_error_handle error = grpc_error_handle error =
grpc_load_file(file_.c_str(), 0, &content_slice.slice); grpc_load_file(file_.c_str(), 0, &content_slice.slice);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
cb("", error); cb("", error);
return; return;
} }
absl::string_view content = StringViewFromSlice(content_slice.slice); absl::string_view content = StringViewFromSlice(content_slice.slice);
if (format_type_ == "json") { if (format_type_ == "json") {
Json content_json = Json::Parse(content, &error); Json content_json = Json::Parse(content, &error);
if (error != GRPC_ERROR_NONE || content_json.type() != Json::Type::OBJECT) { if (!GRPC_ERROR_IS_NONE(error) ||
content_json.type() != Json::Type::OBJECT) {
cb("", GRPC_ERROR_CREATE_FROM_STATIC_STRING( cb("", GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"The content of the file is not a valid json object.")); "The content of the file is not a valid json object."));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

@ -34,7 +34,7 @@ UrlExternalAccountCredentials::Create(Options options,
grpc_error_handle* error) { grpc_error_handle* error) {
auto creds = MakeRefCounted<UrlExternalAccountCredentials>( auto creds = MakeRefCounted<UrlExternalAccountCredentials>(
std::move(options), std::move(scopes), error); std::move(options), std::move(scopes), error);
if (*error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(*error)) {
return creds; return creds;
} else { } else {
return nullptr; return nullptr;
@ -179,7 +179,7 @@ void UrlExternalAccountCredentials::OnRetrieveSubjectToken(
void UrlExternalAccountCredentials::OnRetrieveSubjectTokenInternal( void UrlExternalAccountCredentials::OnRetrieveSubjectTokenInternal(
grpc_error_handle error) { grpc_error_handle error) {
http_request_.reset(); http_request_.reset();
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
FinishRetrieveSubjectToken("", error); FinishRetrieveSubjectToken("", error);
return; return;
} }
@ -188,7 +188,7 @@ void UrlExternalAccountCredentials::OnRetrieveSubjectTokenInternal(
if (format_type_ == "json") { if (format_type_ == "json") {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
Json response_json = Json::Parse(response_body, &error); Json response_json = Json::Parse(response_body, &error);
if (error != GRPC_ERROR_NONE || if (!GRPC_ERROR_IS_NONE(error) ||
response_json.type() != Json::Type::OBJECT) { response_json.type() != Json::Type::OBJECT) {
FinishRetrieveSubjectToken( FinishRetrieveSubjectToken(
"", GRPC_ERROR_CREATE_FROM_STATIC_STRING( "", GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@ -222,7 +222,7 @@ void UrlExternalAccountCredentials::FinishRetrieveSubjectToken(
auto cb = cb_; auto cb = cb_;
cb_ = nullptr; cb_ = nullptr;
// Invoke the callback. // Invoke the callback.
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
cb("", error); cb("", error);
} else { } else {
cb(subject_token, GRPC_ERROR_NONE); cb(subject_token, GRPC_ERROR_NONE);

@ -157,7 +157,7 @@ static void on_metadata_server_detection_http_response(
void* user_data, grpc_error_handle error) { void* user_data, grpc_error_handle error) {
metadata_server_detector* detector = metadata_server_detector* detector =
static_cast<metadata_server_detector*>(user_data); static_cast<metadata_server_detector*>(user_data);
if (error == GRPC_ERROR_NONE && detector->response.status == 200 && if (GRPC_ERROR_IS_NONE(error) && detector->response.status == 200 &&
detector->response.hdr_count > 0) { detector->response.hdr_count > 0) {
/* Internet providers can return a generic response to all requests, so /* Internet providers can return a generic response to all requests, so
it is necessary to check that metadata header is present also. */ it is necessary to check that metadata header is present also. */
@ -300,9 +300,9 @@ static grpc_error_handle create_default_creds_from_path(
goto end; goto end;
} }
error = grpc_load_file(creds_path.c_str(), 0, &creds_data); error = grpc_load_file(creds_path.c_str(), 0, &creds_data);
if (error != GRPC_ERROR_NONE) goto end; if (!GRPC_ERROR_IS_NONE(error)) goto end;
json = Json::Parse(grpc_core::StringViewFromSlice(creds_data), &error); json = Json::Parse(grpc_core::StringViewFromSlice(creds_data), &error);
if (error != GRPC_ERROR_NONE) goto end; if (!GRPC_ERROR_IS_NONE(error)) goto end;
if (json.type() != Json::Type::OBJECT) { if (json.type() != Json::Type::OBJECT) {
error = grpc_error_set_str( error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"),
@ -346,7 +346,7 @@ static grpc_error_handle create_default_creds_from_path(
result = grpc_core::ExternalAccountCredentials::Create(json, {}, &error); result = grpc_core::ExternalAccountCredentials::Create(json, {}, &error);
end: end:
GPR_ASSERT((result == nullptr) + (error == GRPC_ERROR_NONE) == 1); GPR_ASSERT((result == nullptr) + (GRPC_ERROR_IS_NONE(error)) == 1);
grpc_slice_unref_internal(creds_data); grpc_slice_unref_internal(creds_data);
*creds = result; *creds = result;
return error; return error;
@ -383,14 +383,14 @@ static grpc_core::RefCountedPtr<grpc_call_credentials> make_default_call_creds(
if (path_from_env != nullptr) { if (path_from_env != nullptr) {
err = create_default_creds_from_path(path_from_env, &call_creds); err = create_default_creds_from_path(path_from_env, &call_creds);
gpr_free(path_from_env); gpr_free(path_from_env);
if (err == GRPC_ERROR_NONE) return call_creds; if (GRPC_ERROR_IS_NONE(err)) return call_creds;
*error = grpc_error_add_child(*error, err); *error = grpc_error_add_child(*error, err);
} }
/* Then the well-known file. */ /* Then the well-known file. */
err = create_default_creds_from_path( err = create_default_creds_from_path(
grpc_get_well_known_google_credentials_file_path(), &call_creds); grpc_get_well_known_google_credentials_file_path(), &call_creds);
if (err == GRPC_ERROR_NONE) return call_creds; if (GRPC_ERROR_IS_NONE(err)) return call_creds;
*error = grpc_error_add_child(*error, err); *error = grpc_error_add_child(*error, err);
update_tenancy(); update_tenancy();

@ -137,7 +137,7 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
static char* redact_private_key(const char* json_key) { static char* redact_private_key(const char* json_key) {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
Json json = Json::Parse(json_key, &error); Json json = Json::Parse(json_key, &error);
if (error != GRPC_ERROR_NONE || json.type() != Json::Type::OBJECT) { if (!GRPC_ERROR_IS_NONE(error) || json.type() != Json::Type::OBJECT) {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
return gpr_strdup("<Json failed to parse.>"); return gpr_strdup("<Json failed to parse.>");
} }

@ -88,7 +88,7 @@ static Json parse_json_part_from_jwt(const char* str, size_t len) {
absl::string_view string = grpc_core::StringViewFromSlice(slice); absl::string_view string = grpc_core::StringViewFromSlice(slice);
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
Json json = Json::Parse(string, &error); Json json = Json::Parse(string, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "JSON parse error: %s", gpr_log(GPR_ERROR, "JSON parse error: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -413,7 +413,7 @@ static Json json_from_http(const grpc_http_response* response) {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
Json json = Json::Parse( Json json = Json::Parse(
absl::string_view(response->body, response->body_length), &error); absl::string_view(response->body, response->body_length), &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "Invalid JSON found in response."); gpr_log(GPR_ERROR, "Invalid JSON found in response.");
return Json(); // JSON null return Json(); // JSON null
} }

@ -103,7 +103,7 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
const char* json_string) { const char* json_string) {
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
Json json = Json::Parse(json_string, &error); Json json = Json::Parse(json_string, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "JSON parsing failed: %s", gpr_log(GPR_ERROR, "JSON parsing failed: %s",
grpc_error_std_string(error).c_str()); grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -173,7 +173,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
Json::Object::const_iterator it; Json::Object::const_iterator it;
grpc_error_handle error = GRPC_ERROR_NONE; grpc_error_handle error = GRPC_ERROR_NONE;
json = Json::Parse(null_terminated_body, &error); json = Json::Parse(null_terminated_body, &error);
if (error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(error)) {
gpr_log(GPR_ERROR, "Could not parse JSON from %s: %s", gpr_log(GPR_ERROR, "Could not parse JSON from %s: %s",
null_terminated_body, grpc_error_std_string(error).c_str()); null_terminated_body, grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
@ -237,7 +237,7 @@ void grpc_oauth2_token_fetcher_credentials::on_http_response(
absl::optional<grpc_core::Slice> access_token_value; absl::optional<grpc_core::Slice> access_token_value;
grpc_core::Duration token_lifetime; grpc_core::Duration token_lifetime;
grpc_credentials_status status = grpc_credentials_status status =
error == GRPC_ERROR_NONE GRPC_ERROR_IS_NONE(error)
? grpc_oauth2_token_fetcher_credentials_parse_server_response( ? grpc_oauth2_token_fetcher_credentials_parse_server_response(
&r->response, &access_token_value, &token_lifetime) &r->response, &access_token_value, &token_lifetime)
: GRPC_CREDENTIALS_ERROR; : GRPC_CREDENTIALS_ERROR;
@ -523,7 +523,7 @@ void MaybeAddToBody(const char* field_name, const char* field,
grpc_error_handle LoadTokenFile(const char* path, gpr_slice* token) { grpc_error_handle LoadTokenFile(const char* path, gpr_slice* token) {
grpc_error_handle err = grpc_load_file(path, 1, token); grpc_error_handle err = grpc_load_file(path, 1, token);
if (err != GRPC_ERROR_NONE) return err; if (!GRPC_ERROR_IS_NONE(err)) return err;
if (GRPC_SLICE_LENGTH(*token) == 0) { if (GRPC_SLICE_LENGTH(*token) == 0) {
gpr_log(GPR_ERROR, "Token file %s is empty", path); gpr_log(GPR_ERROR, "Token file %s is empty", path);
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Token file is empty."); err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Token file is empty.");
@ -561,7 +561,7 @@ class StsTokenFetcherCredentials
grpc_http_request request; grpc_http_request request;
memset(&request, 0, sizeof(grpc_http_request)); memset(&request, 0, sizeof(grpc_http_request));
grpc_error_handle err = FillBody(&request.body, &request.body_length); grpc_error_handle err = FillBody(&request.body, &request.body_length);
if (err != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(err)) {
response_cb(metadata_req, err); response_cb(metadata_req, err);
GRPC_ERROR_UNREF(err); GRPC_ERROR_UNREF(err);
return; return;
@ -599,7 +599,7 @@ class StsTokenFetcherCredentials
auto cleanup = [&body, &body_length, &body_parts, &subject_token, auto cleanup = [&body, &body_length, &body_parts, &subject_token,
&actor_token, &err]() { &actor_token, &err]() {
if (err == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(err)) {
std::string body_str = absl::StrJoin(body_parts, ""); std::string body_str = absl::StrJoin(body_parts, "");
*body = gpr_strdup(body_str.c_str()); *body = gpr_strdup(body_str.c_str());
*body_length = body_str.size(); *body_length = body_str.size();
@ -610,7 +610,7 @@ class StsTokenFetcherCredentials
}; };
err = LoadTokenFile(subject_token_path_.get(), &subject_token); err = LoadTokenFile(subject_token_path_.get(), &subject_token);
if (err != GRPC_ERROR_NONE) return cleanup(); if (!GRPC_ERROR_IS_NONE(err)) return cleanup();
body_parts.push_back(absl::StrFormat( body_parts.push_back(absl::StrFormat(
GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING, GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING,
reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(subject_token)), reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(subject_token)),
@ -622,7 +622,7 @@ class StsTokenFetcherCredentials
&body_parts); &body_parts);
if ((actor_token_path_ != nullptr) && *actor_token_path_ != '\0') { if ((actor_token_path_ != nullptr) && *actor_token_path_ != '\0') {
err = LoadTokenFile(actor_token_path_.get(), &actor_token); err = LoadTokenFile(actor_token_path_.get(), &actor_token);
if (err != GRPC_ERROR_NONE) return cleanup(); if (!GRPC_ERROR_IS_NONE(err)) return cleanup();
MaybeAddToBody( MaybeAddToBody(
"actor_token", "actor_token",
reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(actor_token)), reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(actor_token)),

@ -154,7 +154,7 @@ void grpc_tls_certificate_distributor::SetErrorForCert(
}; };
void grpc_tls_certificate_distributor::SetError(grpc_error_handle error) { void grpc_tls_certificate_distributor::SetError(grpc_error_handle error) {
GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(!GRPC_ERROR_IS_NONE(error));
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
for (const auto& watcher : watchers_) { for (const auto& watcher : watchers_) {
const auto watcher_ptr = watcher.first; const auto watcher_ptr = watcher.first;
@ -232,7 +232,8 @@ void grpc_tls_certificate_distributor::WatchTlsCertificates(
std::move(updated_identity_pairs)); std::move(updated_identity_pairs));
} }
// Notify this watcher if the certs it is watching already had some errors. // Notify this watcher if the certs it is watching already had some errors.
if (root_error != GRPC_ERROR_NONE || identity_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(root_error) ||
!GRPC_ERROR_IS_NONE(identity_error)) {
watcher_ptr->OnError(GRPC_ERROR_REF(root_error), watcher_ptr->OnError(GRPC_ERROR_REF(root_error),
GRPC_ERROR_REF(identity_error)); GRPC_ERROR_REF(identity_error));
} }

@ -71,8 +71,8 @@ StaticDataCertificateProvider::StaticDataCertificateProvider(
identity_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( identity_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Unable to get latest identity certificates."); "Unable to get latest identity certificates.");
} }
if (root_cert_error != GRPC_ERROR_NONE || if (!GRPC_ERROR_IS_NONE(root_cert_error) ||
identity_cert_error != GRPC_ERROR_NONE) { !GRPC_ERROR_IS_NONE(identity_cert_error)) {
distributor_->SetErrorForCert(cert_name, root_cert_error, distributor_->SetErrorForCert(cert_name, root_cert_error,
identity_cert_error); identity_cert_error);
} }
@ -166,8 +166,8 @@ FileWatcherCertificateProvider::FileWatcherCertificateProvider(
identity_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( identity_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Unable to get latest identity certificates."); "Unable to get latest identity certificates.");
} }
if (root_cert_error != GRPC_ERROR_NONE || if (!GRPC_ERROR_IS_NONE(root_cert_error) ||
identity_cert_error != GRPC_ERROR_NONE) { !GRPC_ERROR_IS_NONE(identity_cert_error)) {
distributor_->SetErrorForCert(cert_name, root_cert_error, distributor_->SetErrorForCert(cert_name, root_cert_error,
identity_cert_error); identity_cert_error);
} }
@ -270,7 +270,7 @@ FileWatcherCertificateProvider::ReadRootCertificatesFromFile(
grpc_slice root_slice = grpc_empty_slice(); grpc_slice root_slice = grpc_empty_slice();
grpc_error_handle root_error = grpc_error_handle root_error =
grpc_load_file(root_cert_full_path.c_str(), 0, &root_slice); grpc_load_file(root_cert_full_path.c_str(), 0, &root_slice);
if (root_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(root_error)) {
gpr_log(GPR_ERROR, "Reading file %s failed: %s", gpr_log(GPR_ERROR, "Reading file %s failed: %s",
root_cert_full_path.c_str(), root_cert_full_path.c_str(),
grpc_error_std_string(root_error).c_str()); grpc_error_std_string(root_error).c_str());
@ -329,7 +329,7 @@ FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles(
SliceWrapper key_slice, cert_slice; SliceWrapper key_slice, cert_slice;
grpc_error_handle key_error = grpc_error_handle key_error =
grpc_load_file(private_key_path.c_str(), 0, &key_slice.slice); grpc_load_file(private_key_path.c_str(), 0, &key_slice.slice);
if (key_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(key_error)) {
gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...", gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...",
private_key_path.c_str(), private_key_path.c_str(),
grpc_error_std_string(key_error).c_str()); grpc_error_std_string(key_error).c_str());
@ -338,7 +338,7 @@ FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles(
} }
grpc_error_handle cert_error = grpc_error_handle cert_error =
grpc_load_file(identity_certificate_path.c_str(), 0, &cert_slice.slice); grpc_load_file(identity_certificate_path.c_str(), 0, &cert_slice.slice);
if (cert_error != GRPC_ERROR_NONE) { if (!GRPC_ERROR_IS_NONE(cert_error)) {
gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...", gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...",
identity_certificate_path.c_str(), identity_certificate_path.c_str(),
grpc_error_std_string(cert_error).c_str()); grpc_error_std_string(cert_error).c_str());

@ -71,7 +71,7 @@ grpc_slice GetSystemRootCerts() {
for (size_t i = 0; i < num_cert_files_; i++) { for (size_t i = 0; i < num_cert_files_; i++) {
grpc_error_handle error = grpc_error_handle error =
grpc_load_file(kCertFiles[i], 1, &valid_bundle_slice); grpc_load_file(kCertFiles[i], 1, &valid_bundle_slice);
if (error == GRPC_ERROR_NONE) { if (GRPC_ERROR_IS_NONE(error)) {
return valid_bundle_slice; return valid_bundle_slice;
} else { } else {
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save