Module Name: src Committed By: riastradh Date: Fri Dec 31 14:19:57 UTC 2021
Modified Files: src/sys/dev/wscons: wsdisplay.c src/sys/kern: subr_autoconf.c subr_psref.c subr_thmap.c src/sys/lib/libkern: libkern.h Log Message: libkern: Make KASSERT verify expression is valid if !DIAGNOSTIC. This way it is no longer necessary to mark variables __diagused if they are used in KASSERT conditions. Fix fallout from this by removing now-unnecessary and `#ifdef DIAGNOSTIC'. Don't do the same for KDASSERT if !DEBUG -- unlike KASSERT and DIAGNOSTIC, variables needed by KDASSERT and DEBUG are likely to be expensive to compute (and potentially difficult for a compiler to prove flushable), so we don't want to require them under !DEBUG. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/dev/wscons/wsdisplay.c cvs rdiff -u -r1.290 -r1.291 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_psref.c cvs rdiff -u -r1.7 -r1.8 src/sys/kern/subr_thmap.c cvs rdiff -u -r1.143 -r1.144 src/sys/lib/libkern/libkern.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/wscons/wsdisplay.c diff -u src/sys/dev/wscons/wsdisplay.c:1.162 src/sys/dev/wscons/wsdisplay.c:1.163 --- src/sys/dev/wscons/wsdisplay.c:1.162 Sun Dec 27 16:09:33 2020 +++ src/sys/dev/wscons/wsdisplay.c Fri Dec 31 14:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay.c,v 1.162 2020/12/27 16:09:33 tsutsui Exp $ */ +/* $NetBSD: wsdisplay.c,v 1.163 2021/12/31 14:19:57 riastradh Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.162 2020/12/27 16:09:33 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.163 2021/12/31 14:19:57 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_wsdisplay_compat.h" @@ -115,10 +115,8 @@ struct wsscreen { struct wsdisplay_softc *sc; -#ifdef DIAGNOSTIC /* XXX this is to support a hack in emulinput, see comment below */ int scr_in_ttyoutput; -#endif }; static struct wsscreen *wsscreen_attach(struct wsdisplay_softc *, int, Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.290 src/sys/kern/subr_autoconf.c:1.291 --- src/sys/kern/subr_autoconf.c:1.290 Mon Oct 11 10:59:09 2021 +++ src/sys/kern/subr_autoconf.c Fri Dec 31 14:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.290 2021/10/11 10:59:09 jmcneill Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.291 2021/12/31 14:19:57 riastradh Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.290 2021/10/11 10:59:09 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.291 2021/12/31 14:19:57 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -838,7 +838,6 @@ cfdriver_get_iattr(const struct cfdriver return 0; } -#if defined(DIAGNOSTIC) static int cfdriver_iattr_count(const struct cfdriver *cd) { @@ -853,7 +852,6 @@ cfdriver_iattr_count(const struct cfdriv } return i; } -#endif /* DIAGNOSTIC */ /* * Lookup an interface attribute description by name. Index: src/sys/kern/subr_psref.c diff -u src/sys/kern/subr_psref.c:1.15 src/sys/kern/subr_psref.c:1.16 --- src/sys/kern/subr_psref.c:1.15 Wed Jul 21 06:35:45 2021 +++ src/sys/kern/subr_psref.c Fri Dec 31 14:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_psref.c,v 1.15 2021/07/21 06:35:45 skrll Exp $ */ +/* $NetBSD: subr_psref.c,v 1.16 2021/12/31 14:19:57 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.15 2021/07/21 06:35:45 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.16 2021/12/31 14:19:57 riastradh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -170,7 +170,6 @@ psref_class_create(const char *name, int return class; } -#ifdef DIAGNOSTIC static void psref_cpu_drained_p(void *p, void *cookie, struct cpu_info *ci __unused) { @@ -190,7 +189,6 @@ psref_class_drained_p(const struct psref return ret; } -#endif /* DIAGNOSTIC */ /* * psref_class_destroy(class) Index: src/sys/kern/subr_thmap.c diff -u src/sys/kern/subr_thmap.c:1.7 src/sys/kern/subr_thmap.c:1.8 --- src/sys/kern/subr_thmap.c:1.7 Mon Aug 31 20:22:57 2020 +++ src/sys/kern/subr_thmap.c Fri Dec 31 14:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_thmap.c,v 1.7 2020/08/31 20:22:57 riastradh Exp $ */ +/* $NetBSD: subr_thmap.c,v 1.8 2021/12/31 14:19:57 riastradh Exp $ */ /*- * Copyright (c) 2018 Mindaugas Rasiukevicius <rmind at noxt eu> @@ -112,7 +112,7 @@ #include "utils.h" #endif -THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.7 2020/08/31 20:22:57 riastradh Exp $"); +THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.8 2021/12/31 14:19:57 riastradh Exp $"); #include <crypto/blake2/blake2s.h> @@ -256,13 +256,11 @@ static const thmap_ops_t thmap_default_o * NODE LOCKING. */ -#ifdef DIAGNOSTIC static inline bool node_locked_p(thmap_inode_t *node) { return (atomic_load_relaxed(&node->state) & NODE_LOCKED) != 0; } -#endif static void lock_node(thmap_inode_t *node) Index: src/sys/lib/libkern/libkern.h diff -u src/sys/lib/libkern/libkern.h:1.143 src/sys/lib/libkern/libkern.h:1.144 --- src/sys/lib/libkern/libkern.h:1.143 Mon May 17 08:50:36 2021 +++ src/sys/lib/libkern/libkern.h Fri Dec 31 14:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: libkern.h,v 1.143 2021/05/17 08:50:36 mrg Exp $ */ +/* $NetBSD: libkern.h,v 1.144 2021/12/31 14:19:57 riastradh Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -269,8 +269,14 @@ tolower(int ch) #define KASSERTMSG(e, msg, ...) /* NOTHING */ #define KASSERT(e) /* NOTHING */ #else /* !lint */ -#define KASSERTMSG(e, msg, ...) ((void)0) -#define KASSERT(e) ((void)0) +/* + * Make sure the expression compiles, but don't evaluate any of it. We + * use sizeof to inhibit evaluation, and cast to long so the expression + * can be integer- or pointer-valued without bringing in other header + * files. + */ +#define KASSERTMSG(e, msg, ...) ((void)sizeof((long)(e))) +#define KASSERT(e) ((void)sizeof((long)(e))) #endif /* !lint */ #else /* DIAGNOSTIC */ #define _DIAGASSERT(a) assert(a)