Possible bugs due to: warning: XXX may be used uninitialized in this function

Tomas Carnecky tom at dbservice.com
Sun Feb 1 17:35:54 PST 2009

While trying to fix some of the warnings that gcc generates when 
compiling the xserver, I came across two which appear to be real bugs. 
Since they don't appear to be trivial to fix, I'm posting them here for 
further review:

Xi/setbmap.c:110 in ProcXSetDeviceButtonMapping()

'DeviceIntPtr dev' seems indeed uninitialized and is passed to 

hw/xfree86/common/xf86Bus.c:2171 in x_isSubsetOf()

This one is a bit more complicated due to the use of macros, I'll list 
the relevant ones here:

typedef struct {
     unsigned long type;
     memType a;
     memType b;
} resRange, *resList;

#define RANGE(r,u,v,t) {\
                        (r).a = (u);\
                        (r).b = (v);\
                        (r).type = (t);\

#define rBase a
#define rMask b
#define rBegin a
#define rEnd b

The function uses 'range1.a' without having touched it anywhere before:

RANGE(range1, ((range.rBase & list->sparse_base)
     | (range.rBase & ~list->sparse_mask)
     | ((~list->sparse_base & list->sparse_mask)
         & ~range.rMask)) & range1.rMask,
     ((range.rMask | list->sparse_mask) & ~test)
     | (1 << i), range.type);


More information about the xorg mailing list