svn commit: r238828 - head/sys/sys
Konstantin Belousov
kostikbel at gmail.com
Fri Jul 27 11:12:48 UTC 2012
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
>
> Log:
> Add assertion for refcount overflow.
>
> 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 != 0. This allows to avoid namespace
pollution due to limits.h.
>
> Modified:
> head/sys/sys/refcount.h
>
> Modified: head/sys/sys/refcount.h
> ==============================================================================
> --- 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__
>
> +#include <sys/limits.h>
> #include <machine/atomic.h>
>
> #ifdef _KERNEL
> @@ -51,6 +52,7 @@ static __inline void
> refcount_acquire(volatile u_int *count)
> {
>
> + KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count));
> atomic_add_acq_int(count, 1);
> }
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20120727/be454d49/attachment.pgp
More information about the svn-src-head
mailing list