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
aa1ba0c150
commit
ce00fb8c10
@ -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