mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-29 11:54:38 +01:00
kern: replace several EBADF with EINVAL
EBADF semantic is that the passed fd is invalid, not that it is of wrong type. Using EBADF in these places in kern_event.c and sys_procdesc.c give bad examples to copy from. Note that places in kern_event.c that checks KQ_CLOSING and return EBADF are kept, since KQ_CLOSING is the transient state before the fd is finally closed and become eligible for EBADF. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D52410
This commit is contained in:
1 parent
fdb3b695a4
commit
fd9e09cb2a
2 files changed
+3
-3
No files matched your search
@@ -1903,7 +1903,7 @@ kqueue_acquire(struct file *fp, struct kqueue **kqp)
|
||||
|
||||
kq = fp->f_data;
|
||||
if (fp->f_type != DTYPE_KQUEUE || kq == NULL)
|
||||
return (EBADF);
|
||||
return (EINVAL);
|
||||
*kqp = kq;
|
||||
KQ_LOCK(kq);
|
||||
if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) {
|
||||
|
||||
@@ -129,7 +129,7 @@ procdesc_find(struct thread *td, int fd, const cap_rights_t *rightsp,
|
||||
if (error)
|
||||
return (error);
|
||||
if (fp->f_type != DTYPE_PROCDESC) {
|
||||
error = EBADF;
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
pd = fp->f_data;
|
||||
@@ -175,7 +175,7 @@ kern_pdgetpid(struct thread *td, int fd, const cap_rights_t *rightsp,
|
||||
if (error)
|
||||
return (error);
|
||||
if (fp->f_type != DTYPE_PROCDESC) {
|
||||
error = EBADF;
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
*pidp = procdesc_pid(fp);
|
||||
|
||||
Reference in new issue
Block a user