Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111375427
D20226.id57265.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D20226.id57265.diff
View Options
Index: subr_blist.c
===================================================================
--- subr_blist.c
+++ subr_blist.c
@@ -120,11 +120,10 @@
#define malloc(a,b,c) calloc(a, 1)
#define free(a,b) free(a)
#define ummin(a,b) ((a) < (b) ? (a) : (b))
+#define KASSERT(a,b)
#include <sys/blist.h>
-void panic(const char *ctl, ...);
-
#endif
/*
@@ -235,8 +234,7 @@
blist_t bl;
u_daddr_t nodes, radix;
- if (blocks == 0)
- panic("invalid block count");
+ KASSERT(blocks > 0, ("invalid block count"));
/*
* Calculate the radix and node count used for scanning.
@@ -288,8 +286,8 @@
{
daddr_t blk, cursor;
- if (count > BLIST_MAX_ALLOC)
- panic("allocation too large");
+ KASSERT (count <= BLIST_MAX_ALLOC,
+ ("allocation too large: %d", maxcount));
/*
* This loop iterates at most twice. An allocation failure in the
@@ -325,15 +323,15 @@
/*
* blist_free() - free up space in the block bitmap. Return the base
- * of a contiguous region. Panic if an inconsistancy is
- * found.
+ * of a contiguous region.
*/
void
blist_free(blist_t bl, daddr_t blkno, daddr_t count)
{
- if (blkno < 0 || blkno + count > bl->bl_blocks)
- panic("freeing invalid range");
+ KASSERT(blkno >= 0 && blkno + count <= bl->bl_blocks,
+ ("freeing invalid range: blkno %llx, count %d, blocks %lld",
+ (long long)blkno, (int)count, (long long)bl->bl_blocks));
blst_meta_free(bl->bl_root, blkno, count, bl->bl_radix);
bl->bl_avail += count;
}
@@ -349,8 +347,9 @@
{
daddr_t filled;
- if (blkno < 0 || blkno + count > bl->bl_blocks)
- panic("filling invalid range");
+ KASSERT(blkno >= 0 && blkno + count <= bl->bl_blocks,
+ ("filling invalid range: blkno %llx, count %d, blocks %lld",
+ (long long)blkno, (int)count, (long long)bl->bl_blocks));
filled = blst_meta_fill(bl->bl_root, blkno, count, bl->bl_radix);
bl->bl_avail -= filled;
return (filled);
@@ -840,8 +839,9 @@
* count n
*/
mask = bitrange(blk & BLIST_BMAP_MASK, count);
- if (scan->bm_bitmap & mask)
- panic("freeing free block");
+ KASSERT((scan->bm_bitmap & mask) == 0,
+ ("freeing free block: %llx, size %d, mask %llx",
+ (long long)blk, count, (long long)scan->bm_bitmap & mask));
scan->bm_bitmap |= mask;
}
@@ -1142,19 +1142,7 @@
break;
}
}
- return(0);
+ return (0);
}
-void
-panic(const char *ctl, ...)
-{
- va_list va;
-
- va_start(va, ctl);
- vfprintf(stderr, ctl, va);
- fprintf(stderr, "\n");
- va_end(va);
- exit(1);
-}
-
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 4, 12:19 AM (11 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16956947
Default Alt Text
D20226.id57265.diff (2 KB)
Attached To
Mode
D20226: Replace panic() with KASSERT in subr_blist.c
Attached
Detach File
Event Timeline
Log In to Comment