Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the code style by introducing macros #2521

Open
git-hulk opened this issue Sep 4, 2024 · 5 comments
Open

Improve the code style by introducing macros #2521

git-hulk opened this issue Sep 4, 2024 · 5 comments
Assignees

Comments

@git-hulk
Copy link
Member

git-hulk commented Sep 4, 2024

Followup code improvements mentioned in PR #2508. Currently, we check and return error if the status is not ok in many many places, which can be improved by introducing macros.

The naming candidates can be:

  • RETURN_NOT_OK
  • RETURN_IF_ERROR

and for converting the rocksdb status if there is an error:

  • RETURN_NOT_OK_FROM_ROCKSDB
  • RETURN_IF_ERR_FROM_ROCKSDB

Originally posted by @mapleFU in #2508 (review)

@git-hulk
Copy link
Member Author

git-hulk commented Sep 4, 2024

@AntiTopQuark Would you like to take this issue?

@AntiTopQuark
Copy link
Contributor

@AntiTopQuark Would you like to take this issue?

I’d be happy to take on this issue. :)

@PragmaTwice
Copy link
Member

The first macro is duplicated with the current GET_OR_RET macro.

@PragmaTwice
Copy link
Member

For the second I think it depends on the context, e.g. rocksdb::Status -> Status? rocksdb::Status -> rocksdb::Status?

We can extend GET_OR_RET for the latter, and the former doesn't require new macro.

@git-hulk
Copy link
Member Author

git-hulk commented Sep 7, 2024

For the second I think it depends on the context, e.g. rocksdb::Status -> Status? rocksdb::Status -> rocksdb::Status?

We can extend GET_OR_RET for the latter, and the former doesn't require new macro.

Yes, my bad. GET_OR_RET allows ignoring the return value, so the former one is unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants