> Here are a few more instances of KASSERT being placed in an #ifdef DIAGNOSTIC
> block.  This is redundant, as KASSERT is already a nop if DIAGNOSTIC is not
> defined.

Yes and no. You are right that KASSERT is a nop on non-DIAGNOSTIC
kernels, but there are sometimes good reasons to keep a single KASSERT
(or a set of KASSERTs) wrapped within #ifdef DIAGNOSTIC.

> Index: crypto/blake2s.c

In this case, the removal is valid and worth doing (in blake2s.h too).

> Index: dev/ic/ahci.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ahci.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 ahci.c
> --- dev/ic/ahci.c     9 Apr 2022 20:10:26 -0000       1.38
> +++ dev/ic/ahci.c     19 Jan 2023 13:30:37 -0000
> @@ -2472,19 +2472,16 @@ ahci_put_err_ccb(struct ahci_ccb *ccb)
>  
>       splassert(IPL_BIO);
>  
> -#ifdef DIAGNOSTIC
>       KASSERT(ap->ap_err_busy);
> -#endif
> +

In this case, I would keep the #ifdef because this field only exists
#ifdef DIAGNOSTIC, so all the code operating on it should have such
guards for consistency.

>       /* No commands may be active on the chip */
>       sact = ahci_pread(ap, AHCI_PREG_SACT);
>       if (sact != 0)
>               printf("ahci_put_err_ccb but SACT %08x != 0?\n", sact);
>       KASSERT(ahci_pread(ap, AHCI_PREG_CI) == 0);
>  
> -#ifdef DIAGNOSTIC
>       /* Done with the CCB */
>       KASSERT(ccb == ap->ap_ccb_err);
> -#endif

In this case, on the other hand, the #ifdef can be removed.

> Index: dev/wscons/wsemul_sun.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/wscons/wsemul_sun.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 wsemul_sun.c
> --- dev/wscons/wsemul_sun.c   25 May 2020 09:55:49 -0000      1.34
> +++ dev/wscons/wsemul_sun.c   19 Jan 2023 13:30:38 -0000
> @@ -242,9 +242,9 @@ wsemul_sun_attach(int console, const str
>  
>       if (console) {
>               edp = &wsemul_sun_console_emuldata;
> -#ifdef DIAGNOSTIC
> +
>               KASSERT(edp->console == 1);
> -#endif
> +

Same as for ahci: The `console' field only exists #ifdef DIAGNOSTIC, so
the guards must remain (and in that respect, wsemul_vt100.c r1.40 was a
mistake).

> Index: net/wg_noise.c

The removal is valid here.

Reply via email to