summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2012-06-13 17:18:16 +0000
committermjg <mjg@FreeBSD.org>2012-06-13 17:18:16 +0000
commit29bd2f6d4632d1ccdcb5f08bc6150a1e3047a731 (patch)
tree85e8b61e5a4b017a6a90a90dcf7f519461eb5088 /sys/kern/kern_descrip.c
parent1ca4c8cbf909810e0a057b149ac0af3e776a050e (diff)
downloadFreeBSD-src-29bd2f6d4632d1ccdcb5f08bc6150a1e3047a731.zip
FreeBSD-src-29bd2f6d4632d1ccdcb5f08bc6150a1e3047a731.tar.gz
Remove 'low' argument from fd_last_used().
This function is static and the only caller always passes 0 as low. While here update note about return values in comment. Reviewed by: pjd Approved by: trasz (mentor) MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 4341829..9592d8e 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -119,7 +119,7 @@ static int closefp(struct filedesc *fdp, int fd, struct file *fp,
static int do_dup(struct thread *td, int flags, int old, int new,
register_t *retval);
static int fd_first_free(struct filedesc *, int, int);
-static int fd_last_used(struct filedesc *, int, int);
+static int fd_last_used(struct filedesc *, int);
static void fdgrowtable(struct filedesc *, int);
static void fdunused(struct filedesc *fdp, int fd);
static void fdused(struct filedesc *fdp, int fd);
@@ -217,19 +217,16 @@ fd_first_free(struct filedesc *fdp, int low, int size)
}
/*
- * Find the highest non-zero bit in the given bitmap, starting at low and
- * not exceeding size - 1.
+ * Find the highest non-zero bit in the given bitmap, starting at 0 and
+ * not exceeding size - 1. Return -1 if not found.
*/
static int
-fd_last_used(struct filedesc *fdp, int low, int size)
+fd_last_used(struct filedesc *fdp, int size)
{
NDSLOTTYPE *map = fdp->fd_map;
NDSLOTTYPE mask;
int off, minoff;
- if (low >= size)
- return (-1);
-
off = NDSLOT(size);
if (size % NDENTRIES) {
mask = ~(~(NDSLOTTYPE)0 << (size % NDENTRIES));
@@ -237,10 +234,10 @@ fd_last_used(struct filedesc *fdp, int low, int size)
return (off * NDENTRIES + flsl(mask) - 1);
--off;
}
- for (minoff = NDSLOT(low); off >= minoff; --off)
+ for (minoff = NDSLOT(0); off >= minoff; --off)
if (map[off] != 0)
return (off * NDENTRIES + flsl(map[off]) - 1);
- return (low - 1);
+ return (-1);
}
static int
@@ -286,7 +283,7 @@ fdunused(struct filedesc *fdp, int fd)
if (fd < fdp->fd_freefile)
fdp->fd_freefile = fd;
if (fd == fdp->fd_lastfile)
- fdp->fd_lastfile = fd_last_used(fdp, 0, fd);
+ fdp->fd_lastfile = fd_last_used(fdp, fd);
}
/*
OpenPOWER on IntegriCloud