You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/12/18 05:32:28 UTC
[GitHub] [incubator-kvrocks] PragmaTwice opened a new pull request, #1193: Add nodiscard attribute to Status and StatusOr
PragmaTwice opened a new pull request, #1193:
URL: https://github.com/apache/incubator-kvrocks/pull/1193
We make Status and StatusOr `[[nodiscard]]` in this PR, which means, you will get a compile warning if you do not handle the return value of a call to a function that returns Status or StatusOr, e.g.
```c++
Status DoSomething(int x);
DoSomething(0); // warning: cannot discard the return value;
GET_OR_RET(DoSomething(0)); // fine if the current context is in a function that returns Status
if(auto s = DoSomething(0); !s.IsOK()) return s; // fine, same as above
if(auto s = DoSomething(0); !s.IsOK()) LOG(ERROR) << "got error: " << s.Msg(); // fine
auto s [[maybe_unused]] = DoSomething(0); // fine if you really want to discard the error (can explain in code review)
```
We will eventually make it a compiler error instead of a warning.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-kvrocks] PragmaTwice merged pull request #1193: Add nodiscard attribute to Status and StatusOr
Posted by GitBox <gi...@apache.org>.
PragmaTwice merged PR #1193:
URL: https://github.com/apache/incubator-kvrocks/pull/1193
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org