Skip to content

Commit

Permalink
Merge pull request #1500 from AntelopeIO/greg_nodiscard
Browse files Browse the repository at this point in the history
Add some `[[nodiscard]]` attributes and remove unused type
  • Loading branch information
greg7mdp authored Aug 16, 2023
2 parents 2ce7b22 + ea25c90 commit 4b8fe6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion libraries/chain/include/eosio/chain/transaction_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace eosio { namespace chain {
>
>;

typedef chainbase::generic_index<transaction_multi_index> transaction_index;
} }

CHAINBASE_SET_INDEX_TYPE(eosio::chain::transaction_object, eosio::chain::transaction_multi_index)
Expand Down
12 changes: 6 additions & 6 deletions libraries/libfc/include/fc/mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ class SCOPED_CAPABILITY lock_guard {

public:
// Acquire mu, implicitly acquire *this and associate it with mu.
lock_guard(M& mu) ACQUIRE(mu)
[[nodiscard]] lock_guard(M& mu) ACQUIRE(mu)
: mut(mu) {
mu.lock();
}

// Assume mu is held, implicitly acquire *this and associate it with mu.
lock_guard(M& mu, adopt_lock_t) REQUIRES(mu)
[[nodiscard]] lock_guard(M& mu, adopt_lock_t) REQUIRES(mu)
: mut(mu) {}

~lock_guard() RELEASE() { mut.unlock(); }
Expand All @@ -150,24 +150,24 @@ class SCOPED_CAPABILITY unique_lock {
bool locked;

public:
unique_lock() noexcept
[[nodiscard]] unique_lock() noexcept
: mut(nullptr)
, locked(false) {}

// Acquire mu, implicitly acquire *this and associate it with mu.
explicit unique_lock(M& mu) ACQUIRE(mu)
[[nodiscard]] explicit unique_lock(M& mu) ACQUIRE(mu)
: mut(&mu)
, locked(true) {
mut->lock();
}

// Assume mu is held, implicitly acquire *this and associate it with mu.
unique_lock(M& mu, adopt_lock_t) REQUIRES(mu)
[[nodiscard]] unique_lock(M& mu, adopt_lock_t) REQUIRES(mu)
: mut(&mu)
, locked(true) {}

// Assume mu is not held, implicitly acquire *this and associate it with mu.
unique_lock(M& mu, defer_lock_t) EXCLUDES(mu)
[[nodiscard]] unique_lock(M& mu, defer_lock_t) EXCLUDES(mu)
: mut(mu)
, locked(false) {}

Expand Down
4 changes: 2 additions & 2 deletions libraries/libfc/include/fc/scoped_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace fc {
class scoped_exit {
public:
template<typename C>
scoped_exit( C&& c ):callback( std::forward<C>(c) ){}
[[nodiscard]] scoped_exit( C&& c ):callback( std::forward<C>(c) ){}

scoped_exit( scoped_exit&& mv )
[[nodiscard]] scoped_exit( scoped_exit&& mv )
:callback( std::move( mv.callback ) ),canceled(mv.canceled)
{
mv.canceled = true;
Expand Down

0 comments on commit 4b8fe6a

Please sign in to comment.