glib-aux: add assertions to nm_utils_fd_wait_for_event()

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

View file

@ -3347,6 +3347,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 {
@ -3360,6 +3362,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;
}