diff options
author | 2014-07-13 23:49:40 +0000 | |
---|---|---|
committer | 2014-07-13 23:49:40 +0000 | |
commit | a972b4a4eb1466195f36d2e762d5d43d5e152e6c (patch) | |
tree | 22e17e4064f54adc8445ba74e5b28bc38feec087 /sys/kern/kern_physio.c | |
parent | Add stubs for the proposed server API. (diff) | |
download | wireguard-openbsd-a972b4a4eb1466195f36d2e762d5d43d5e152e6c.tar.xz wireguard-openbsd-a972b4a4eb1466195f36d2e762d5d43d5e152e6c.zip |
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/kern_physio.c')
-rw-r--r-- | sys/kern/kern_physio.c | 18 |
1 files changed, 5 insertions, 13 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; |