[gdome] Bugfix: Wrong operator precedence bug in gdome_cast_evnt



Hi all,

I have discovered a bug in gdome:
The following code is in gdome-util.c
GdomeEvent *
gdome_cast_evnt (GdomeEvent *evt) {
        if (evt == NULL || !GDOME_XML_IS_EVNT(evt))
                return NULL;
  else
                return (GdomeEvent *)evt;
}

However, GDOME_XML_IS_EVNT is defined without outer brackets, and so the ! binds
to the wrong part of the expression, causing wrong code to be generated.

Patch below...

Best regards,
Andrew Miller

diff -budr gdome2-0.8.1-myfixes/libgdome/events/gdome-evt-util.h
gdome2-0.8.1-myfixes-eventfix/libgdome/events/gdome-evt-util.h
--- gdome2-0.8.1-myfixes/libgdome/events/gdome-evt-util.h       2001-11-23
06:54:21.000000000 +1300
+++ gdome2-0.8.1-myfixes-eventfix/libgdome/events/gdome-evt-util.h     
2006-03-16 10:19:51.217198954 +1300
@@ -32,8 +32,8 @@
 #define GDOME_XML_IS_EVNTL(evntl) 1

 #define GDOME_XML_IS_EVNT(evnt) \
-((Gdome_evt_Event *) evnt)->etype == GDOME_BASE_EVENT || \
-((Gdome_evt_Event *) evnt)->etype == GDOME_MUTATION_EVENT
+(((Gdome_evt_Event *) evnt)->etype == GDOME_BASE_EVENT || \
+ ((Gdome_evt_Event *) evnt)->etype == GDOME_MUTATION_EVENT)

 #define GDOME_XML_IS_MEVNT(mevnt) \
 ((Gdome_evt_Event *) mevnt)->etype == GDOME_MUTATION_EVENT


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



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