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.
This commit is contained in:
mjg 2015-03-24 00:10:11 +00:00
parent aa1ba0c150
commit ce00fb8c10

View File

@ -2342,7 +2342,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
#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