On 4/27/22, John F Carr <j...@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>