[build] Make GRPC_MUST_USE_RESULT default backed by nodiscard (#33742)

Going forward `[[nodiscard]]` is the portable way to spell this;
requires yanking a bunch of usage from after the param list to before.

We should further refine the GRPC_MUST_USE_RESULT macro to make it work
uniformly for any compilers that it doesn't today (most likely by making
it expand to nothing).

---------

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/33747/head
Craig Tiller 1 year ago committed by GitHub
parent 6ad141ae8c
commit 76bd606bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 52
      include/grpc/support/port_platform.h
  2. 2
      include/grpcpp/ext/gcp_observability.h
  3. 12
      include/grpcpp/impl/call_op_set.h
  4. 6
      src/core/ext/filters/client_channel/dynamic_filters.h
  5. 6
      src/core/ext/filters/client_channel/subchannel.h
  6. 7
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  7. 2
      src/core/ext/transport/chttp2/transport/hpack_parser_table.h
  8. 4
      src/core/lib/address_utils/sockaddr_utils.h
  9. 20
      src/core/lib/channel/channel_args.cc
  10. 2
      src/core/lib/event_engine/posix_engine/timer.h
  11. 18
      src/core/lib/gprpp/dual_ref_counted.h
  12. 6
      src/core/lib/gprpp/orphanable.h
  13. 12
      src/core/lib/gprpp/ref_counted.h
  14. 31
      src/core/lib/gprpp/status_helper.h
  15. 15
      src/core/lib/http/httpcli.h
  16. 19
      src/core/lib/iomgr/error.h
  17. 2
      src/core/lib/iomgr/ev_poll_posix.cc
  18. 9
      src/core/lib/iomgr/pollset.h
  19. 9
      src/core/lib/iomgr/wakeup_fd_posix.h
  20. 2
      src/core/lib/promise/party.h
  21. 2
      src/core/lib/resource_quota/memory_quota.h
  22. 4
      src/core/lib/surface/server.h

@ -563,29 +563,6 @@ typedef unsigned __int64 uint64_t;
#define GRPC_IF_NAMETOINDEX 1
#endif
#ifndef GRPC_MUST_USE_RESULT
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
#define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
#else
#define GRPC_MUST_USE_RESULT
#define GPR_ALIGN_STRUCT(n)
#endif
#ifdef USE_STRICT_WARNING
/* When building with USE_STRICT_WARNING (which -Werror), types with this
attribute will be treated as annotated with warn_unused_result, enforcing
returned values of this type should be used.
This is added in grpc::Status in mind to address the issue where it always
has this annotation internally but OSS doesn't, sometimes causing internal
build failure. To prevent this, this is added while not introducing
a breaking change to existing user code which may not use returned values
of grpc::Status. */
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPC_MUST_USE_RESULT
#else
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING
#endif
#endif
#ifndef GRPC_UNUSED
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_UNUSED __attribute__((unused))
@ -611,6 +588,35 @@ typedef unsigned __int64 uint64_t;
#endif
#endif /* GPR_HAS_CPP_ATTRIBUTE */
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
#else
#define GPR_ALIGN_STRUCT(n)
#endif
#ifndef GRPC_MUST_USE_RESULT
#if GPR_HAS_CPP_ATTRIBUTE(nodiscard)
#define GRPC_MUST_USE_RESULT [[nodiscard]]
#elif defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
#else
#define GRPC_MUST_USE_RESULT
#endif
#ifdef USE_STRICT_WARNING
/* When building with USE_STRICT_WARNING (which -Werror), types with this
attribute will be treated as annotated with warn_unused_result, enforcing
returned values of this type should be used.
This is added in grpc::Status in mind to address the issue where it always
has this annotation internally but OSS doesn't, sometimes causing internal
build failure. To prevent this, this is added while not introducing
a breaking change to existing user code which may not use returned values
of grpc::Status. */
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPC_MUST_USE_RESULT
#else
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING
#endif
#endif
#ifndef GPR_HAS_ATTRIBUTE
#ifdef __has_attribute
#define GPR_HAS_ATTRIBUTE(a) __has_attribute(a)

@ -67,7 +67,7 @@ class GcpObservability {
// As an implementation detail, this properly initializes the OpenCensus stats
// and tracing plugin, so applications do not need to perform any additional
// gRPC C++ OpenCensus setup/registration to get GCP Observability for gRPC.
static absl::StatusOr<GcpObservability> Init() GRPC_MUST_USE_RESULT;
static absl::StatusOr<GcpObservability> Init();
GcpObservability() = default;
// Move constructor and Move-assignment operator.

@ -290,23 +290,23 @@ class CallOpSendMessage {
/// Send \a message using \a options for the write. The \a options are cleared
/// after use.
template <class M>
Status SendMessage(const M& message,
WriteOptions options) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessage(const M& message,
WriteOptions options);
template <class M>
Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessage(const M& message);
/// Send \a message using \a options for the write. The \a options are cleared
/// after use. This form of SendMessage allows gRPC to reference \a message
/// beyond the lifetime of SendMessage.
template <class M>
Status SendMessagePtr(const M* message,
WriteOptions options) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message,
WriteOptions options);
/// This form of SendMessage allows gRPC to reference \a message beyond the
/// lifetime of SendMessage.
template <class M>
Status SendMessagePtr(const M* message) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message);
protected:
void AddOp(grpc_op* ops, size_t* nops) {

@ -68,9 +68,9 @@ class DynamicFilters : public RefCounted<DynamicFilters> {
void SetAfterCallStackDestroy(grpc_closure* closure);
// Interface of RefCounted<>.
RefCountedPtr<Call> Ref() GRPC_MUST_USE_RESULT;
RefCountedPtr<Call> Ref(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT RefCountedPtr<Call> Ref();
GRPC_MUST_USE_RESULT RefCountedPtr<Call> Ref(const DebugLocation& location,
const char* reason);
// When refcount drops to 0, destroys itself and the associated call stack,
// but does NOT free the memory because it's in the call arena.
void Unref();

@ -119,9 +119,9 @@ class SubchannelCall {
void SetAfterCallStackDestroy(grpc_closure* closure);
// Interface of RefCounted<>.
RefCountedPtr<SubchannelCall> Ref() GRPC_MUST_USE_RESULT;
RefCountedPtr<SubchannelCall> Ref(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT RefCountedPtr<SubchannelCall> Ref();
GRPC_MUST_USE_RESULT RefCountedPtr<SubchannelCall> Ref(
const DebugLocation& location, const char* reason);
// When refcount drops to 0, destroys itself and the associated call stack,
// but does NOT free the memory because it's in the call arena.
void Unref();

@ -246,13 +246,12 @@ class Chttp2ServerListener : public Server::ListenerInterface {
IncrementRefCount();
}
RefCountedPtr<Chttp2ServerListener> Ref() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Chttp2ServerListener> Ref() {
IncrementRefCount();
return RefCountedPtr<Chttp2ServerListener>(this);
}
RefCountedPtr<Chttp2ServerListener> Ref(const DebugLocation& /* location */,
const char* /* reason */)
GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Chttp2ServerListener> Ref(
const DebugLocation& /* location */, const char* /* reason */) {
return Ref();
}

@ -71,7 +71,7 @@ class HPackTable {
}
// add a table entry to the index
bool Add(Memento md) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT bool Add(Memento md);
void AddLargerThanCurrentTableSize();
// Current entry count in the table.

@ -67,8 +67,8 @@ int grpc_sockaddr_set_port(grpc_resolved_address* addr, int port);
// Currently, only the AF_INET, AF_INET6, and AF_UNIX families are recognized.
// If the normalize flag is enabled, ::ffff:0.0.0.0/96 IPv6 addresses are
// displayed as plain IPv4.
absl::StatusOr<std::string> grpc_sockaddr_to_string(
const grpc_resolved_address* addr, bool normalize) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT absl::StatusOr<std::string> grpc_sockaddr_to_string(
const grpc_resolved_address* addr, bool normalize);
// Returns the URI string corresponding to \a addr
absl::StatusOr<std::string> grpc_sockaddr_to_uri(

@ -189,25 +189,25 @@ ChannelArgs ChannelArgs::Set(absl::string_view name, int value) const {
return Set(name, Value(value));
}
ChannelArgs ChannelArgs::Set(absl::string_view key, Value value) const {
return ChannelArgs(args_.Add(std::string(key), std::move(value)));
ChannelArgs ChannelArgs::Set(absl::string_view name, Value value) const {
return ChannelArgs(args_.Add(std::string(name), std::move(value)));
}
ChannelArgs ChannelArgs::Set(absl::string_view key,
ChannelArgs ChannelArgs::Set(absl::string_view name,
absl::string_view value) const {
return Set(key, std::string(value));
return Set(name, std::string(value));
}
ChannelArgs ChannelArgs::Set(absl::string_view key, const char* value) const {
return Set(key, std::string(value));
ChannelArgs ChannelArgs::Set(absl::string_view name, const char* value) const {
return Set(name, std::string(value));
}
ChannelArgs ChannelArgs::Set(absl::string_view key, std::string value) const {
return Set(key, Value(std::move(value)));
ChannelArgs ChannelArgs::Set(absl::string_view name, std::string value) const {
return Set(name, Value(std::move(value)));
}
ChannelArgs ChannelArgs::Remove(absl::string_view key) const {
return ChannelArgs(args_.Remove(key));
ChannelArgs ChannelArgs::Remove(absl::string_view name) const {
return ChannelArgs(args_.Remove(name));
}
ChannelArgs ChannelArgs::RemoveAllKeysWithPrefix(

@ -89,7 +89,7 @@ class TimerList {
// timer has already fired, or if its closure is currently running. The
// closure is guaranteed to run eventually if this method returns false.
// Otherwise, this returns true, and the closure will not be run.
bool TimerCancel(Timer* timer) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT bool TimerCancel(Timer* timer);
// Check for timers to be run, and return them.
// Return nullopt if timers could not be checked due to contention with

@ -49,13 +49,13 @@ class DualRefCounted : public Orphanable {
public:
~DualRefCounted() override = default;
RefCountedPtr<Child> Ref() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> Ref() {
IncrementRefCount();
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
RefCountedPtr<Child> Ref(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> Ref(const DebugLocation& location,
const char* reason) {
IncrementRefCount(location, reason);
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
@ -103,7 +103,7 @@ class DualRefCounted : public Orphanable {
WeakUnref(location, reason);
}
RefCountedPtr<Child> RefIfNonZero() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> RefIfNonZero() {
uint64_t prev_ref_pair = refs_.load(std::memory_order_acquire);
do {
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
@ -121,8 +121,8 @@ class DualRefCounted : public Orphanable {
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
RefCountedPtr<Child> RefIfNonZero(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> RefIfNonZero(
const DebugLocation& location, const char* reason) {
uint64_t prev_ref_pair = refs_.load(std::memory_order_acquire);
do {
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
@ -146,13 +146,13 @@ class DualRefCounted : public Orphanable {
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
WeakRefCountedPtr<Child> WeakRef() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT WeakRefCountedPtr<Child> WeakRef() {
IncrementWeakRefCount();
return WeakRefCountedPtr<Child>(static_cast<Child*>(this));
}
WeakRefCountedPtr<Child> WeakRef(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT WeakRefCountedPtr<Child> WeakRef(
const DebugLocation& location, const char* reason) {
IncrementWeakRefCount(location, reason);
return WeakRefCountedPtr<Child>(static_cast<Child*>(this));
}

@ -87,12 +87,12 @@ class InternallyRefCounted : public Orphanable {
: refs_(initial_refcount, trace) {}
~InternallyRefCounted() override = default;
RefCountedPtr<Child> Ref() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> Ref() {
IncrementRefCount();
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
RefCountedPtr<Child> Ref(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> Ref(const DebugLocation& location,
const char* reason) {
IncrementRefCount(location, reason);
return RefCountedPtr<Child>(static_cast<Child*>(this));
}

@ -277,13 +277,13 @@ class RefCounted : public Impl {
// Note: Depending on the Impl used, this dtor can be implicitly virtual.
~RefCounted() = default;
RefCountedPtr<Child> Ref() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> Ref() {
IncrementRefCount();
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
RefCountedPtr<Child> Ref(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> Ref(const DebugLocation& location,
const char* reason) {
IncrementRefCount(location, reason);
return RefCountedPtr<Child>(static_cast<Child*>(this));
}
@ -303,12 +303,12 @@ class RefCounted : public Impl {
}
}
RefCountedPtr<Child> RefIfNonZero() GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> RefIfNonZero() {
return RefCountedPtr<Child>(refs_.RefIfNonZero() ? static_cast<Child*>(this)
: nullptr);
}
RefCountedPtr<Child> RefIfNonZero(const DebugLocation& location,
const char* reason) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT RefCountedPtr<Child> RefIfNonZero(
const DebugLocation& location, const char* reason) {
return RefCountedPtr<Child>(refs_.RefIfNonZero(location, reason)
? static_cast<Child*>(this)
: nullptr);

@ -116,57 +116,58 @@ enum class StatusTimeProperty {
};
/// Creates a status with given additional information
absl::Status StatusCreate(
absl::StatusCode code, absl::string_view msg, const DebugLocation& location,
std::vector<absl::Status> children) GRPC_MUST_USE_RESULT;
absl::Status StatusCreate(absl::StatusCode code, absl::string_view msg,
const DebugLocation& location,
std::vector<absl::Status> children);
/// Sets the int property to the status
void StatusSetInt(absl::Status* status, StatusIntProperty key, intptr_t value);
/// Gets the int property from the status
absl::optional<intptr_t> StatusGetInt(
const absl::Status& status, StatusIntProperty key) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT
absl::optional<intptr_t> StatusGetInt(const absl::Status& status,
StatusIntProperty key);
/// Sets the str property to the status
void StatusSetStr(absl::Status* status, StatusStrProperty key,
absl::string_view value);
/// Gets the str property from the status
absl::optional<std::string> StatusGetStr(
const absl::Status& status, StatusStrProperty key) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT absl::optional<std::string> StatusGetStr(
const absl::Status& status, StatusStrProperty key);
/// Sets the time property to the status
void StatusSetTime(absl::Status* status, StatusTimeProperty key,
absl::Time time);
/// Gets the time property from the status
absl::optional<absl::Time> StatusGetTime(
const absl::Status& status, StatusTimeProperty key) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT absl::optional<absl::Time> StatusGetTime(
const absl::Status& status, StatusTimeProperty key);
/// Adds a child status to status
void StatusAddChild(absl::Status* status, absl::Status child);
/// Returns all children status from a status
std::vector<absl::Status> StatusGetChildren(absl::Status status)
GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT std::vector<absl::Status> StatusGetChildren(
absl::Status status);
/// Returns a string representation from status
/// Error status will be like
/// STATUS[:MESSAGE] [{PAYLOADS[, children:[CHILDREN-STATUS-LISTS]]}]
/// e.g.
/// CANCELLATION:SampleMessage {errno:'2021', line:'54', children:[ABORTED]}
std::string StatusToString(const absl::Status& status) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT std::string StatusToString(const absl::Status& status);
namespace internal {
/// Builds a upb message, google_rpc_Status from a status
/// This is for internal implementation & test only
google_rpc_Status* StatusToProto(const absl::Status& status,
upb_Arena* arena) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT google_rpc_Status* StatusToProto(
const absl::Status& status, upb_Arena* arena);
/// Builds a status from a upb message, google_rpc_Status
/// This is for internal implementation & test only
absl::Status StatusFromProto(google_rpc_Status* msg) GRPC_MUST_USE_RESULT;
absl::Status StatusFromProto(google_rpc_Status* msg);
/// Returns ptr that is allocated in the heap memory and the given status is
/// copied into. This ptr can be used to get Status later and should be

@ -100,12 +100,11 @@ class HttpRequest : public InternallyRefCounted<HttpRequest> {
// nullptr is treated as insecure credentials.
// TODO(yihuaz): disallow nullptr as a value after unsecure builds
// are removed.
static OrphanablePtr<HttpRequest> Get(
GRPC_MUST_USE_RESULT static OrphanablePtr<HttpRequest> Get(
URI uri, const grpc_channel_args* args, grpc_polling_entity* pollent,
const grpc_http_request* request, Timestamp deadline,
grpc_closure* on_done, grpc_http_response* response,
RefCountedPtr<grpc_channel_credentials> channel_creds)
GRPC_MUST_USE_RESULT;
RefCountedPtr<grpc_channel_credentials> channel_creds);
// Asynchronously perform a HTTP POST.
// 'uri' is the target to make the request to. The scheme field is used to
@ -126,12 +125,11 @@ class HttpRequest : public InternallyRefCounted<HttpRequest> {
// TODO(apolcyn): disallow nullptr as a value after unsecure builds
// are removed.
// Does not support ?var1=val1&var2=val2 in the path.
static OrphanablePtr<HttpRequest> Post(
GRPC_MUST_USE_RESULT static OrphanablePtr<HttpRequest> Post(
URI uri, const grpc_channel_args* args, grpc_polling_entity* pollent,
const grpc_http_request* request, Timestamp deadline,
grpc_closure* on_done, grpc_http_response* response,
RefCountedPtr<grpc_channel_credentials> channel_creds)
GRPC_MUST_USE_RESULT;
RefCountedPtr<grpc_channel_credentials> channel_creds);
// Asynchronously perform a HTTP PUT.
// 'uri' is the target to make the request to. The scheme field is used to
@ -152,12 +150,11 @@ class HttpRequest : public InternallyRefCounted<HttpRequest> {
// TODO(apolcyn): disallow nullptr as a value after unsecure builds
// are removed.
// Does not support ?var1=val1&var2=val2 in the path.
static OrphanablePtr<HttpRequest> Put(
GRPC_MUST_USE_RESULT static OrphanablePtr<HttpRequest> Put(
URI uri, const grpc_channel_args* args, grpc_polling_entity* pollent,
const grpc_http_request* request, Timestamp deadline,
grpc_closure* on_done, grpc_http_response* response,
RefCountedPtr<grpc_channel_credentials> channel_creds)
GRPC_MUST_USE_RESULT;
RefCountedPtr<grpc_channel_credentials> channel_creds);
HttpRequest(URI uri, const grpc_slice& request_text,
grpc_http_response* response, Timestamp deadline,

@ -46,8 +46,7 @@ typedef absl::Status grpc_error_handle;
absl::Status grpc_status_create(absl::StatusCode code, absl::string_view msg,
const grpc_core::DebugLocation& location,
size_t children_count,
absl::Status* children) GRPC_MUST_USE_RESULT;
size_t children_count, absl::Status* children);
// Create an error that references some other errors.
#define GRPC_ERROR_CREATE_REFERENCING(desc, errs, count) \
@ -73,7 +72,7 @@ static absl::Status grpc_status_create_from_vector(
grpc_status_create_from_vector(DEBUG_LOCATION, desc, error_list)
absl::Status grpc_os_error(const grpc_core::DebugLocation& location, int err,
const char* call_name) GRPC_MUST_USE_RESULT;
const char* call_name);
inline absl::Status grpc_assert_never_ok(absl::Status error) {
GPR_ASSERT(!error.ok());
@ -85,7 +84,7 @@ inline absl::Status grpc_assert_never_ok(absl::Status error) {
grpc_assert_never_ok(grpc_os_error(DEBUG_LOCATION, err, call_name))
absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
absl::string_view call_name) GRPC_MUST_USE_RESULT;
absl::string_view call_name);
/// windows only: create an error associated with WSAGetLastError()!=0
#define GRPC_WSA_ERROR(err, call_name) \
@ -93,14 +92,14 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
grpc_error_handle grpc_error_set_int(grpc_error_handle src,
grpc_core::StatusIntProperty which,
intptr_t value) GRPC_MUST_USE_RESULT;
intptr_t value);
/// It is an error to pass nullptr as `p`. Caller should allocate a phony
/// intptr_t for `p`, even if the value of `p` is not used.
bool grpc_error_get_int(grpc_error_handle error,
grpc_core::StatusIntProperty which, intptr_t* p);
grpc_error_handle grpc_error_set_str(
grpc_error_handle src, grpc_core::StatusStrProperty which,
absl::string_view str) GRPC_MUST_USE_RESULT;
grpc_error_handle grpc_error_set_str(grpc_error_handle src,
grpc_core::StatusStrProperty which,
absl::string_view str);
/// Returns false if the specified string is not set.
bool grpc_error_get_str(grpc_error_handle error,
grpc_core::StatusStrProperty which, std::string* str);
@ -116,8 +115,8 @@ bool grpc_error_get_str(grpc_error_handle error,
/// returns absl::OkStatus(). 3) If \a src and \a child point to the same error,
/// returns a single reference. (Note that, 2 references should have been
/// received to the error in this case.)
grpc_error_handle grpc_error_add_child(
grpc_error_handle src, grpc_error_handle child) GRPC_MUST_USE_RESULT;
grpc_error_handle grpc_error_add_child(grpc_error_handle src,
grpc_error_handle child);
bool grpc_log_error(const char* what, grpc_error_handle error, const char* file,
int line);

@ -235,7 +235,7 @@ static int poll_deadline_to_millis_timeout(grpc_core::Timestamp deadline);
// -- mostly for fd_posix's use.
static grpc_error_handle pollset_kick_ext(grpc_pollset* p,
grpc_pollset_worker* specific_worker,
uint32_t flags) GRPC_MUST_USE_RESULT;
uint32_t flags);
// Return 1 if the pollset has active threads in pollset_work (pollset must
// be locked)

@ -86,14 +86,13 @@ void grpc_pollset_destroy(grpc_pollset* pollset);
// May call grpc_closure_list_run on grpc_closure_list, without holding the
// pollset
// lock
grpc_error_handle grpc_pollset_work(
grpc_pollset* pollset, grpc_pollset_worker** worker,
grpc_core::Timestamp deadline) GRPC_MUST_USE_RESULT;
grpc_error_handle grpc_pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker,
grpc_core::Timestamp deadline);
// Break one polling thread out of polling work for this pollset.
// If specific_worker is non-NULL, then kick that worker.
grpc_error_handle grpc_pollset_kick(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker)
GRPC_MUST_USE_RESULT;
grpc_pollset_worker* specific_worker);
#endif // GRPC_SRC_CORE_LIB_IOMGR_POLLSET_H

@ -81,12 +81,9 @@ extern int grpc_allow_pipe_wakeup_fd;
#define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd)
grpc_error_handle grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info)
GRPC_MUST_USE_RESULT;
grpc_error_handle grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info)
GRPC_MUST_USE_RESULT;
grpc_error_handle grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info)
GRPC_MUST_USE_RESULT;
grpc_error_handle grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info);
grpc_error_handle grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info);
grpc_error_handle grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info);
void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info);
// Defined in some specialized implementation's .c file, or by

@ -384,7 +384,7 @@ class Party : public Activity, private Wakeable {
// Should not be called by derived types except as a tail call to the base
// class RunParty when overriding this method to add custom context.
// Returns true if the party is over.
virtual bool RunParty() GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT virtual bool RunParty();
bool RefIfNonZero() { return sync_.RefIfNonZero(); }

@ -459,7 +459,7 @@ class GrpcMemoryAllocatorImpl final : public EventEngineMemoryAllocatorImpl {
static constexpr size_t kMaxQuotaBufferSize = 1024 * 1024;
// Primitive reservation function.
absl::optional<size_t> TryReserve(MemoryRequest request) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT absl::optional<size_t> TryReserve(MemoryRequest request);
// This function may be invoked during a memory release operation.
// It will try to return half of our free pool to the quota.
void MaybeDonateBack();

@ -420,8 +420,8 @@ class Server : public InternallyRefCounted<Server>,
}
// Returns a notification pointer to wait on if there are requests in-flight,
// or null.
Notification* ShutdownUnrefOnShutdownCall()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_global_) GRPC_MUST_USE_RESULT {
GRPC_MUST_USE_RESULT Notification* ShutdownUnrefOnShutdownCall()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_global_) {
if (shutdown_refs_.fetch_sub(1, std::memory_order_acq_rel) == 1) {
// There is no request in-flight.
MaybeFinishShutdown();

Loading…
Cancel
Save