On Thu 05 May 2005 at 09:58:30 +0200, Richard Levitte - VMS Whacker wrote:
> As usual, patches are welcome!

I have another one. Gcc with default options has three warnings in
add_window.c, and they turn out to be bugs in the code.
I propose this patch:


--- add_window.c.dist   2005-05-04 12:33:03.000000000 +0200
+++ add_window.c        2005-05-05 13:37:38.000000000 +0200
@@ -395,7 +395,7 @@
        tmp_win->full_name, &tmp_win->class)) ? ONTOP_MAX : ONTOP_DEFAULT;
 
     tmp_win->titlehighlight = Scr->TitleHighlight && 
-       (!(short)(int) LookInList(Scr->NoTitleHighlight, tmp_win->full_name, 
+       (!LookInList(Scr->NoTitleHighlight, tmp_win->full_name, 
            &tmp_win->class));
 
     tmp_win->auto_raise = Scr->AutoRaiseDefault ||
@@ -412,12 +412,12 @@
     if (Scr->IconifyByUnmapping)
     {
        tmp_win->iconify_by_unmapping = iconm ? FALSE :
-           !(short)(int) LookInList(Scr->DontIconify, tmp_win->full_name,
+           !LookInList(Scr->DontIconify, tmp_win->full_name,
                &tmp_win->class);
     }
     tmp_win->iconify_by_unmapping |= 
-       (short)(int) LookInList(Scr->IconifyByUn, tmp_win->full_name,
-           &tmp_win->class);
+       LookInList(Scr->IconifyByUn, tmp_win->full_name,
+           &tmp_win->class) != NULL;
 
     if (LookInList (Scr->UnmapByMovingFarAway, tmp_win->full_name, 
&tmp_win->class))
        tmp_win->UnmapByMovingFarAway = True;


Rationale: LookInList() returns a pointer. If you cast it to int, you
lose bits (hence the warning on my Alpha). Casting to short makes it
even worse. This can never work right: if the pointer value happens to
be a multiple of 64K, suddenly the value is "false" instead of "true".

I don't know what the person thought when they were adding these casts;
perhaps they were trying to fix compiler warnings but they were going
about it entirely the wrong way.

> Richard
-Olaf.
-- 
___ Olaf 'Rhialto' Seibert                            --  rhialto/at/falu.nl
\X/ Hi! I'm a signature virus! Copy me to your .signature to help me spread!

Reply via email to