diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-04-24 15:46:47 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-04-28 17:27:29 +0200 |
| commit | 23431ae93a21d485f66a177304de353113dcdd28 (patch) | |
| tree | ac954616e9bf9777984e76c42c35399aa463cf72 | |
| parent | f38567bb63ae029e3b63fcb99b6a2dcc6f421e69 (diff) | |
| download | linux-23431ae93a21d485f66a177304de353113dcdd28.tar.gz linux-23431ae93a21d485f66a177304de353113dcdd28.zip | |
eventpoll: use bool for predicate helpers
Three inline predicates -- is_file_epoll(), ep_is_linked(),
ep_events_available() -- were declared to return int even though
their only use is as a truthy test and their bodies are already
boolean expressions. ep_has_wakeup_source(), in the same file,
returns bool, so the convention was already inconsistent.
Convert all three to return bool. Rewrite ep_events_available()'s
verbose kerneldoc to the same one-line style the rest of the
predicates use now.
ep_poll()'s local eavail variable stores the result of
ep_events_available() (already boolean), ep_busy_loop() (returns
bool), and list_empty() (int but tested as boolean). Split it out
of the combined int declaration and give it bool type; replace the
one "eavail = 1" after a wakeup with "eavail = true" to match.
No functional change.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Link: https://patch.msgid.link/20260424-work-epoll-rework-v1-16-249ed00a20f3@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
| -rw-r--r-- | fs/eventpoll.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 7ed4b47279ff..201e688304b3 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -505,7 +505,7 @@ static void __init epoll_sysctls_init(void) static const struct file_operations eventpoll_fops; -static inline int is_file_epoll(struct file *f) +static inline bool is_file_epoll(struct file *f) { return f->f_op == &eventpoll_fops; } @@ -526,8 +526,8 @@ static inline int ep_cmp_ffd(struct epoll_filefd *p1, (p1->file < p2->file ? -1 : p1->fd - p2->fd)); } -/* Tells us if the item is currently linked */ -static inline int ep_is_linked(struct epitem *epi) +/* True iff @epi is on its owning ep's ready list. */ +static inline bool ep_is_linked(struct epitem *epi) { return !list_empty(&epi->rdllink); } @@ -580,15 +580,8 @@ static inline void epi_clear_ovflist(struct epitem *epi) epi->ovflist_next = EP_UNACTIVE_PTR; } -/** - * ep_events_available - Checks if ready events might be available. - * - * @ep: Pointer to the eventpoll context. - * - * Return: a value different than %zero if ready events are available, - * or %zero otherwise. - */ -static inline int ep_events_available(struct eventpoll *ep) +/* True iff @ep has ready events that epoll_wait() might harvest. */ +static inline bool ep_events_available(struct eventpoll *ep) { return !list_empty_careful(&ep->rdllist) || ep_is_scanning(ep); } @@ -2218,7 +2211,8 @@ static int ep_schedule_timeout(ktime_t *to) static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, int maxevents, struct timespec64 *timeout) { - int res, eavail, timed_out = 0; + int res, timed_out = 0; + bool eavail; u64 slack = 0; wait_queue_entry_t wait; ktime_t expires, *to = NULL; @@ -2316,7 +2310,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, * If timed out and still on the wait queue, recheck eavail * carefully under lock, below. */ - eavail = 1; + eavail = true; if (!list_empty_careful(&wait.entry)) { spin_lock_irq(&ep->lock); |
