commit - c48cf63883dde2f28bca9aa8b97e0bcd94b071ff
commit + 21c9672d65fdfef303bd8dd6b699c13d19118c22
blob - 473ce3d8dd057cae13b31e8676d33d366f2082f3
blob + f0cb8b173bba9cfbb314353d6720f6c6be03a399
--- ev.c
+++ ev.c
int
ev_add(int fd, int ev, void (*cb)(int, int, void *), void *udata)
{
- if (fd < 0 || (size_t)fd >= base->len) {
+ if (fd < 0) {
+ errno = EBADF;
+ return -1;
+ }
+
+ if ((size_t)fd >= base->len) {
if (ev_resize(fd + 1) == -1)
return -1;
}
int
ev_del(int fd)
{
- if (fd < 0 || (size_t)fd >= base->len) {
+ if (fd < 0) {
+ errno = EBADF;
+ return -1;
+ }
+
+ if ((size_t)fd >= base->len) {
errno = ERANGE;
return -1;
}