Skip to content

Commit

Permalink
Merge pull request grpc#19683 from arjunroy/codegen_assert_fail
Browse files Browse the repository at this point in the history
Mark assert failure path as unlikely in codegen.
  • Loading branch information
arjunroy authored Jul 19, 2019
2 parents 1e607d3 + b47d22f commit 825a202
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/grpcpp/impl/codegen/callback_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ class CallbackWithSuccessTag
void* ignored = ops_;
// Allow a "false" return value from FinalizeResult to silence the
// callback, just as it silences a CQ tag in the async cases
#ifndef NDEBUG
auto* ops = ops_;
#endif
bool do_callback = ops_->FinalizeResult(&ignored, &ok);
GPR_CODEGEN_ASSERT(ignored == ops);
GPR_CODEGEN_DEBUG_ASSERT(ignored == ops);

if (do_callback) {
CatchingCallback(func_, ok);
Expand Down
2 changes: 1 addition & 1 deletion include/grpcpp/impl/codegen/core_codegen_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ extern CoreCodegenInterface* g_core_codegen_interface;
/// Codegen specific version of \a GPR_ASSERT.
#define GPR_CODEGEN_ASSERT(x) \
do { \
if (!(x)) { \
if (GPR_UNLIKELY(!(x))) { \
grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \
} \
} while (0)
Expand Down

0 comments on commit 825a202

Please sign in to comment.