Module Name:    src
Committed By:   riastradh
Date:           Sat Mar 18 05:20:04 UTC 2017

Modified Files:
        src/sys/ufs/ffs: ffs_alloc.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/ufs/ffs/ffs_alloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.155 src/sys/ufs/ffs/ffs_alloc.c:1.156
--- src/sys/ufs/ffs/ffs_alloc.c:1.155	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ffs/ffs_alloc.c	Sat Mar 18 05:20:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.156 2017/03/18 05:20:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.156 2017/03/18 05:20:04 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -226,15 +226,15 @@ ffs_alloc(struct inode *ip, daddr_t lbn,
 #endif
 
 	*bnp = 0;
-#ifdef DIAGNOSTIC
-	if (cred == NOCRED)
-		panic("%s: missing credential", __func__);
-	if ((u_int)size > fs->fs_bsize || ffs_fragoff(fs, size) != 0) {
-		panic("%s: bad size: dev = 0x%llx, bsize = %d, size = %d, "
-		    "fs = %s", __func__, (unsigned long long)ip->i_dev,
-		    fs->fs_bsize, size, fs->fs_fsmnt);
-	}
-#endif /* DIAGNOSTIC */
+
+	KASSERTMSG((cred != NOCRED), "missing credential");
+	KASSERTMSG(((u_int)size <= fs->fs_bsize),
+	    "bad size: dev = 0x%llx, bsize = %d, size = %d, fs = %s",
+	    (unsigned long long)ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
+	KASSERTMSG((ffs_fragoff(fs, size) == 0),
+	    "bad size: dev = 0x%llx, bsize = %d, size = %d, fs = %s",
+	    (unsigned long long)ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
+
 	if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0)
 		goto nospace;
 	if (freespace(fs, fs->fs_minfree) <= 0 &&
@@ -344,17 +344,24 @@ ffs_realloccg(struct inode *ip, daddr_t 
 	}
 #endif
 
-#ifdef DIAGNOSTIC
-	if (cred == NOCRED)
-		panic("%s: missing credential", __func__);
-	if ((u_int)osize > fs->fs_bsize || ffs_fragoff(fs, osize) != 0 ||
-	    (u_int)nsize > fs->fs_bsize || ffs_fragoff(fs, nsize) != 0) {
-		panic("%s: bad size: dev = 0x%llx, bsize = %d, osize = %d, "
-		    "nsize = %d, fs = %s", __func__,
-		    (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
-		    fs->fs_fsmnt);
-	}
-#endif /* DIAGNOSTIC */
+	KASSERTMSG((cred != NOCRED), "missing credential");
+	KASSERTMSG(((u_int)osize <= fs->fs_bsize),
+	    "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	    (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	    fs->fs_fsmnt);
+	KASSERTMSG((ffs_fragoff(fs, osize) == 0),
+	    "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	    (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	    fs->fs_fsmnt);
+	KASSERTMSG(((u_int)nsize <= fs->fs_bsize),
+	    "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	    (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	    fs->fs_fsmnt);
+	KASSERTMSG((ffs_fragoff(fs, nsize) == 0),
+	    "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	    (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	    fs->fs_fsmnt);
+
 	if (freespace(fs, fs->fs_minfree) <= 0 &&
 	    kauth_authorize_system(cred, KAUTH_SYSTEM_FS_RESERVEDSPACE, 0, NULL,
 	    NULL, NULL) != 0) {

Reply via email to