[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] EV_CHANGE_xxx macros



The definition of the EV_CHANGE_xxx macros partially relies on the
definition of a different set of macros (EV_SIGNAL, EV_PERSIST, etc.).
There are two issues I see with that.

First, both EV_CHANGE_ADD and EV_TIMEOUT are defined as 1, which might lead
to situations where a bit can be interpreted as two different things., e.g.
following this code in event_changelist_add
  if (events & (EV_READ|EV_SIGNAL)) {
    change->read_change = EV_CHANGE_ADD |
        (events & (EV_ET|EV_PERSIST|EV_SIGNAL));
  }
  if (events & EV_WRITE) {
    change->write_change = EV_CHANGE_ADD |
        (events & (EV_ET|EV_PERSIST|EV_SIGNAL));
  }

I haven't actually found any buggy scenario, but it is a bit fishy.

Second, the definitions combine constant values (e.g. 0x02) with macro usage
(e.g. EV_SIGNAL). This style easily allows human errors where two of these
macros will end up with the same value.

I don't know the code well enough to suggest a patch so I'll have to settle
for raising the issue.

Gilad

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.