diff --git a/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc b/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc index 1408ae2169f..0b82392273e 100644 --- a/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc +++ b/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc @@ -42,19 +42,19 @@ const char kAuthorityMetadataKey[] = ":authority"; absl::StatusOr parse_metadata(ReadableParcel* reader) { int num_header; - RETURN_IF_ERROR(reader->ReadInt32(&num_header)); + RETURN_IF_NOT_OK(reader->ReadInt32(&num_header)); if (num_header < 0) { return absl::InvalidArgumentError("num_header cannot be negative"); } std::vector> ret; for (int i = 0; i < num_header; i++) { int count; - RETURN_IF_ERROR(reader->ReadInt32(&count)); + RETURN_IF_NOT_OK(reader->ReadInt32(&count)); std::string key{}; - if (count > 0) RETURN_IF_ERROR(reader->ReadByteArray(&key)); - RETURN_IF_ERROR(reader->ReadInt32(&count)); + if (count > 0) RETURN_IF_NOT_OK(reader->ReadByteArray(&key)); + RETURN_IF_NOT_OK(reader->ReadInt32(&count)); std::string value{}; - if (count > 0) RETURN_IF_ERROR(reader->ReadByteArray(&value)); + if (count > 0) RETURN_IF_NOT_OK(reader->ReadByteArray(&value)); ret.emplace_back(key, value); } return ret; @@ -183,7 +183,7 @@ absl::Status WireReaderImpl::ProcessTransaction(transaction_code_t code, } int version; - RETURN_IF_ERROR(parcel->ReadInt32(&version)); + RETURN_IF_NOT_OK(parcel->ReadInt32(&version)); gpr_log(GPR_DEBUG, "The other end respond with version = %d", version); // We only support this single lowest possible version, so server must // respond that version too. @@ -194,7 +194,7 @@ absl::Status WireReaderImpl::ProcessTransaction(transaction_code_t code, version, kWireFormatVersion); } std::unique_ptr binder{}; - RETURN_IF_ERROR(parcel->ReadBinder(&binder)); + RETURN_IF_NOT_OK(parcel->ReadBinder(&binder)); if (!binder) { return absl::InternalError("Read NULL binder from the parcel"); } @@ -210,7 +210,7 @@ absl::Status WireReaderImpl::ProcessTransaction(transaction_code_t code, } case BinderTransportTxCode::ACKNOWLEDGE_BYTES: { int64_t num_bytes = -1; - RETURN_IF_ERROR(parcel->ReadInt64(&num_bytes)); + RETURN_IF_NOT_OK(parcel->ReadInt64(&num_bytes)); gpr_log(GPR_DEBUG, "received acknowledge bytes = %" PRId64, num_bytes); wire_writer_->OnAckReceived(num_bytes); break; @@ -220,14 +220,14 @@ absl::Status WireReaderImpl::ProcessTransaction(transaction_code_t code, return absl::FailedPreconditionError("Receive PING request in client"); } int ping_id = -1; - RETURN_IF_ERROR(parcel->ReadInt32(&ping_id)); + RETURN_IF_NOT_OK(parcel->ReadInt32(&ping_id)); gpr_log(GPR_DEBUG, "received ping id = %d", ping_id); // TODO(waynetu): Ping back. break; } case BinderTransportTxCode::PING_RESPONSE: { int value = -1; - RETURN_IF_ERROR(parcel->ReadInt32(&value)); + RETURN_IF_NOT_OK(parcel->ReadInt32(&value)); gpr_log(GPR_DEBUG, "received ping response = %d", value); break; } @@ -303,7 +303,7 @@ absl::Status WireReaderImpl::ProcessStreamingTransactionImpl( gpr_log(GPR_INFO, "Total incoming bytes: %" PRId64, num_incoming_bytes_); int flags; - RETURN_IF_ERROR(parcel->ReadInt32(&flags)); + RETURN_IF_NOT_OK(parcel->ReadInt32(&flags)); *cancellation_flags = flags; // Ignore in-coming transaction with flag = 0 to match with Java @@ -322,7 +322,7 @@ absl::Status WireReaderImpl::ProcessStreamingTransactionImpl( gpr_log(GPR_DEBUG, "FLAG_MESSAGE_DATA = %d", (flags & kFlagMessageData)); gpr_log(GPR_DEBUG, "FLAG_SUFFIX = %d", (flags & kFlagSuffix)); int seq_num; - RETURN_IF_ERROR(parcel->ReadInt32(&seq_num)); + RETURN_IF_NOT_OK(parcel->ReadInt32(&seq_num)); // TODO(waynetu): For now we'll just assume that the transactions commit in // the same order they're issued. The following assertion detects // out-of-order or missing transactions. WireReaderImpl should be fixed if @@ -342,7 +342,7 @@ absl::Status WireReaderImpl::ProcessStreamingTransactionImpl( if (flags & kFlagPrefix) { std::string method_ref; if (!is_client_) { - RETURN_IF_ERROR(parcel->ReadString(&method_ref)); + RETURN_IF_NOT_OK(parcel->ReadString(&method_ref)); } absl::StatusOr initial_metadata_or_error = parse_metadata(parcel); if (!initial_metadata_or_error.ok()) { @@ -373,11 +373,11 @@ absl::Status WireReaderImpl::ProcessStreamingTransactionImpl( } if (flags & kFlagMessageData) { int count; - RETURN_IF_ERROR(parcel->ReadInt32(&count)); + RETURN_IF_NOT_OK(parcel->ReadInt32(&count)); gpr_log(GPR_DEBUG, "count = %d", count); std::string msg_data{}; if (count > 0) { - RETURN_IF_ERROR(parcel->ReadByteArray(&msg_data)); + RETURN_IF_NOT_OK(parcel->ReadByteArray(&msg_data)); } message_buffer_[code] += msg_data; if ((flags & kFlagMessageDataIsPartial) == 0) { @@ -391,7 +391,7 @@ absl::Status WireReaderImpl::ProcessStreamingTransactionImpl( if (flags & kFlagStatusDescription) { // FLAG_STATUS_DESCRIPTION set std::string desc; - RETURN_IF_ERROR(parcel->ReadString(&desc)); + RETURN_IF_NOT_OK(parcel->ReadString(&desc)); gpr_log(GPR_DEBUG, "description = %s", desc.c_str()); } Metadata trailing_metadata; diff --git a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc index 1c503c48cc7..786b5bc98d5 100644 --- a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +++ b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc @@ -113,17 +113,17 @@ absl::Status PrepareTcpClientSocket(PosixSocketWrapper sock, close(sock.Fd()); } }); - RETURN_IF_ERROR(sock.SetSocketNonBlocking(1)); - RETURN_IF_ERROR(sock.SetSocketCloexec(1)); + RETURN_IF_NOT_OK(sock.SetSocketNonBlocking(1)); + RETURN_IF_NOT_OK(sock.SetSocketCloexec(1)); if (reinterpret_cast(addr.address())->sa_family != AF_UNIX) { // If its not a unix socket address. - RETURN_IF_ERROR(sock.SetSocketLowLatency(1)); - RETURN_IF_ERROR(sock.SetSocketReuseAddr(1)); + RETURN_IF_NOT_OK(sock.SetSocketLowLatency(1)); + RETURN_IF_NOT_OK(sock.SetSocketReuseAddr(1)); sock.TrySetSocketTcpUserTimeout(options, true); } - RETURN_IF_ERROR(sock.SetSocketNoSigpipeIfPossible()); - RETURN_IF_ERROR(sock.ApplySocketMutatorInOptions( + RETURN_IF_NOT_OK(sock.SetSocketNoSigpipeIfPossible()); + RETURN_IF_NOT_OK(sock.ApplySocketMutatorInOptions( GRPC_FD_CLIENT_CONNECTION_USAGE, options)); // No errors. Set close_fd to false to ensure the socket is not closed. close_fd = false; diff --git a/src/core/lib/gprpp/status_helper.h b/src/core/lib/gprpp/status_helper.h index 7a880639721..923a41ae482 100644 --- a/src/core/lib/gprpp/status_helper.h +++ b/src/core/lib/gprpp/status_helper.h @@ -38,7 +38,7 @@ struct google_rpc_Status; struct upb_Arena; } -#define RETURN_IF_ERROR(expr) \ +#define RETURN_IF_NOT_OK(expr) \ do { \ const absl::Status status = (expr); \ if (!status.ok()) return status; \