Author: mjg
Date: Tue Mar 24 00:10:11 2015
New Revision: 280407
URL: https://svnweb.freebsd.org/changeset/base/280407
Log:
filedesc: microoptimize fget_unlocked by getting rid of fd < 0 branch
Casting fd to an unsigned type simplifies fd range coparison to mere checking
if the result is bigger than the table.
Modified:
head/sys/kern/kern_descrip.c
Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c Tue Mar 24 00:01:30 2015
(r280406)
+++ head/sys/kern/kern_descrip.c Tue Mar 24 00:10:11 2015
(r280407)
@@ -2342,7 +2342,7 @@ fget_unlocked(struct filedesc *fdp, int
#endif
fdt = fdp->fd_files;
- if (fd < 0 || fd >= fdt->fdt_nfiles)
+ if ((u_int)fd >= fdt->fdt_nfiles)
return (EBADF);
/*
* Fetch the descriptor locklessly. We avoid fdrop() races by
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"