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.
This commit is contained in:
parent
3da318191b
commit
57efa05d59
|
@ -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,
|
||||
|
|
|
@ -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 *cd, const char *ia)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(DIAGNOSTIC)
|
||||
static int
|
||||
cfdriver_iattr_count(const struct cfdriver *cd)
|
||||
{
|
||||
|
@ -853,7 +852,6 @@ cfdriver_iattr_count(const struct cfdriver *cd)
|
|||
}
|
||||
return i;
|
||||
}
|
||||
#endif /* DIAGNOSTIC */
|
||||
|
||||
/*
|
||||
* Lookup an interface attribute description by name.
|
||||
|
|
|
@ -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 ipl)
|
|||
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_class *prc)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif /* DIAGNOSTIC */
|
||||
|
||||
/*
|
||||
* psref_class_destroy(class)
|
||||
|
|
|
@ -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_ops = {
|
|||
* 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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue