[rescue] $ for repair to 35 line X11 complete program

der Mouse mouse at Rodents-Montreal.ORG
Wed Jul 21 23:18:10 CDT 2010


> Same here.  I think this is it:
> http://www.io.com/~cjwyche/2010/20100718/trouble.html

I think so.

And the problem is very simple: XStoreColor does not return anything
useful.  Looking at XStoreColor's return value gives you meaningless
trash, probably whatever was lying around in some machine register or
other.

Most errors in X are not reported through return values (a few are, but
they are specifically called out as such in the documentation); if an
XStoreColor call provokes an error, then at some later point in the
program your error handler (see XSetErrorHandler) will get called with
an XErrorEvent giving the details.  The default error handler just
prints out some basic information about the error and exits.

If the API were being designed today, XStoreColor would probably be
declared as returning void.  But the X API predates the ability for
functions to "return" void; I noticed this because one of the things I
have done in the X tree I use is to go through and add such
declarations to the functions that deserve them.  So when I tried to
compile your program I got a "void value not ignored as it ought to be"
error, which pointed me to the problem immediately.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse at rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B



More information about the rescue mailing list