[lttng-dev] [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
mathieu.desnoyers at efficios.com
Fri Mar 22 11:04:36 EDT 2019
----- On Mar 21, 2019, at 4:25 PM, Jeremie Galarneau jeremie.galarneau at efficios.com wrote:
>> + assert(idx < events->wait.nb_fd);
> Not needed. Using assert() is fine to highlight assumptions across
> interfaces/functions and/or catch catastrophic internal errors. Here,
> this would be a very local condition that seems to be already
> Reworking the 'for' condition to use 'i < events->wait.nb_fd' and
> breaking out early of the loop is also an option here.
The reason for using assert() here is to ensure that there is no discrepancy
between the number of active poll fd in the set and the value returned by
poll indicating that same number of active fds.
We'd need a kernel bug (or memory corruption) to have a mismatch, but I thought
having an assert in there would not hurt, since it might help diagnose issues
that cross user-kernel boundaries.
More information about the lttng-dev