lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211118035328.5730-1-yajun.deng@linux.dev>
Date:   Thu, 18 Nov 2021 11:53:28 +0800
From:   Yajun Deng <yajun.deng@...ux.dev>
To:     will@...nel.org, peterz@...radead.org, boqun.feng@...il.com
Cc:     linux-kernel@...r.kernel.org, Yajun Deng <yajun.deng@...ux.dev>
Subject: [PATCH] refcount: introduce refcount_is_one() helper function

There are many cases where it is necessary to determine if refcount is one,
introduce refcount_is_one() helper function for these cases.

Signed-off-by: Yajun Deng <yajun.deng@...ux.dev>
---
 include/linux/refcount.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/refcount.h b/include/linux/refcount.h
index b8a6e387f8f9..1cc23c0e7454 100644
--- a/include/linux/refcount.h
+++ b/include/linux/refcount.h
@@ -147,6 +147,11 @@ static inline unsigned int refcount_read(const refcount_t *r)
 	return atomic_read(&r->refs);
 }
 
+static inline bool refcount_is_one(const refcount_t *r)
+{
+	return refcount_read(r) == 1;
+}
+
 static inline __must_check bool __refcount_add_not_zero(int i, refcount_t *r, int *oldp)
 {
 	int old = refcount_read(r);
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ