An initialized EventNotifier must have a nonnegative descriptor. Callers
can use the initialized flag to represent an absent notifier instead of
initializing it with a negative fd.

Assert this precondition in event_notifier_init_fd() now that IOHub and
shadow virtqueues no longer pass negative placeholder descriptors.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
---
 util/event_notifier-posix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 34a2716dbf2..c6d2caaf9ff 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -27,6 +27,7 @@
  */
 void event_notifier_init_fd(EventNotifier *e, int fd)
 {
+    assert(fd >= 0);
     e->rfd = fd;
     e->wfd = fd;
     e->initialized = true;
-- 
2.43.0


Reply via email to