summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMasao Uebayashi <uebayasi@cvs.openbsd.org>2014-07-13 23:49:41 +0000
committerMasao Uebayashi <uebayasi@cvs.openbsd.org>2014-07-13 23:49:41 +0000
commitfc65c734b6e806538a2d2a9a00a44e8ceaae00b6 (patch)
tree128123785c0f7a4acbdac17840af379c69f17d20 /sys/kern
parent1e81356459ee5c7e8c2ebac6542190130defbd09 (diff)
KASSERTMSG(9): New kernel assertion with message
KASSERT() is annoying as it only prints the expression as a string. If you (developers) want to know a little more information, you have to do: #ifdef DIAGNOSTIC if (bad) panic(...); #endif KASSERTMSG() replaces it into a single line: KASSERTMSG(!bad, ...); Taken from NetBSD. (There is a concern that KASSERT() messages are too long; consume more memory, and not friendly for small monitors. This have to be considered & revisited later.) "Like" from henning@ Man page review & advices from jmc@ and schwarze@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_physio.c18
-rw-r--r--sys/kern/subr_prf.c5
2 files changed, 7 insertions, 16 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 60d44331d28..bf588f26ba9 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_physio.c,v 1.39 2011/07/18 02:49:20 matthew Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.40 2014/07/13 23:49:40 uebayasi Exp $ */
/* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */
/*-
@@ -128,12 +128,8 @@ physio(void (*strategy)(struct buf *), dev_t dev, int flags,
*/
(*minphys)(bp);
todo = bp->b_bcount;
-#ifdef DIAGNOSTIC
- if (todo < 0)
- panic("todo < 0; minphys broken");
- if (todo > MAXPHYS)
- panic("todo > MAXPHYS; minphys broken");
-#endif
+ KASSERTMSG(todo >= 0, "minphys broken");
+ KASSERTMSG(todo <= MAXPHYS, "minphys broken");
/*
* [lock the part of the user address space involved
@@ -194,12 +190,8 @@ physio(void (*strategy)(struct buf *), dev_t dev, int flags,
* of data to transfer]
*/
done = bp->b_bcount - bp->b_resid;
-#ifdef DIAGNOSTIC
- if (done < 0)
- panic("done < 0; strategy broken");
- if (done > todo)
- panic("done > todo; strategy broken");
-#endif
+ KASSERTMSG(done >= 0, "strategy broken");
+ KASSERTMSG(done <= todo, "strategy broken");
iovp->iov_len -= done;
iovp->iov_base = (caddr_t)iovp->iov_base + done;
uio->uio_offset += done;
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index ed134d1fe3a..899fcb529d5 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_prf.c,v 1.82 2014/07/11 14:36:44 uebayasi Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.83 2014/07/13 23:49:40 uebayasi Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
@@ -156,8 +156,7 @@ void
__assert(const char *t, const char *f, int l, const char *e)
{
- panic("kernel %sassertion \"%s\" failed: file \"%s\", line %d",
- t, e, f, l);
+ panic(__KASSERTSTR, t, e, f, l);
}
/*