Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Sep 2010 15:31:53 -0700
From:      mdf@FreeBSD.org
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, pluknet <pluknet@gmail.com>, src-committers@freebsd.org
Subject:   Re: svn commit: r212182 - head/sys/kern
Message-ID:  <AANLkTi=txseBeUoZPkqKPEehtnkFzMNZ13vznu0oP9WT@mail.gmail.com>
In-Reply-To: <20100906234057.O954@delplex.bde.org>
References:  <201009031723.o83HNR7k056625@svn.freebsd.org> <AANLkTi=pEArHiS-V-sX=hn8v=t=9t5swOPs63BXrMgXR@mail.gmail.com> <20100906234057.O954@delplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 6, 2010 at 6:45 AM, Bruce Evans <brde@optusnet.com.au> wrote:
> On Fri, 3 Sep 2010, pluknet wrote:
>
>> On 3 September 2010 21:23, Matthew D Fleming <mdf@freebsd.org> wrote:
>>>
>>> Log:
>>> =A0Fix user-space libsbuf build. =A0Why isn't CTASSERT available to
>>> =A0user-space?
>
> Well, user headers shouldn't be enlisted to check for kernel bugs that
> can be checked well enough in the kernel.

I agree, but in this case one could define different constants for
user space and kernel space, and the code could be wrong only for
user-space, where there isn't a compile-time assert.

I do always appreciate style and standards advice from Mr Bruce.  It's
the only way to learn (usually, hopefully, from other people's
mistakes ;-)

Thanks,
matthew

>>> Modified:
>>> =A0head/sys/kern/subr_sbuf.c
>>>
>>> Modified: head/sys/kern/subr_sbuf.c
>>>
>>> =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/kern/subr_sbuf.c =A0 Fri Sep =A03 16:12:39 2010 =A0 =A0 =
=A0 =A0(r212181)
>>> +++ head/sys/kern/subr_sbuf.c =A0 Fri Sep =A03 17:23:26 2010 =A0 =A0 =
=A0 =A0(r212182)
>>> @@ -116,8 +116,10 @@ _assert_sbuf_state(const char *fun, stru
>>>
>>> =A0#endif /* _KERNEL && INVARIANTS */
>>>
>>> +#ifdef _KERNEL
>>> =A0CTASSERT(powerof2(SBUF_MAXEXTENDSIZE));
>>> =A0CTASSERT(powerof2(SBUF_MAXEXTENDINCR));
>>> +#endif
>>>
>>> =A0static int
>>> =A0sbuf_extendsize(int size)
>>
>> Hi,
>>
>> as I can see, the next (and maybe preferred) model is used in system
>> headers:
>>
>> #ifdef CTASSERT
>> CTASSERT(...);
>> #endif
>
> Needed, even in the kernel, since CTASSERT() is only defined if the
> kernel-only header <sys/systm.h> has been included.
>
> If this macro were defined in a user header, then it would have to be
> more global (probably defined in <sys/cdefs.h>) but not in the applicatio=
n
> namespace (probably spelled __CTASSERT()), so it would be uglier.
>
> Bruce



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