Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs Turn some `#if DIAGNOSTIC' into KASSERT.
details: https://anonhg.NetBSD.org/src/rev/ebf3386d1f61
branches: trunk
changeset: 336946:ebf3386d1f61
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Mar 28 03:53:36 2015 +0000
description:
Turn some `#if DIAGNOSTIC' into KASSERT.
diffstat:
sys/ufs/ext2fs/ext2fs_readwrite.c | 34 +++++++++++-----------------------
sys/ufs/lfs/ulfs_readwrite.c | 32 ++++++++++----------------------
sys/ufs/ufs/ufs_readwrite.c | 32 ++++++++++----------------------
3 files changed, 31 insertions(+), 67 deletions(-)
diffs (188 lines):
diff -r 9cb30721852a -r ebf3386d1f61 sys/ufs/ext2fs/ext2fs_readwrite.c
--- a/sys/ufs/ext2fs/ext2fs_readwrite.c Sat Mar 28 03:49:41 2015 +0000
+++ b/sys/ufs/ext2fs/ext2fs_readwrite.c Sat Mar 28 03:53:36 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_readwrite.c,v 1.69 2015/03/28 03:49:41 riastradh Exp $ */
+/* $NetBSD: ext2fs_readwrite.c,v 1.70 2015/03/28 03:53:36 riastradh Exp $ */
/*-
* Copyright (c) 1993
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.69 2015/03/28 03:49:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.70 2015/03/28 03:53:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -108,13 +108,9 @@
uio = ap->a_uio;
error = 0;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("%s: mode", "ext2fs_read");
+ KASSERT(uio->uio_rw == UIO_READ);
+ KASSERT(vp->v_type == VREG || vp->v_type == VDIR);
- if (vp->v_type != VREG && vp->v_type != VDIR)
- panic("%s: type %d", "ext2fs_read", vp->v_type);
-#endif
/* XXX Eliminate me by refusing directory reads from userland. */
if (vp->v_type == VDIR)
return ext2fs_bufrd(vp, uio, ap->a_ioflag, ap->a_cred);
@@ -272,22 +268,14 @@
ump = ip->i_ump;
error = 0;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("%s: mode", "ext2fs_write");
-#endif
+ KASSERT(uio->uio_rw == UIO_WRITE);
+ KASSERT(vp->v_type == VREG);
- switch (vp->v_type) {
- case VREG:
- if (ioflag & IO_APPEND)
- uio->uio_offset = ext2fs_size(ip);
- if ((ip->i_e2fs_flags & EXT2_APPEND) &&
- uio->uio_offset != ext2fs_size(ip))
- return (EPERM);
- break;
- default:
- panic("%s: type", "ext2fs_write");
- }
+ if (ioflag & IO_APPEND)
+ uio->uio_offset = ext2fs_size(ip);
+ if ((ip->i_e2fs_flags & EXT2_APPEND) &&
+ uio->uio_offset != ext2fs_size(ip))
+ return (EPERM);
fs = ip->i_e2fs;
if (uio->uio_offset < 0 ||
diff -r 9cb30721852a -r ebf3386d1f61 sys/ufs/lfs/ulfs_readwrite.c
--- a/sys/ufs/lfs/ulfs_readwrite.c Sat Mar 28 03:49:41 2015 +0000
+++ b/sys/ufs/lfs/ulfs_readwrite.c Sat Mar 28 03:53:36 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_readwrite.c,v 1.9 2015/03/27 19:47:14 riastradh Exp $ */
+/* $NetBSD: ulfs_readwrite.c,v 1.10 2015/03/28 03:53:36 riastradh Exp $ */
/* from NetBSD: ufs_readwrite.c,v 1.105 2013/01/22 09:39:18 dholland Exp */
/*-
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.9 2015/03/27 19:47:14 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.10 2015/03/28 03:53:36 riastradh Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@@ -84,13 +84,9 @@
ioflag = ap->a_ioflag;
error = 0;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("%s: mode", READ_S);
+ KASSERT(uio->uio_rw == UIO_READ);
+ KASSERT(vp->v_type == VREG || vp->v_type == VDIR);
- if (vp->v_type != VREG && vp->v_type != VDIR)
- panic("%s: type %d", READ_S, vp->v_type);
-#endif
/* XXX Eliminate me by refusing directory reads from userland. */
if (vp->v_type == VDIR)
return BUFRD(vp, uio, ioflag, ap->a_cred);
@@ -269,21 +265,13 @@
ip = VTOI(vp);
KASSERT(vp->v_size == ip->i_size);
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("%s: mode", WRITE_S);
-#endif
+ KASSERT(uio->uio_rw == UIO_WRITE);
+ KASSERT(vp->v_type == VREG);
- switch (vp->v_type) {
- case VREG:
- if (ioflag & IO_APPEND)
- uio->uio_offset = ip->i_size;
- if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size)
- return (EPERM);
- break;
- default:
- panic("%s: type", WRITE_S);
- }
+ if (ioflag & IO_APPEND)
+ uio->uio_offset = ip->i_size;
+ if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size)
+ return (EPERM);
fs = ip->I_FS;
if (uio->uio_offset < 0 ||
diff -r 9cb30721852a -r ebf3386d1f61 sys/ufs/ufs/ufs_readwrite.c
--- a/sys/ufs/ufs/ufs_readwrite.c Sat Mar 28 03:49:41 2015 +0000
+++ b/sys/ufs/ufs/ufs_readwrite.c Sat Mar 28 03:53:36 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_readwrite.c,v 1.109 2015/03/27 19:47:14 riastradh Exp $ */
+/* $NetBSD: ufs_readwrite.c,v 1.110 2015/03/28 03:53:36 riastradh Exp $ */
/*-
* Copyright (c) 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.109 2015/03/27 19:47:14 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.110 2015/03/28 03:53:36 riastradh Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@@ -96,13 +96,9 @@
ioflag = ap->a_ioflag;
error = 0;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("%s: mode", READ_S);
+ KASSERT(uio->uio_rw == UIO_READ);
+ KASSERT(vp->v_type == VREG || vp->v_type == VDIR);
- if (vp->v_type != VREG && vp->v_type != VDIR)
- panic("%s: type %d", READ_S, vp->v_type);
-#endif
/* XXX Eliminate me by refusing directory reads from userland. */
if (vp->v_type == VDIR)
return BUFRD(vp, uio, ioflag, ap->a_cred);
@@ -294,21 +290,13 @@
ump = ip->i_ump;
KASSERT(vp->v_size == ip->i_size);
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("%s: mode", WRITE_S);
-#endif
+ KASSERT(uio->uio_rw == UIO_WRITE);
+ KASSERT(vp->v_type == VREG);
- switch (vp->v_type) {
- case VREG:
- if (ioflag & IO_APPEND)
- uio->uio_offset = ip->i_size;
- if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size)
- return (EPERM);
- break;
- default:
- panic("%s: type", WRITE_S);
- }
+ if (ioflag & IO_APPEND)
+ uio->uio_offset = ip->i_size;
+ if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size)
+ return (EPERM);
fs = ip->I_FS;
if (uio->uio_offset < 0 ||
Home |
Main Index |
Thread Index |
Old Index