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:
parent
ca0f81984a
commit
ea926658ff
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=280407
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user