From a6c459dd2907be6479a89368c0f957da06e5c1ec Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 3 Jan 2021 16:41:49 -0700 Subject: [PATCH] AK: Decorate RefCountedBase::try_ref with nodiscard Because try_ref only increments the ref count if it returned true, it is important that any caller properly acts upon the return value. --- AK/RefCounted.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/RefCounted.h b/AK/RefCounted.h index 17d6330f00..29eb554285 100644 --- a/AK/RefCounted.h +++ b/AK/RefCounted.h @@ -74,7 +74,7 @@ public: ASSERT(!Checked::addition_would_overflow(old_ref_count, 1)); } - ALWAYS_INLINE bool try_ref() const + [[nodiscard]] ALWAYS_INLINE bool try_ref() const { RefCountType expected = m_ref_count.load(AK::MemoryOrder::memory_order_relaxed); for (;;) {