From owner-svn-src-all@freebsd.org  Sun Jul 21 20:16:49 2019
Return-Path: <owner-svn-src-all@freebsd.org>
Delivered-To: svn-src-all@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id D175ABC77A;
 Sun, 21 Jul 2019 20:16:49 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id B4A3E8E8E5;
 Sun, 21 Jul 2019 20:16:49 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 90F21BB1;
 Sun, 21 Jul 2019 20:16:49 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6LKGnF7036433;
 Sun, 21 Jul 2019 20:16:49 GMT (envelope-from kib@FreeBSD.org)
Received: (from kib@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6LKGnjH036431;
 Sun, 21 Jul 2019 20:16:49 GMT (envelope-from kib@FreeBSD.org)
Message-Id: <201907212016.x6LKGnjH036431@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org
 using -f
From: Konstantin Belousov <kib@FreeBSD.org>
Date: Sun, 21 Jul 2019 20:16:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r350204 - in head: share/man/man9 sys/sys
X-SVN-Group: head
X-SVN-Commit-Author: kib
X-SVN-Commit-Paths: in head: share/man/man9 sys/sys
X-SVN-Commit-Revision: 350204
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Rspamd-Queue-Id: B4A3E8E8E5
X-Spamd-Bar: --
Authentication-Results: mx1.freebsd.org
X-Spamd-Result: default: False [-2.96 / 15.00];
 local_wl_from(0.00)[FreeBSD.org];
 NEURAL_HAM_MEDIUM(-1.00)[-1.000,0];
 NEURAL_HAM_LONG(-1.00)[-1.000,0];
 NEURAL_HAM_SHORT(-0.96)[-0.960,0];
 ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 21 Jul 2019 20:16:49 -0000

Author: kib
Date: Sun Jul 21 20:16:48 2019
New Revision: 350204
URL: https://svnweb.freebsd.org/changeset/base/350204

Log:
  Switch the rest of the refcount(9) functions to bool return type.
  
  There are some explicit comparisions of refcount_release(9) result
  with 0/1, which are fine.
  
  Reviewed by:	markj, mjg
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D21014

Modified:
  head/share/man/man9/refcount.9
  head/sys/sys/refcount.h

Modified: head/share/man/man9/refcount.9
==============================================================================
--- head/share/man/man9/refcount.9	Sun Jul 21 17:14:39 2019	(r350203)
+++ head/share/man/man9/refcount.9	Sun Jul 21 20:16:48 2019	(r350204)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 20, 2009
+.Dd July 21, 2019
 .Dt REFCOUNT 9
 .Os
 .Sh NAME
@@ -42,7 +42,7 @@
 .Fn refcount_init "volatile u_int *count" "u_int value"
 .Ft void
 .Fn refcount_acquire "volatile u_int *count"
-.Ft int
+.Ft bool
 .Fn refcount_release "volatile u_int *count"
 .Sh DESCRIPTION
 The
@@ -73,9 +73,9 @@ protection for acquiring a new reference.
 The
 .Fn refcount_release
 function is used to release an existing reference.
-The function returns a non-zero value if the reference being released was
+The function returns true if the reference being released was
 the last reference;
-otherwise, it returns zero.
+otherwise, it returns false.
 .Pp
 Note that these routines do not provide any inter-CPU synchronization,
 data protection,
@@ -89,7 +89,7 @@ is released.
 .Sh RETURN VALUES
 The
 .Nm refcount_release
-function returns non-zero when releasing the last reference and zero when
+function returns true when releasing the last reference and false when
 releasing any other reference.
 .Sh HISTORY
 These functions were introduced in

Modified: head/sys/sys/refcount.h
==============================================================================
--- head/sys/sys/refcount.h	Sun Jul 21 17:14:39 2019	(r350203)
+++ head/sys/sys/refcount.h	Sun Jul 21 20:16:48 2019	(r350204)
@@ -69,7 +69,7 @@ refcount_acquire_checked(volatile u_int *count)
 	}
 }
 
-static __inline int
+static __inline bool
 refcount_release(volatile u_int *count)
 {
 	u_int old;
@@ -78,7 +78,7 @@ refcount_release(volatile u_int *count)
 	old = atomic_fetchadd_int(count, -1);
 	KASSERT(old > 0, ("refcount %p is zero", count));
 	if (old > 1)
-		return (0);
+		return (false);
 
 	/*
 	 * Last reference.  Signal the user to call the destructor.
@@ -87,14 +87,14 @@ refcount_release(volatile u_int *count)
 	 * at the start of the function synchronized with this fence.
 	 */
 	atomic_thread_fence_acq();
-	return (1);
+	return (true);
 }
 
 /*
  * This functions returns non-zero if the refcount was
  * incremented. Else zero is returned.
  */
-static __inline __result_use_check int
+static __inline __result_use_check bool
 refcount_acquire_if_not_zero(volatile u_int *count)
 {
 	u_int old;
@@ -103,13 +103,13 @@ refcount_acquire_if_not_zero(volatile u_int *count)
 	for (;;) {
 		KASSERT(old < UINT_MAX, ("refcount %p overflowed", count));
 		if (old == 0)
-			return (0);
+			return (false);
 		if (atomic_fcmpset_int(count, &old, old + 1))
-			return (1);
+			return (true);
 	}
 }
 
-static __inline __result_use_check int
+static __inline __result_use_check bool
 refcount_release_if_not_last(volatile u_int *count)
 {
 	u_int old;
@@ -118,9 +118,9 @@ refcount_release_if_not_last(volatile u_int *count)
 	for (;;) {
 		KASSERT(old > 0, ("refcount %p is zero", count));
 		if (old == 1)
-			return (0);
+			return (false);
 		if (atomic_fcmpset_int(count, &old, old - 1))
-			return (1);
+			return (true);
 	}
 }