Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Apr 2022 15:31:48 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        John F Carr <jfc@mit.edu>
Cc:        "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>
Subject:   Re: Can't build with INVARIANTS but not WITNESS
Message-ID:  <CAGudoHGgfcVgL=yOv3Hyguj5B8CaQypsbwmOzKi7dqibY_vLCw@mail.gmail.com>
In-Reply-To: <E5559D3F-2668-461D-B571-77EB55394866@exchange.mit.edu>
References:  <E5559D3F-2668-461D-B571-77EB55394866@exchange.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/27/22, John F Carr <jfc@mit.edu> wrote:
> My -CURRENT kernel has INVARIANTS (inherited from GENERIC) but not WITNESS:
>
> include GENERIC
> ident   STRIATUS
> nooptions       WITNESS
> nooptions       WITNESS_SKIPSPIN
>
> My kernel build fails:
>
> /usr/home/jfc/freebsd/src/sys/kern/vfs_lookup.c:102:13: error: variable
> 'line' set but not used [-Werror,-Wunused-but-set-variable]
>         int flags, line __diagused;
>                    ^
> /usr/home/jfc/freebsd/src/sys/kern/vfs_lookup.c:101:14: error: variable
> 'file' set but not used [-Werror,-Wunused-but-set-variable]
>         const char *file __diagused;
>
> The problem is, __diagused expands to nothing if INVARIANTS _or_ WITNESS is
> defined, but the variable in vfs_lookup.c is only used if WITNESS is
> defined.
>
> #if defined(INVARIANTS) || defined(WITNESS)
> #define __diagused
> #else
> #define __diagused      __unused
> #endif
>
> I think this code is trying to be too clever and causing more trouble than
> it prevents.  Change the || to &&, or replace __diagused with __unused
> everywhere.
>

I disagree. The entire point is to not end up with actually unused
variables even when is enabled.

I patched it up in
https://cgit.FreeBSD.org/src/commit/?id=b40c0db6f6d61ed594118d81dc691b9263a7e4d7
. This still allows for actually vars when only one of INVARIANTS or
WITNESS is defined, but that's a much smaller problem than allowing it
in general.

-- 
Mateusz Guzik <mjguzik gmail.com>



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