Skip to content

refactor(macro): Use CHECK to replace dassert_f/dassert - #1205

Merged
empiredan merged 5 commits into
apache:masterfrom
acelyc111:dassert_to_CHECK
Oct 27, 2022
Merged

empiredan merged 5 commits into
apache:masterfrom
acelyc111:dassert_to_CHECK

Conversation

@acelyc111

@acelyc111 acelyc111 commented Oct 26, 2022 •

Copy link
Copy Markdown
Member

#1204

  • introduce CHECK
  • introduce CHECK_NOTNULL
  • use CHECK to replace part of dassert_f, which are used to check a single condition
  • use CHECK to replace part of dassert, which are used to check a single condition. And update to use fmt style

TODO: src/replica/mutation_log.cpp:970 should be fixed later

@github-actions github-actions Bot added the cpp label Oct 26, 2022
@acelyc111
acelyc111 marked this pull request as ready for review October 26, 2022 04:30
foreverneverer
foreverneverer previously approved these changes Oct 27, 2022
fetch_and_dequeue_messages(ready_responses, true);
for (dsn::message_ex *m : ready_responses) {
dassert(m != nullptr, "");
CHECK(m, "");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to user m != nullptr for pointer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are OK.
But in the future refactor, we are going to introduce CHECK_EQ and CHECK_NE, it's a bit of duplicate and strange if we judge the pointer like CHECK_NE(pointer, nullptr). I also consulted some other projects' habit, both styles are OK.

@acelyc111 acelyc111 Oct 27, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new macro CHECK_NOTNULL for pointers, similar to glog CHECK_NOTNULL

Comment thread src/block_service/fds/fds_service.cpp Resolved
Comment thread src/base/value_schema_manager.cpp Resolved
Comment thread src/common/replication_common.cpp Resolved
Comment thread src/common/replication_common.cpp Resolved
Comment thread src/geo/lib/geo_client.cpp Resolved
Comment thread src/shell/commands/debugger.cpp Resolved
Comment thread src/test/bench_test/benchmark.cpp Resolved
Comment thread src/test/bench_test/benchmark.cpp Resolved
Comment thread src/test/pressure_test/main.cpp Resolved
@empiredan
empiredan merged commit c20a88d into apache:master Oct 27, 2022
@empiredan empiredan mentioned this pull request Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants