Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jul 2012 14:12:37 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r238828 - head/sys/sys
Message-ID:  <20120727111237.GC2676@deviant.kiev.zoral.com.ua>
In-Reply-To: <201207270916.q6R9Gm23086648@svn.freebsd.org>
References:  <201207270916.q6R9Gm23086648@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--yx93Kc6BzsIU1RZq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 27, 2012 at 09:16:48AM +0000, Gleb Smirnoff wrote:
> Author: glebius
> Date: Fri Jul 27 09:16:48 2012
> New Revision: 238828
> URL: http://svn.freebsd.org/changeset/base/238828
>=20
> Log:
>   Add assertion for refcount overflow.
>  =20
>   Submitted by:	Andrey Zonov <andrey zonov.org>
>   Reviewed by:	kib
It was discussed rather then reviewed.

I suggest that the assert may be expressed as a check after the increment,
which verifies that counter is !=3D 0. This allows to avoid namespace
pollution due to limits.h.

>=20
> Modified:
>   head/sys/sys/refcount.h
>=20
> Modified: head/sys/sys/refcount.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/sys/refcount.h	Fri Jul 27 08:28:44 2012	(r238827)
> +++ head/sys/sys/refcount.h	Fri Jul 27 09:16:48 2012	(r238828)
> @@ -32,6 +32,7 @@
>  #ifndef __SYS_REFCOUNT_H__
>  #define __SYS_REFCOUNT_H__
> =20
> +#include <sys/limits.h>
>  #include <machine/atomic.h>
> =20
>  #ifdef _KERNEL
> @@ -51,6 +52,7 @@ static __inline void
>  refcount_acquire(volatile u_int *count)
>  {
> =20
> +	KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count));
>  	atomic_add_acq_int(count, 1);=09
>  }
> =20

--yx93Kc6BzsIU1RZq
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAlASd6UACgkQC3+MBN1Mb4j1ywCg4F5Qe2TLuK3WR4fhxIcMSNF1
eW8AnimtZVUxhTV2VQueX0rto3E5D8aI
=fOjQ
-----END PGP SIGNATURE-----

--yx93Kc6BzsIU1RZq--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120727111237.GC2676>