glib-aux: add assertions to nm_utils_fd_wait_for_event()

This commit is contained in:
Thomas Haller 2022-08-03 12:10:41 +02:00
parent d5b31a05e6
commit e80fc43f2a
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -3383,6 +3383,8 @@ nm_utils_fd_wait_for_event(int fd, int event, gint64 timeout_nsec)
struct timespec ts, *pts;
int r;
nm_assert(fd >= 0);
if (timeout_nsec < 0)
pts = NULL;
else {
@ -3396,6 +3398,13 @@ nm_utils_fd_wait_for_event(int fd, int event, gint64 timeout_nsec)
return -NM_ERRNO_NATIVE(errno);
if (r == 0)
return 0;
nm_assert(r == 1);
nm_assert(pollfd.revents > 0);
if (pollfd.revents & POLLNVAL)
return nm_assert_unreachable_val(-EBADF);
return pollfd.revents;
}