Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Apr 2022 09:30:17 -0700
From:      John Baldwin <jhb@FreeBSD.org>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: b40c0db6f6d6 - main - Patch up __diagused for when only one of INVARIANTS or WITNESS is defined
Message-ID:  <60c3658a-2a59-dd89-b5c7-0f0318c2597c@FreeBSD.org>
In-Reply-To: <CAGudoHGRq=LABYb3tbHzAFAYEWejyEwNjy%2BbtRVzzGRz_PBnrg@mail.gmail.com>
References:  <202204271330.23RDUHwN063641@gitrepo.freebsd.org> <0dbcc859-69b1-4850-11c3-f8a4acf5bde9@FreeBSD.org> <CAGudoHFcnwpg-%2BKyxxRqz4Q3J18AAbDvqFXGGUFSLnH1WZWYiw@mail.gmail.com> <73612e5c-d6d7-0c5e-9cea-046839164bc5@FreeBSD.org> <CAGudoHGRq=LABYb3tbHzAFAYEWejyEwNjy%2BbtRVzzGRz_PBnrg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/27/22 9:18 AM, Mateusz Guzik wrote:
> On 4/27/22, John Baldwin <jhb@freebsd.org> wrote:
>> On 4/27/22 8:50 AM, Mateusz Guzik wrote:
>>> On 4/27/22, John Baldwin <jhb@freebsd.org> wrote:
>>>> On 4/27/22 6:30 AM, Mateusz Guzik wrote:
>>>>> The branch main has been updated by mjg:
>>>>>
>>>>> URL:
>>>>> https://cgit.FreeBSD.org/src/commit/?id=b40c0db6f6d61ed594118d81dc691b9263a7e4d7
>>>>>
>>>>> commit b40c0db6f6d61ed594118d81dc691b9263a7e4d7
>>>>> Author:     Mateusz Guzik <mjg@FreeBSD.org>
>>>>> AuthorDate: 2022-04-27 13:29:12 +0000
>>>>> Commit:     Mateusz Guzik <mjg@FreeBSD.org>
>>>>> CommitDate: 2022-04-27 13:29:12 +0000
>>>>>
>>>>>        Patch up __diagused for when only one of INVARIANTS or WITNESS is
>>>>> defined
>>>>>
>>>>>        Reported by:    John F Carr<jfc@mit.edu>
>>>>> ---
>>>>>     sys/sys/systm.h | 9 ++++++---
>>>>>     1 file changed, 6 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/sys/sys/systm.h b/sys/sys/systm.h
>>>>> index f2ffa7e6b815..6ca9ee886562 100644
>>>>> --- a/sys/sys/systm.h
>>>>> +++ b/sys/sys/systm.h
>>>>> @@ -554,10 +554,13 @@ void _gone_in_dev(device_t dev, int major, const
>>>>> char *msg);
>>>>>     #define gone_in(major, msg)		__gone_ok(major, msg) _gone_in(major,
>>>>> msg)
>>>>>     #define gone_in_dev(dev, major, msg)	__gone_ok(major, msg)
>>>>> _gone_in_dev(dev, major, msg)
>>>>>
>>>>> -#if defined(INVARIANTS) || defined(WITNESS)
>>>>> -#define	__diagused
>>>>> -#else
>>>>> +#if !defined(INVARIANTS) && !defined(WITNESS)
>>>>> +#define	__diagused	__unused
>>>>> +#elif ((defined(INVARIANTS) && !defined(WITNESS)) || \
>>>>> +	(!defined(INVARIANTS) && defined(WITNESS)))
>>>>>     #define	__diagused	__unused
>>>>> +#else
>>>>> +#define	__diagused
>>>>>     #endif
>>>>
>>>> Hmm, could this just be:
>>>>
>>>> #if defined(INVARIANTS) && defined(WITNESS)
>>>> #define __diagused
>>>> #else
>>>> #define __diagused __unused
>>>> #endif
>>>>
>>>
>>> it does boil down to it and if you want to make the change I'm not
>>> going to stand in the way, but then imo it should get a comment that
>>> there is no dedicated macro for invariants or witness only so some
>>> warnings are possibly silenced when they should not be
>>>
>>> however, the point here is that the case of only one of these being
>>> defined is distinct from the rest and may warrant special treatment. I
>>> wanted to preserve the distinction in the, arguably hairy,
>>> conditional.
>>
>> The other option perhaps is to split out a separate __witness_used as
>> I suspect the majority of __diagused cases are for INVARIANTS.  In a
>> few other places where I didn't want to use bare __unused I added
>> option-specific helpers (e.g. __usbdebug_unused).
>>
> 
> Ye, that's I wished I did the first time around after the bug report :)
> 
> I just checked and the reported build failure is the only spot when
> building GENERIC (without WITNESS) on amd64 so this may be perfectly
> feasible.

Ok, I can take a stab at doing that then.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?60c3658a-2a59-dd89-b5c7-0f0318c2597c>