[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] EV_CHANGE_xxx macros
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] EV_CHANGE_xxx macros
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Tue, 26 Oct 2010 22:00:53 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 26 Oct 2010 22:00:58 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=t6Kyu6TRqc2Kqh2hofWiyDVV21r/XYaCnxoyhwJOdN0=; b=r/ZHF5COaPvF7VvwEnlLZGnCMoE/7+xrVPdNKmhyaRQjYadm9k8ogeuHI7N3e3ovH7 yhSB45TCogLPeDBSNhawZTrZ0IFNHEvv8HvZ4jeTrarVu8lRj9VnICzCG16hevvLsHXN YACAmcdYp96k9Q7S7LQYg8Vt6wQN7LMcd8Xp8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=KQ71buw7HfUJbliF9EbjgsN6lYgZxAE8uJU2r6mOlFMAXsI7CphU3rigRkp+u1w90P 4+3CUuBJXjXyhQXiD9dWTKdrYh2NjQRdMuCt64rORDUFIa7dK23qCAUTaYK5zKj4xgQX AIe24ZhqCFfoRZq3WImiWt1lDS0EQ9DvHeulk=
- In-reply-to: <008501cb7487$1c0e7e70$542b7b50$@com>
- References: <008501cb7487$1c0e7e70$542b7b50$@com>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Mon, Oct 25, 2010 at 4:56 PM, Gilad Benjamini
<gilad@xxxxxxxxxxxxxxxxx> wrote:
> The definition of the EV_CHANGE_xxx macros partially relies on the
> definition of a different set of macros (EV_SIGNAL, EV_PERSIST, etc.).
I'd have no objection to making the EV_CHANGE_xxx macros more
independent from the EV_* macros in 2.1. In particular, having
EV_CHANGE_ADD and EV_CHANGE_DEL not overlap with any used bits in EV_*
would be grand.
The point of having EV_CHANGELIST_{ET, PERSIST, SIGNAL} be the same as
EV_{ET,PERSIST,SIGNAL} was so that the code you mention below could
work without needing to do bit-by-bit reassignment of the "if (events
& EV_x) change->read_change |= EV_x" variety. Still, this should be
documented.
Patches welcome on the tracker as always, if somebody wants to work on this. ;)
> 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.
yrs,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.