summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-06-14 15:34:10 +0000
committerpjd <pjd@FreeBSD.org>2012-06-14 15:34:10 +0000
commit7b02ff91719409c8e8110701c1aaba1982b273a1 (patch)
tree7f08656be4722317416f1a18854ec2579c15214d /sys/kern/kern_descrip.c
parent32b7d4b1494f830b495e37e72fe31be77bef62b6 (diff)
downloadFreeBSD-src-7b02ff91719409c8e8110701c1aaba1982b273a1.zip
FreeBSD-src-7b02ff91719409c8e8110701c1aaba1982b273a1.tar.gz
Style fixes and assertions improvements.
MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 6802672..bf3d01d 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -242,8 +242,10 @@ fd_last_used(struct filedesc *fdp, int size)
static int
fdisused(struct filedesc *fdp, int fd)
{
+
KASSERT(fd >= 0 && fd < fdp->fd_nfiles,
("file descriptor %d out of range (0, %d)", fd, fdp->fd_nfiles));
+
return ((fdp->fd_map[NDSLOT(fd)] & NDBIT(fd)) != 0);
}
@@ -255,8 +257,8 @@ fdused(struct filedesc *fdp, int fd)
{
FILEDESC_XLOCK_ASSERT(fdp);
- KASSERT(!fdisused(fdp, fd),
- ("fd already used"));
+
+ KASSERT(!fdisused(fdp, fd), ("fd=%d is already used", fd));
fdp->fd_map[NDSLOT(fd)] |= NDBIT(fd);
if (fd > fdp->fd_lastfile)
@@ -273,10 +275,9 @@ fdunused(struct filedesc *fdp, int fd)
{
FILEDESC_XLOCK_ASSERT(fdp);
- KASSERT(fdisused(fdp, fd),
- ("fd is already unused"));
- KASSERT(fdp->fd_ofiles[fd] == NULL,
- ("fd is still in use"));
+
+ KASSERT(fdisused(fdp, fd), ("fd=%d is already unused", fd));
+ KASSERT(fdp->fd_ofiles[fd] == NULL, ("fd=%d is still in use", fd));
fdp->fd_map[NDSLOT(fd)] &= ~NDBIT(fd);
if (fd < fdp->fd_freefile)
OpenPOWER on IntegriCloud