[Xquartz-changes] xserver: Branch 'server-1.11-apple' - 42 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Apr 7 20:41:20 PDT 2011


Rebased ref, commits from common ancestor:
commit 88091820fe039de2bfda2be2ffef37af41819062
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Oct 30 14:55:06 2010 -0700

    configure.ac: Add -fno-strict-aliasing to CFLAGS
    
    This should address https://bugs.freedesktop.org/show_bug.cgi?id=31238
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 9e04ff0..e542135 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,12 @@ XORG_PROG_RAWCPP
 # easier overrides at build time.
 XSERVER_CFLAGS='$(CWARNFLAGS)'
 
+dnl Explicitly add -fno-strict-aliasing since this option should disappear
+dnl from util-macros CWARNFLAGS
+if  test "x$GCC" = xyes ; then
+    XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
+fi
+
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
 dnl ISDN trace program named dtrace
commit d2a5137d5b1da08696cf069d7660f5fcd5280318
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 12 19:48:52 2010 -0800

    fb: Revert fb changes that broke XQuartz
    
    http://bugs.freedesktop.org/show_bug.cgi?id=26124
    
    Revert "Fix source pictures getting random transforms after 2d6a8f668342a5190cdf43b5."
    Revert "fb: Adjust transform or composite coordinates for pixman operations"
    
    http://bugs.freedesktop.org/26124
    
    This reverts commit a72c65e9176c51de95db2fdbf4c5d946a4911695.
    This reverts commit a6bd5d2e482a5aa84acb3d4932e2a166d8670ef1.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/fb/fb.h b/fb/fb.h
index eaa21ad..e65a1c0 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2049,11 +2049,8 @@ fbFillRegionSolid (DrawablePtr	pDrawable,
 		   FbBits	xor);
 
 extern _X_EXPORT pixman_image_t *
-image_from_pict (PicturePtr	pict,
-		 Bool		has_clip,
-		 int		*xoff,
-		 int		*yoff);
-
+image_from_pict (PicturePtr pict,
+		 Bool       has_clip);
 extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
 
 #endif /* _FB_H_ */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 133f422..093ae90 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -50,24 +50,19 @@ fbComposite (CARD8      op,
 	     CARD16     height)
 {
     pixman_image_t *src, *mask, *dest;
-    int src_xoff, src_yoff;
-    int msk_xoff, msk_yoff;
-    int dst_xoff, dst_yoff;
     
     miCompositeSourceValidate (pSrc);
     if (pMask)
 	miCompositeSourceValidate (pMask);
     
-    src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
-    mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
-    dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict (pSrc, TRUE);
+    mask = image_from_pict (pMask, TRUE);
+    dest = image_from_pict (pDst, TRUE);
 
     if (src && dest && !(pMask && !mask))
     {
 	pixman_image_composite (op, src, mask, dest,
-				xSrc + src_xoff, ySrc + src_yoff,
-				xMask + msk_xoff, yMask + msk_yoff,
-				xDst + dst_xoff, yDst + dst_yoff,
+				xSrc, ySrc, xMask, yMask, xDst, yDst,
 				width, height);
     }
 
@@ -146,22 +141,22 @@ create_conical_gradient_image (PictGradient *gradient)
 
 static pixman_image_t *
 create_bits_picture (PicturePtr pict,
-		     Bool       has_clip,
-		     int	*xoff,
-		     int	*yoff)
+		     Bool       has_clip)
 {
-    PixmapPtr pixmap;
     FbBits *bits;
     FbStride stride;
-    int bpp;
+    int bpp, xoff, yoff;
     pixman_image_t *image;
     
-    fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff);
-    fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+
+    bits = (FbBits*)((CARD8*)bits +
+		     (pict->pDrawable->y + yoff) * stride * sizeof(FbBits) +
+		     (pict->pDrawable->x + xoff) * (bpp / 8));
 
     image = pixman_image_create_bits (
 	pict->format,
-	pixmap->drawable.width, pixmap->drawable.height,
+	pict->pDrawable->width, pict->pDrawable->height,
 	(uint32_t *)bits, stride * sizeof (FbStride));
     
     
@@ -187,55 +182,33 @@ create_bits_picture (PicturePtr pict,
 	if (pict->clientClipType != CT_NONE)
 	    pixman_image_set_has_client_clip (image, TRUE);
 
-	if (*xoff || *yoff)
-	    pixman_region_translate (pict->pCompositeClip, *xoff, *yoff);
+	pixman_region_translate (pict->pCompositeClip, - pict->pDrawable->x, - pict->pDrawable->y);
 
 	pixman_image_set_clip_region (image, pict->pCompositeClip);
 
-	if (*xoff || *yoff)
-	    pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff);
+	pixman_region_translate (pict->pCompositeClip, pict->pDrawable->x, pict->pDrawable->y);
     }
     
     /* Indexed table */
     if (pict->pFormat->index.devPrivate)
 	pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
 
-    /* Add in drawable origin to position within the image */
-    *xoff += pict->pDrawable->x;
-    *yoff += pict->pDrawable->y;
-
     return image;
 }
 
 static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map);
+image_from_pict_internal (PicturePtr pict, Bool has_clip, Bool is_alpha_map);
 
 static void
-set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+set_image_properties (pixman_image_t *image, PicturePtr pict, Bool is_alpha_map)
 {
     pixman_repeat_t repeat;
     pixman_filter_t filter;
     
     if (pict->transform)
     {
-	/* For source images, adjust the transform to account
-	 * for the drawable offset within the pixman image,
-	 * then set the offset to 0 as it will be used
-	 * to compute positions within the transformed image.
-	 */
-	if (!has_clip) {
-	    struct pixman_transform	adjusted;
-
-	    adjusted = *pict->transform;
-	    pixman_transform_translate(&adjusted,
-				       NULL,
-				       pixman_int_to_fixed(*xoff),
-				       pixman_int_to_fixed(*yoff));
-	    pixman_image_set_transform (image, &adjusted);
-	    *xoff = 0;
-	    *yoff = 0;
-	} else
-	    pixman_image_set_transform (image, pict->transform);
+	pixman_image_set_transform (
+	    image, (pixman_transform_t *)pict->transform);
     }
     
     switch (pict->repeatType)
@@ -265,8 +238,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
      */
     if (pict->alphaMap && !is_alpha_map)
     {
-	int alpha_xoff, alpha_yoff;
-	pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff, TRUE);
+	pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, TRUE, TRUE);
 	
 	pixman_image_set_alpha_map (
 	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
@@ -299,7 +271,8 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
 }
 
 static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+image_from_pict_internal (PicturePtr pict,
+		 Bool has_clip, Bool is_alpha_map)
 {
     pixman_image_t *image = NULL;
 
@@ -308,7 +281,7 @@ image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
 
     if (pict->pDrawable)
     {
-	image = create_bits_picture (pict, has_clip, xoff, yoff);
+	image = create_bits_picture (pict, has_clip);
     }
     else if (pict->pSourcePict)
     {
@@ -329,19 +302,18 @@ image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
 	    else if (sp->type == SourcePictTypeConical)
 		image = create_conical_gradient_image (gradient);
 	}
-	*xoff = *yoff = 0;
     }
     
     if (image)
-	set_image_properties (image, pict, has_clip, xoff, yoff, is_alpha_map);
+	set_image_properties (image, pict, is_alpha_map);
     
     return image;
 }
 
 pixman_image_t *
-image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+image_from_pict (PicturePtr pict, Bool has_clip)
 {
-    return image_from_pict_internal (pict, has_clip, xoff, yoff, FALSE);
+    return image_from_pict_internal (pict, has_clip, FALSE);
 }
 
 void
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index 2554fcc..06fbb22 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -37,8 +37,7 @@ fbAddTraps (PicturePtr	pPicture,
 	    int		ntrap,
 	    xTrap	*traps)
 {
-    int image_xoff, image_yoff;
-    pixman_image_t *image = image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
@@ -54,8 +53,7 @@ fbRasterizeTrapezoid (PicturePtr    pPicture,
 		      int	    x_off,
 		      int	    y_off)
 {
-    int	mask_xoff, mask_yoff;
-    pixman_image_t *image = image_from_pict (pPicture, FALSE, &mask_xoff, &mask_yoff);
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
@@ -74,7 +72,7 @@ fbAddTriangles (PicturePtr  pPicture,
 {
     int image_xoff, image_yoff;
     pixman_image_t *image =
-	image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
+	image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
@@ -110,8 +108,8 @@ fbShapes (CompositeShapesFunc	composite,
     int src_xoff, src_yoff;
     int dst_xoff, dst_yoff;
 
-    src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
-    dst = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict (pSrc, FALSE);
+    dst = image_from_pict (pDst, TRUE);
 
     if (src && dst)
     {
commit ae2695988567fec9e2b0ffdb4f581abc89c755b9
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Apr 30 13:08:25 2010 -0700

    Workaround the GC clipping problem in miPaintWindow and add some debugging output.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 94258b8..4f25c23 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -521,6 +521,7 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
+#include "../fb/fb.h"
 #endif 
 
 void
@@ -548,24 +549,37 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool	solid = TRUE;
     DrawablePtr	drawable = &pWin->drawable;
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
+	                               prgn->extents.x2 - prgn->extents.x1,
+	                               prgn->extents.y2 - prgn->extents.y1);
+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
+				       pWin->drawable.width, pWin->drawable.height);
+#endif
+
 #ifdef ROOTLESS
     if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
 	return;
-
-    if(IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-    
-        if(pWin->backgroundState == ParentRelative) {
-            if((what == PW_BACKGROUND) || 
-               (what == PW_BORDER && !pWin->borderIsPixel))
-                RootlessSetPixmapOfAncestors(pWin);
-        }
-    }
 #endif
     
     if (what == PW_BACKGROUND)
     {
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+
+	    if(pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	while (pWin->backgroundState == ParentRelative)
 	    pWin = pWin->parent;
 
@@ -587,6 +601,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     {
 	PixmapPtr   pixmap;
 
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(!pWin->borderIsPixel &&
+		pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	tile_x_off = drawable->x;
 	tile_y_off = drawable->y;
 	
@@ -595,6 +621,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 	    return;
 	pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
 	drawable = &pixmap->drawable;
+
+#ifdef XQUARTZ_CLIP_DEBUG
+	ErrorF("     Draw: %d %d %d %d\n",
+	       drawable->x, drawable->y, drawable->width, drawable->height);    
+#endif
+	
 #ifdef COMPOSITE
 	draw_x_off = pixmap->screen_x;
 	draw_y_off = pixmap->screen_y;
@@ -657,6 +689,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     ChangeGC (NullClient, pGC, gcmask, gcval);
     ValidateGC (drawable, pGC);
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
+#endif
+    
+#ifdef XQUARTZ
+    /* Looks like our clipping isn't set right for some reason:
+     * http://xquartz.macosforge.org/trac/ticket/290
+     */
+    if(what == PW_BORDER) {
+
+#if 0
+	if(solid) {
+#if 1
+	    fbFillRegionSolid(&pWin->drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       pWin->drawable.bitsPerPixel));
+#else
+	    fbFillRegionSolid(drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       drawable->bitsPerPixel));
+#endif
+	    return;
+	}
+#endif
+    
+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
+	
+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
+    }
+#endif
+
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
+#endif
+
     numRects = RegionNumRects(prgn);
     pbox = RegionRects(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
commit 7aad7dbf409eaa16a2c80d76ba2a42dc84501919
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 7 08:43:13 2011 +1000

    Xext: use EXT_MASK macro instead of manual & 0x7f
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xext/geext.c b/Xext/geext.c
index a6fbb09..18f8ffe 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -49,6 +49,7 @@ static const int version_requests[] = {
 static void SGEGenericEvent(xEvent* from, xEvent* to);
 
 #define NUM_VERSION_REQUESTS	(sizeof (version_requests) / sizeof (version_requests[0]))
+#define EXT_MASK(ext) ((ext) & 0x7F)
 
 /************************************************************/
 /*                request handlers                          */
@@ -191,8 +192,8 @@ SGEGenericEvent(xEvent* from, xEvent* to)
         return;
     }
 
-    if (GEExtensions[gefrom->extension & 0x7F].evswap)
-        GEExtensions[gefrom->extension & 0x7F].evswap(gefrom, geto);
+    if (GEExtensions[EXT_MASK(gefrom->extension)].evswap)
+        GEExtensions[EXT_MASK(gefrom->extension)].evswap(gefrom, geto);
 }
 
 /* Init extension, register at server.
@@ -241,11 +242,11 @@ void
 GERegisterExtension(int extension,
                     void (*ev_swap)(xGenericEvent* from, xGenericEvent* to))
 {
-    if ((extension & 0x7F) >=  MAXEXTENSIONS)
+    if (EXT_MASK(extension) >=  MAXEXTENSIONS)
         FatalError("GE: extension > MAXEXTENSIONS. This should not happen.\n");
 
     /* extension opcodes are > 128, might as well save some space here */
-    GEExtensions[extension & 0x7f].evswap = ev_swap;
+    GEExtensions[EXT_MASK(extension)].evswap = ev_swap;
 }
 
 
commit b28a1af55cf1ad2a882cc8cd73b77341dec7ff5a
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Wed Apr 6 14:51:45 2011 -0400

    Fix unset valuator handling for XI 1.x valuator events again
    
    Set the valuator values for unset masked absolute valuators in the
    internal device event. This ensures the values will always be correct in
    getValuatorEvents even if the device has been removed.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index a5fe0a9..14731f4 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -383,12 +383,12 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
     int i;
     int state = 0;
     int first_valuator, num_valuators;
-    DeviceIntPtr dev = NULL;
 
 
     num_valuators = countValuators(ev, &first_valuator);
     if (num_valuators > 0)
     {
+        DeviceIntPtr dev = NULL;
         dixLookupDevice(&dev, ev->deviceid, serverClient, DixUseAccess);
         /* State needs to be assembled BEFORE the device is updated. */
         state = (dev && dev->key) ? XkbStateFieldFromRec(&dev->key->xkbInfo->state) : 0;
@@ -405,14 +405,10 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
         xv->deviceid = ev->deviceid;
         xv->device_state = state;
 
-        for (j = 0; j < xv->num_valuators; j++) {
-            if (BitIsOn(ev->valuators.mask, xv->first_valuator + j))
-                valuators[j] = ev->valuators.data[xv->first_valuator + j];
-            else if (dev->valuator->axes[xv->first_valuator + j].mode == Absolute)
-                valuators[j] = dev->valuator->axisVal[xv->first_valuator + j];
-            else
-                valuators[j] = 0;
-        }
+        /* Unset valuators in masked valuator events have the proper data values
+         * in the case of an absolute axis in between two set valuators. */
+        for (j = 0; j < xv->num_valuators; j++)
+            valuators[j] = ev->valuators.data[xv->first_valuator + j];
 
         if (i + 6 < num_valuators)
             xv->deviceid |= MORE_EVENTS;
diff --git a/dix/getevents.c b/dix/getevents.c
index c3b7ced..644b388 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -205,6 +205,8 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
 {
     int i;
 
+    /* Set the data to the previous value for unset absolute axes. The values
+     * may be used when sent as part of an XI 1.x valuator event. */
     for (i = 0; i < valuator_mask_size(mask); i++)
     {
         if (valuator_mask_isset(mask, i))
@@ -216,6 +218,8 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
             event->valuators.data_frac[i] =
                 dev->last.remainder[i] * (1 << 16) * (1 << 16);
         }
+        else if (valuator_get_mode(dev, i) == Absolute)
+            event->valuators.data[i] = dev->valuator->axisVal[i];
     }
 }
 
commit 3085b178626c957854385c7a88a05ec3c7eb74f3
Merge: c9d89ce... 3c45b59...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 6 08:34:10 2011 -0700

    Merge remote-tracking branch 'jturney/master'

commit c9d89cec1407550cb2568f4cef146c93607bbae6
Merge: a52049d... bc61787...
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Apr 4 11:57:39 2011 -0700

    Merge remote-tracking branch 'vignatti/for-keith'

commit bc61787a20e7683cbc4dfa45fe855da98a8c0cd0
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 18:22:50 2011 +0300

    render: fix memory leaks in ProcRenderCompositeGlyphs
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Soren Sandmann <ssp at redhat.com>

diff --git a/render/render.c b/render/render.c
index 8ff8ee6..c5da6d7 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1372,8 +1372,10 @@ ProcRenderCompositeGlyphs (ClientPtr client)
     else
     {
 	listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec));
-	if (!listsBase)
-	    return BadAlloc;
+	if (!listsBase) {
+	    rc = BadAlloc;
+	    goto bail;
+	}
     }
     buffer = (CARD8 *) (stuff + 1);
     glyphs = glyphsBase;
@@ -1392,13 +1394,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
 					     GlyphSetType, client,
 					     DixUseAccess);
 		if (rc != Success)
-		{
-		    if (glyphsBase != glyphsLocal)
-			free(glyphsBase);
-		    if (listsBase != listsLocal)
-			free(listsBase);
-		    return rc;
-		}
+		    goto bail;
 	    }
 	    buffer += 4;
 	}
@@ -1436,8 +1432,10 @@ ProcRenderCompositeGlyphs (ClientPtr client)
 	    lists++;
 	}
     }
-    if (buffer > end)
-	return BadLength;
+    if (buffer > end) {
+	rc = BadLength;
+	goto bail;
+    }
 
     CompositeGlyphs (stuff->op,
 		     pSrc,
@@ -1448,13 +1446,14 @@ ProcRenderCompositeGlyphs (ClientPtr client)
 		     nlist,
 		     listsBase,
 		     glyphsBase);
+    rc = Success;
 
+bail:
     if (glyphsBase != glyphsLocal)
 	free(glyphsBase);
     if (listsBase != listsLocal)
 	free(listsBase);
-    
-    return Success;
+    return rc;
 }
 
 static int
commit 45b6667b651a0a26b17f64c9e99d70784045e4bf
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 17:17:40 2011 +0300

    xkb: fix fd leak in XkbDDXListComponent
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index 9623cb6..3d301d8 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -222,8 +222,10 @@ char	tmpname[PATH_MAX];
     list->nFound[what]= 0;
     free(buf);
     buf = malloc(PATH_MAX * sizeof(char));
-    if (!buf)
+    if (!buf) {
+        fclose(in);
         return BadAlloc;
+    }
     while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {
 	unsigned flags;
 	register unsigned int i;
commit 0b288c8738a97cf6aa3f36aa5c05e7ac2a5cbca8
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 16:54:14 2011 +0300

    dix: fix memory leak in ProcListExtensions
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/dix/extension.c b/dix/extension.c
index 6540b64..c7bbac5 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -353,9 +353,8 @@ ProcListExtensions(ClientPtr client)
     }
     WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply);
     if (reply.length)
-    {
         WriteToClient(client, total_length, buffer);
-        free(buffer);
-    }
+
+    free(buffer);
     return Success;
 }
commit 90e03ab026cd8ffdc6202e6b8bae119717ee8528
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 16:48:21 2011 +0300

    mi: fix memory leak in miZeroLine
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/mi/mizerline.c b/mi/mizerline.c
index 07cfbe1..7077b51 100644
--- a/mi/mizerline.c
+++ b/mi/mizerline.c
@@ -157,9 +157,11 @@ miZeroLine(
     list_len = (height >= width) ? height : width;
     pspanInit = malloc(list_len * sizeof(DDXPointRec));
     pwidthInit = malloc(list_len * sizeof(int));
-    if (!pspanInit || !pwidthInit)
+    if (!pspanInit || !pwidthInit) {
+	free(pspanInit);
+	free(pwidthInit);
 	return;
-
+    }
     Nspans = 0;
     new_span = TRUE;
     spans  = pspanInit - 1;
commit daae5e5de194757f7084f9b2b24353c34b961f19
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Mar 28 20:13:11 2011 +0300

    xi: fix memory leak in AddExtensionClient
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 5b207bc..18803c9 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1607,14 +1607,18 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
     if (!others)
 	return BadAlloc;
     if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
-	return BadAlloc;
+	goto bail;
     others->mask[mskidx] = mask;
     others->resource = FakeClientID(client->index);
     others->next = pWin->optional->inputMasks->inputClients;
     pWin->optional->inputMasks->inputClients = others;
     if (!AddResource(others->resource, RT_INPUTCLIENT, (pointer) pWin))
-	return BadAlloc;
+	goto bail;
     return Success;
+
+bail:
+    free(others);
+    return BadAlloc;
 }
 
 static Bool
commit c1875ac25b7b730d464c98c4c151c35efd64a562
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Mar 28 20:09:04 2011 +0300

    dix: fix memory leak in AllocShared
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/dix/colormap.c b/dix/colormap.c
index 188378b..0e1feb6 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -2105,6 +2105,7 @@ AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b,
 	{
 	    for (z++ ; z < npixShared; z++)
 		free(ppshared[z]);
+	    free(psharedList);
 	    return FALSE;
 	}
     }
commit 6e5020f46165862ff09211d5425c8b6a13966303
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Mar 28 20:07:06 2011 +0300

    dix: fix memory leak in AllocPseudo
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/dix/colormap.c b/dix/colormap.c
index 2e9a806..188378b 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -1879,6 +1879,7 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig,
 	{
 	    for (p = ppixTemp; p < ppixTemp + npix; p++)
 		pmap->red[*p].refcnt = 0;
+	    free(ppixTemp);
 	    return BadAlloc;
 	}
 	pmap->clientPixelsRed[client] = ppix;
commit a6c71ce5d2d2fe89e07a2ef5041c915acc3dc686
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Mar 28 19:21:28 2011 +0300

    os: fix memory and fd leaks in Popen
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/os/utils.c b/os/utils.c
index f47177f..36cb46f 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1315,6 +1315,9 @@ Popen(char *command, char *type)
     /* Ignore the smart scheduler while this is going on */
     old_alarm = OsSignal(SIGALRM, SIG_IGN);
     if (old_alarm == SIG_ERR) {
+      close(pdes[0]);
+      close(pdes[1]);
+      free(cur);
       perror("signal");
       return NULL;
     }
commit bafec9a25efa902bef2a3730dc44dc50f0e45877
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Mar 28 19:19:57 2011 +0300

    os: use DebugF for debugging
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>

diff --git a/os/utils.c b/os/utils.c
index a365aca..f47177f 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1256,10 +1256,7 @@ System(char *command)
       perror("signal");
       return -1;
     }
-
-#ifdef DEBUG
-    ErrorF("System: `%s'\n", command);
-#endif
+    DebugF("System: `%s'\n", command);
 
     switch (pid = fork()) {
     case -1:	/* error */
@@ -1371,9 +1368,7 @@ Popen(char *command, char *type)
     cur->next = pidlist;
     pidlist = cur;
 
-#ifdef DEBUG
-    ErrorF("Popen: `%s', fp = %p\n", command, iop);
-#endif
+    DebugF("Popen: `%s', fp = %p\n", command, iop);
 
     return iop;
 }
@@ -1448,9 +1443,7 @@ Fopen(char *file, char *type)
     cur->next = pidlist;
     pidlist = cur;
 
-#ifdef DEBUG
-    ErrorF("Fopen(%s), fp = %p\n", file, iop);
-#endif
+    DebugF("Fopen(%s), fp = %p\n", file, iop);
 
     return iop;
 #else
@@ -1479,10 +1472,7 @@ Pclose(pointer iop)
     int pstat;
     int pid;
 
-#ifdef DEBUG
-    ErrorF("Pclose: fp = %p\n", iop);
-#endif
-
+    DebugF("Pclose: fp = %p\n", iop);
     fclose(iop);
 
     for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
commit 719b37c33a89d6ad86c79097e5c67b9b3cea5aac
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 20:04:24 2011 +0300

    xfree86: fix memory leak in xf86LoadModules
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index e664ce4..0b36163 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1414,8 +1414,10 @@ xf86LoadModules(char **list, pointer *optlist)
 	name = xf86NormalizeName(list[i]);
 
 	/* Skip empty names */
-	if (name == NULL || *name == '\0')
+	if (name == NULL || *name == '\0') {
+	    free(name);
 	    continue;
+	}
 
 	/* Replace obsolete keyboard driver with kbd */
 	if (!xf86NameCmp(name, "keyboard")) {
commit af054db005b48160b117dfd5bec5f821ee614ea9
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 19:51:23 2011 +0300

    xfree86: fix bad free configInputDevices
    
    introduced in 93ca526892c0d22afa05cce6496198c652043a19.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 7a23253..114bdc3 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1459,8 +1459,9 @@ configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
     while (irp) {
 	indp[count] = xf86AllocateInput();
 	if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
-	    while(count--)
+	    do {
 		free(indp[count]);
+	    } while(count--);
 	    free(indp);
 	    return FALSE;
 	}
commit ac2fac24d8baa56f369f4e54908bc00c2b73a60a
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 29 19:49:32 2011 +0300

    xfree86: fix memory leaks in configLayout
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 4b897a1..7a23253 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1485,7 +1485,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
 {
     XF86ConfAdjacencyPtr adjp;
     XF86ConfInactivePtr idp;
-    int count = 0;
+    int saved_count, count = 0;
     int scrnum;
     XF86ConfLayoutPtr l;
     MessageType from;
@@ -1553,6 +1553,9 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
 	    scrnum = adjp->adj_scrnum;
 	if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
 			  X_CONFIG)) {
+	    do {
+		free(slp[count].screen);
+	    } while(count--);
 	    free(slp);
 	    return FALSE;
 	}
@@ -1641,6 +1644,10 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
 	}
     }
 
+    if (!count)
+	saved_count = 1;
+    else
+	saved_count = count;
     /*
      * Count the number of inactive devices.
      */
@@ -1657,16 +1664,14 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
     idp = conf_layout->lay_inactive_lst;
     count = 0;
     while (idp) {
-	if (!configDevice(&gdp[count], idp->inactive_device, FALSE)) {
-	    free(gdp);
-	    return FALSE;
-	}
+	if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+	    goto bail;
         count++;
         idp = (XF86ConfInactivePtr)idp->list.next;
     }
 
     if (!configInputDevices(conf_layout, servlayoutp))
-	return FALSE;
+	goto bail;
 
     servlayoutp->id = conf_layout->lay_identifier;
     servlayoutp->screens = slp;
@@ -1675,6 +1680,14 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
     from = X_DEFAULT;
 
     return TRUE;
+
+bail:
+    do {
+	free(slp[saved_count].screen);
+    } while(saved_count--);
+    free(slp);
+    free(gdp);
+    return FALSE;
 }
 
 /*
commit bc123319206930638ef1217922824d586d4ada6d
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 22:21:21 2011 +0200

    xfree86: fix memory leak in xf86ConfigFbEntity
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 3998838..3cdffdb 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1831,6 +1831,7 @@ xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
 
     xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
 
+    free(pEnt);
     return pScrn;
 }
 
commit 2aa935bc5cc1e2d5365a97b8c5bb3d33eb5fc758
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 22:10:55 2011 +0200

    fb: fix memory leak in fbOverlayFinishScreenInit
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 61eaaa3..255cc23 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -384,12 +384,16 @@ fbOverlayFinishScreenInit(ScreenPtr	pScreen,
    
     if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
 			&defaultVisual, ((unsigned long)1<<(bpp1-1)) |
-			((unsigned long)1<<(bpp2-1)), 8))
+			((unsigned long)1<<(bpp2-1)), 8)) {
+	free(pScrPriv);
 	return FALSE;
+    }
     if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0,
 			depth1, ndepths, depths,
-			defaultVisual, nvisuals, visuals))
+			defaultVisual, nvisuals, visuals)) {
+	free(pScrPriv);
 	return FALSE;
+    }
     /* MI thinks there's no frame buffer */
 #ifdef MITSHM
     ShmRegisterFbFuncs(pScreen);
commit 4d87606a0d0eb63458098028c300c39c6f1bd2bf
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 22:07:44 2011 +0200

    Xi: fix memory leak in ProcXGetSelectedExtensionEvents
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/getselev.c b/Xi/getselev.c
index 09a53f4..7304738 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -152,8 +152,8 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
     if (total_length) {
 	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 	WriteSwappedDataToClient(client, total_length, buf);
-	free(buf);
     }
+    free(buf);
     return Success;
 }
 
commit 12e46e83733b47d2704e1509960192365102af46
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 22:07:31 2011 +0200

    dix: fix memory leak in SetDefaultFontPath
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 71689cf..fbac124 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1815,8 +1815,10 @@ SetDefaultFontPath(char *path)
     /* get enough for string, plus values -- use up commas */
     len = strlen(temp_path) + 1;
     nump = cp = newpath = malloc(len);
-    if (!newpath)
+    if (!newpath) {
+	free(temp_path);
 	return BadAlloc;
+    }
     pp = (unsigned char *) temp_path;
     cp++;
     while (*pp) {
commit 7ae46b69ba3f05f46529131e6a864904967cde3a
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 21:33:15 2011 +0200

    mi: fix memory leak in miFillUniqueSpanGroup
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/mi/mispans.c b/mi/mispans.c
index 53539e5..21ba4da 100644
--- a/mi/mispans.c
+++ b/mi/mispans.c
@@ -458,6 +458,8 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup)
 			    }
 			    free(yspans);
 			    free(ysizes);
+			    free(newpoints);
+			    free(newwidths);
 			    miDisposeSpanGroup (spanGroup);
 			    return;
 			}
commit 623bb34342641811e2151232f1ab4e2ee3d6b871
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 19:27:17 2011 +0200

    xi: fix memory leak in ProcXIQueryDevice
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 8b54211..8b69904 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -107,8 +107,10 @@ ProcXIQueryDevice(ClientPtr client)
     }
 
     info = calloc(1, len);
-    if (!info)
+    if (!info) {
+        free(skip);
         return BadAlloc;
+    }
 
     memset(&rep, 0, sizeof(xXIQueryDeviceReply));
     rep.repType = X_Reply;
commit dce2f10cf7bef9929cefadb5088d5b66df43a865
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 19:21:03 2011 +0200

    mi: fix memory leak in miInitVisuals
    
    Free the pointers inside miInitVisuals, so the callers of this function
    (fboverlay.c and fbscreen.c) don't need to worry with deallocation in the case
    of failure.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index fa518f6..9e6ecf5 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -221,11 +221,7 @@ fbFinishScreenInit(ScreenPtr	pScreen,
     rootdepth = 0;
     if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
 			&defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
-    {
-	free(visuals);
-	free(depths);
 	return FALSE;
-    }
     if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 			rootdepth, ndepths, depths,
 			defaultVisual, nvisuals, visuals))
diff --git a/mi/micmap.c b/mi/micmap.c
index 41e0300..7448ef8 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -564,6 +564,8 @@ miInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp,
 	{
 	    vid = malloc(nvtype * sizeof (VisualID));
 	    if (!vid) {
+	        free(depth);
+	        free(visual);
 		free(preferredCVCs);
 		return FALSE;
 	    }
commit 8ab92cd9822510f426d179a636ef34bb0ace3bb3
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 18:56:02 2011 +0200

    xfree86: dri2: fix memory leak and free resources properly
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 9ca378f..10be599 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -221,11 +221,16 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
     if (ref == NULL)
 	return BadAlloc;
 	
-    if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
+    if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
+	free(ref);
 	return BadAlloc;
+    }
     if (!DRI2LookupDrawableRef(pPriv, id))
-	if (!AddResource(id, dri2DrawableRes, pPriv))
+	if (!AddResource(id, dri2DrawableRes, pPriv)) {
+	    FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
+	    free(ref);
 	    return BadAlloc;
+        }
 
     ref->id = id;
     ref->dri2_id = dri2_id; 
commit aa7096ca6f108e399d9916639cf20c57f9776305
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Mar 25 18:24:34 2011 +0200

    xorg: remove unused pointer values all over the server
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/xtest.c b/Xext/xtest.c
index b26bc33..6780aa6 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -374,10 +374,7 @@ ProcXTestFakeInput(ClientPtr client)
             if (!dev->valuator)
                 return BadDevice;
 
-            /* broken lib, XI events have root uninitialized */
-            if (extension || ev->u.keyButtonPointer.root == None)
-                root = GetCurrentRootWindow(dev);
-            else
+            if (!(extension || ev->u.keyButtonPointer.root == None))
             {
                 rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root,
                                      client, DixGetAttrAccess);
diff --git a/Xi/getprop.c b/Xi/getprop.c
index ba98fc8..5e10262 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -115,7 +115,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
 
     if ((others = wOtherInputMasks(pWin)) != 0) {
 	for (i = 0; i < EMASKSIZE; i++)
-	    tbuf = ClassFromMask(NULL, others->dontPropagateMask[i], i,
+	    ClassFromMask(NULL, others->dontPropagateMask[i], i,
 				 &count, COUNT);
 	if (count) {
 	    rep.count = count;
diff --git a/Xi/getselev.c b/Xi/getselev.c
index d63b661..09a53f4 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -118,13 +118,13 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
     if ((pOthers = wOtherInputMasks(pWin)) != 0) {
 	for (others = pOthers->inputClients; others; others = others->next)
 	    for (i = 0; i < EMASKSIZE; i++)
-		tclient = ClassFromMask(NULL, others->mask[i], i,
+		ClassFromMask(NULL, others->mask[i], i,
 					&rep.all_clients_count, COUNT);
 
 	for (others = pOthers->inputClients; others; others = others->next)
 	    if (SameClient(others, client)) {
 		for (i = 0; i < EMASKSIZE; i++)
-		    tclient = ClassFromMask(NULL, others->mask[i], i,
+		    ClassFromMask(NULL, others->mask[i], i,
 					    &rep.this_client_count, COUNT);
 		break;
 	    }
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 5312ca6..4b897a1 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -309,7 +309,7 @@ xf86ModulelistFromConfig(pointer **optlist)
             }
             if (found == FALSE) {
 		XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
-	            ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+                xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
                 xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name);
             }
          }
@@ -318,7 +318,7 @@ xf86ModulelistFromConfig(pointer **optlist)
 	for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
 	    if (ModuleDefaults[i].toLoad == TRUE) {
 		XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
-		ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+		xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
 	    }
 	}
     }
diff --git a/mi/midispcur.c b/mi/midispcur.c
index 9b3e87a..32c5c9d 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -397,7 +397,6 @@ Bool
 miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
                  int x, int y, unsigned long source, unsigned long mask)
 {
-    miDCScreenPtr   pScreenPriv;
     miDCCursorPtr   pPriv;
     miDCBufferPtr   pBuffer;
     WindowPtr	    pWin;
@@ -410,8 +409,7 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 	if (!pPriv)
 	    return FALSE;
     }
-    pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
-						  miDCScreenKey);
+
     pWin = pScreen->root;
     pBuffer = miGetDCDevice(pDev, pScreen);
 
@@ -444,14 +442,11 @@ Bool
 miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
                      int x, int y, int w, int h)
 {
-    miDCScreenPtr   pScreenPriv;
     miDCBufferPtr   pBuffer;
     PixmapPtr	    pSave;
     WindowPtr	    pWin;
     GCPtr	    pGC;
 
-    pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
-						  miDCScreenKey);
     pBuffer = miGetDCDevice(pDev, pScreen);
 
     pSave = pBuffer->pSave;
@@ -478,14 +473,11 @@ Bool
 miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
                         int x, int y, int w, int h)
 {
-    miDCScreenPtr   pScreenPriv;
     miDCBufferPtr   pBuffer;
     PixmapPtr	    pSave;
     WindowPtr	    pWin;
     GCPtr	    pGC;
 
-    pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
-						  miDCScreenKey);
     pBuffer = miGetDCDevice(pDev, pScreen);
     pSave = pBuffer->pSave;
 
diff --git a/mi/mipointer.c b/mi/mipointer.c
index c578d0b..db24381 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -602,7 +602,6 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
 		pScreen = newScreen;
 		(*pScreenPriv->screenFuncs->NewEventScreen) (pDev, pScreen,
 							     FALSE);
-		pScreenPriv = GetScreenPrivate (pScreen);
 	    	/* Smash the confine to the new screen */
                 pPointer->limits.x2 = pScreen->width;
                 pPointer->limits.y2 = pScreen->height;
diff --git a/xfixes/region.c b/xfixes/region.c
index 81ead4d..f493496 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -757,13 +757,11 @@ ProcXFixesSetPictureClipRegion (ClientPtr client)
     PicturePtr		pPicture;
     RegionPtr		pRegion;
     ScreenPtr		pScreen;
-    PictureScreenPtr	ps;
     REQUEST(xXFixesSetPictureClipRegionReq);
     
     REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
     VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
     pScreen = pPicture->pDrawable->pScreen;
-    ps = GetPictureScreen (pScreen);
     VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess);
     
     return SetPictureClipRegion (pPicture, stuff->xOrigin, stuff->yOrigin,
commit 49051355d47849b3dd73631e3e2287e319a7f4e5
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed Mar 23 18:08:29 2011 +0200

    dix: remove unused macro
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 316a8a5..71689cf 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -70,8 +70,6 @@ Equipment Corporation.
 #include "xf86bigfontsrv.h"
 #endif
 
-#define QUERYCHARINFO(pci, pr)  *(pr) = (pci)->metrics
-
 extern pointer fosNaturalParams;
 extern FontPtr defaultFont;
 
commit f1a80e1268fa4d235a411a8cdf20b4f13eafcde0
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed Mar 23 18:06:51 2011 +0200

    dix: remove unused debug code
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index d8f1529..316a8a5 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -66,10 +66,6 @@ Equipment Corporation.
 #include "dixfont.h"
 #include "xace.h"
 
-#ifdef DEBUG
-#include	<stdio.h>
-#endif
-
 #ifdef XF86BIGFONT
 #include "xf86bigfontsrv.h"
 #endif
@@ -391,14 +387,6 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna
     int         i;
     FontPtr     cached = (FontPtr)0;
 
-#ifdef FONTDEBUG
-    char *f;
-    f = malloc(lenfname + 1);
-    memmove(f, pfontname, lenfname);
-    f[lenfname] = '\0';
-    ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f);
-    free(f);
-#endif
     if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
 	return BadName;
     if (patternCache)
commit a52049de2f846fe984d4db5ac8d2c1826c7b2d0b
Merge: d044d36... 266ea63...
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Apr 4 09:58:53 2011 +1000

    Merge branch 'master' of git://people.freedesktop.org/~herrb/xserver into for-keith

commit d044d3675635f037bf0eb30e47f82460f78227d1
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu Mar 31 16:26:06 2011 +0300

    xfree86: loader: fix memory leaks in LoaderListDirs
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Nicolas Peninguy <nico at lostgeeks.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index eaa99e8..46ce68b 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -532,6 +532,7 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
 				FreePathList(pathlist);
 				FreeSubdirs(subdirs);
 				FreePatterns(patterns);
+				closedir(d);
 				return NULL;
 			    }
 			    listing[n] = malloc(len + 1);
@@ -540,6 +541,7 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
 				FreePathList(pathlist);
 				FreeSubdirs(subdirs);
 				FreePatterns(patterns);
+				closedir(d);
 				return NULL;
 			    }
 			    strncpy(listing[n], dp->d_name + match[1].rm_so,
@@ -556,6 +558,10 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
     }
     if (listing)
 	listing[n] = NULL;
+
+    FreePathList(pathlist);
+    FreeSubdirs(subdirs);
+    FreePatterns(patterns);
     return listing;
 }
 
commit 9c4aae2141161e4bf69313a771db91c0acc4cc83
Author: Rami Ylimäki <rami.ylimaki at vincit.fi>
Date:   Wed Mar 30 16:47:31 2011 +0300

    xkb: Prevent leaking of XKB geometry information on copy.
    
    Currently shapes, sections and doodads may leak on copy.
    
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
    Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index a80a8d8..cc9aaa7 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1541,10 +1541,10 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
         }
 
         if (src->geom->num_shapes) {
-            tmp = calloc(src->geom->num_shapes, sizeof(XkbShapeRec));
-            if (!tmp)
+            /* Reallocate and clear all items. */
+            if (!XkbGeomRealloc((void **)&dst->geom->shapes, dst->geom->sz_shapes, src->geom->num_shapes,
+                                sizeof(XkbShapeRec), XKB_GEOM_CLEAR_ALL))
                 return FALSE;
-            dst->geom->shapes = tmp;
 
             for (i = 0, sshape = src->geom->shapes, dshape = dst->geom->shapes;
                  i < src->geom->num_shapes;
@@ -1661,7 +1661,6 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
             }
 
             dst->geom->num_sections = 0;
-            dst->geom->sections = NULL;
         }
 
         if (src->geom->num_sections) {
@@ -1771,7 +1770,6 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
                 }
             }
             dst->geom->num_doodads = 0;
-            dst->geom->doodads = NULL;
         }
 
         if (src->geom->num_doodads) {
commit 29d63ba175ff1ef1587c390b18ce61c8f1c150f3
Author: Rami Ylimäki <rami.ylimaki at vincit.fi>
Date:   Wed Mar 30 16:47:30 2011 +0300

    xkb: Introduce helper function to handle similar reallocations.
    
    This is preparation for a memory leak fix and doesn't contain any
    functional changes.
    
    Note that two variables are generally used for reallocation and
    clearing of arrays: geom->sz_elems (reallocation) and geom->num_elems
    (clearing). The interface of XkbGeomRealloc is deliberately kept
    simple and it only accepts geom->sz_elems as argument, because that is
    needed to determine whether the array needs to be resized. When the
    array is cleared, we just assume that either geom->sz_elems and
    geom->num_elems are synchronized to be equal or that unused elements
    are cleared whenever geom->num_elems is set to be less than
    geom->sz_elems without reallocation.
    
    Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
    Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index 65f92fd..dd2b046 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -435,6 +435,57 @@ XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
 
 /***====================================================================***/
 
+/**
+ * Resize and clear an XKB geometry item array. The array size may
+ * grow or shrink unlike in _XkbGeomAlloc.
+ *
+ * @param buffer[in,out]  buffer to reallocate and clear
+ * @param szItems[in]     currently allocated item count for "buffer"
+ * @param nrItems[in]     required item count for "buffer"
+ * @param itemSize[in]    size of a single item in "buffer"
+ * @param clearance[in]   items to clear after reallocation
+ *
+ * @see _XkbGeomAlloc
+ *
+ * @return TRUE if reallocation succeeded. Otherwise FALSE is returned
+ *         and contents of "buffer" aren't touched.
+ */
+Bool
+XkbGeomRealloc(void **buffer, int szItems, int nrItems,
+               int itemSize, XkbGeomClearance clearance)
+{
+    void *items;
+    int clearBegin;
+    /* Check validity of arguments. */
+    if (!buffer)
+        return FALSE;
+    items = *buffer;
+    if (!((items && (szItems > 0)) || (!items && !szItems)))
+        return FALSE;
+    /* Check if there is need to resize. */
+    if (nrItems != szItems)
+        if (!(items = realloc(items, nrItems * itemSize)))
+            return FALSE;
+    /* Clear specified items to zero. */
+    switch (clearance)
+    {
+    case XKB_GEOM_CLEAR_EXCESS:
+        clearBegin = szItems;
+        break;
+    case XKB_GEOM_CLEAR_ALL:
+        clearBegin = 0;
+        break;
+    case XKB_GEOM_CLEAR_NONE:
+    default:
+        clearBegin = nrItems;
+        break;
+    }
+    if (items && (clearBegin < nrItems))
+        memset((char *)items + (clearBegin * itemSize), 0, (nrItems - clearBegin) * itemSize);
+    *buffer = items;
+    return TRUE;
+}
+
 static Status
 _XkbGeomAlloc(	void **		old,
 		unsigned short *	num,
@@ -451,18 +502,15 @@ _XkbGeomAlloc(	void **		old,
 	return Success;
 
     *total= (*num)+num_new;
-    if ((*old)!=NULL)
-	 (*old)= realloc((*old),(*total)*sz_elem);
-    else (*old)= calloc((*total),sz_elem);
-    if ((*old)==NULL) {
+
+    if (!XkbGeomRealloc(old, *num, *total, sz_elem, XKB_GEOM_CLEAR_EXCESS))
+    {
+	free(*old);
+	(*old)= NULL;
 	*total= *num= 0;
 	return BadAlloc;
     }
 
-    if (*num>0) {
-	char *tmp= (char *)(*old);
-	memset(&tmp[sz_elem*(*num)], 0, (num_new*sz_elem));
-    }
     return Success;
 }
 
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 3a56bea..a80a8d8 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1398,42 +1398,26 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
 
         /* properties */
         if (src->geom->num_properties) {
-            if (src->geom->num_properties != dst->geom->sz_properties) {
-                /* If we've got more properties in the destination than
-                 * the source, run through and free all the excess ones
-                 * first. */
-                if (src->geom->num_properties < dst->geom->sz_properties) {
-                    for (i = src->geom->num_properties,
-                         dprop = dst->geom->properties + i;
-                         i < dst->geom->num_properties;
-                         i++, dprop++) {
-                        free(dprop->name);
-                        free(dprop->value);
-                    }
+            /* If we've got more properties in the destination than
+             * the source, run through and free all the excess ones
+             * first. */
+            if (src->geom->num_properties < dst->geom->sz_properties) {
+                for (i = src->geom->num_properties, dprop = dst->geom->properties + i;
+                     i < dst->geom->num_properties;
+                     i++, dprop++) {
+                    free(dprop->name);
+                    free(dprop->value);
                 }
-
-                if (dst->geom->sz_properties)
-                    tmp = realloc(dst->geom->properties,
-                                   src->geom->num_properties *
-                                    sizeof(XkbPropertyRec));
-                else
-                    tmp = malloc(src->geom->num_properties *
-                                  sizeof(XkbPropertyRec));
-                if (!tmp)
-                    return FALSE;
-                dst->geom->properties = tmp;
             }
 
+            /* Reallocate and clear all new items if the buffer grows. */
+            if (!XkbGeomRealloc((void **)&dst->geom->properties, dst->geom->sz_properties, src->geom->num_properties,
+                                sizeof(XkbPropertyRec), XKB_GEOM_CLEAR_EXCESS))
+                return FALSE;
             /* We don't set num_properties as we need it to try and avoid
              * too much reallocing. */
             dst->geom->sz_properties = src->geom->num_properties;
 
-            if (dst->geom->sz_properties > dst->geom->num_properties) {
-                memset(dst->geom->properties + dst->geom->num_properties, 0,
-                      (dst->geom->sz_properties - dst->geom->num_properties) *
-                      sizeof(XkbPropertyRec));
-            }
-
             for (i = 0,
                   sprop = src->geom->properties,
                   dprop = dst->geom->properties;
@@ -1482,36 +1466,20 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
 
         /* colors */
         if (src->geom->num_colors) {
-            if (src->geom->num_colors != dst->geom->sz_colors) {
-                if (src->geom->num_colors < dst->geom->sz_colors) {
-                    for (i = src->geom->num_colors,
-                         dcolor = dst->geom->colors + i;
-                         i < dst->geom->num_colors;
-                         i++, dcolor++) {
-                        free(dcolor->spec);
-                    }
+            if (src->geom->num_colors < dst->geom->sz_colors) {
+                for (i = src->geom->num_colors, dcolor = dst->geom->colors + i;
+                     i < dst->geom->num_colors;
+                     i++, dcolor++) {
+                    free(dcolor->spec);
                 }
-
-                if (dst->geom->sz_colors)
-                    tmp = realloc(dst->geom->colors,
-                                   src->geom->num_colors *
-                                    sizeof(XkbColorRec));
-                else
-                    tmp = malloc(src->geom->num_colors *
-                                  sizeof(XkbColorRec));
-                if (!tmp)
-                    return FALSE;
-                dst->geom->colors = tmp;
             }
 
+            /* Reallocate and clear all new items if the buffer grows. */
+            if (!XkbGeomRealloc((void **)&dst->geom->colors, dst->geom->sz_colors, src->geom->num_colors,
+                                sizeof(XkbColorRec), XKB_GEOM_CLEAR_EXCESS))
+                return FALSE;
             dst->geom->sz_colors = src->geom->num_colors;
 
-            if (dst->geom->sz_colors > dst->geom->num_colors) {
-                memset(dst->geom->colors + dst->geom->num_colors, 0,
-                      (dst->geom->sz_colors - dst->geom->num_colors) *
-                      sizeof(XkbColorRec));
-            }
-
             for (i = 0,
                   scolor = src->geom->colors,
                   dcolor = dst->geom->colors;
@@ -1697,16 +1665,10 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
         }
 
         if (src->geom->num_sections) {
-            if (dst->geom->sz_sections)
-                tmp = realloc(dst->geom->sections,
-                               src->geom->num_sections *
-                                sizeof(XkbSectionRec));
-            else
-                tmp = malloc(src->geom->num_sections * sizeof(XkbSectionRec));
-            if (!tmp)
+            /* Reallocate and clear all items. */
+            if (!XkbGeomRealloc((void **)&dst->geom->sections, dst->geom->sz_sections, src->geom->num_sections,
+                                sizeof(XkbSectionRec), XKB_GEOM_CLEAR_ALL))
                 return FALSE;
-            memset(tmp, 0, src->geom->num_sections * sizeof(XkbSectionRec));
-            dst->geom->sections = tmp;
             dst->geom->num_sections = src->geom->num_sections;
             dst->geom->sz_sections = src->geom->num_sections;
 
@@ -1813,17 +1775,10 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
         }
 
         if (src->geom->num_doodads) {
-            if (dst->geom->sz_doodads)
-                tmp = realloc(dst->geom->doodads,
-                               src->geom->num_doodads *
-                                sizeof(XkbDoodadRec));
-            else
-                tmp = malloc(src->geom->num_doodads *
-                              sizeof(XkbDoodadRec));
-            if (!tmp)
+            /* Reallocate and clear all items. */
+            if (!XkbGeomRealloc((void **)&dst->geom->doodads, dst->geom->sz_doodads, src->geom->num_doodads,
+                                sizeof(XkbDoodadRec), XKB_GEOM_CLEAR_ALL))
                 return FALSE;
-            memset(tmp, 0, src->geom->num_doodads * sizeof(XkbDoodadRec));
-            dst->geom->doodads = tmp;
 
             dst->geom->sz_doodads = src->geom->num_doodads;
 
@@ -1860,20 +1815,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
 
         /* key aliases */
         if (src->geom->num_key_aliases) {
-            if (src->geom->num_key_aliases != dst->geom->sz_key_aliases) {
-                if (dst->geom->sz_key_aliases)
-                    tmp = realloc(dst->geom->key_aliases,
-                                   src->geom->num_key_aliases *
-                                    2 * XkbKeyNameLength);
-                else
-                    tmp = malloc(src->geom->num_key_aliases *
-                                  2 * XkbKeyNameLength);
-                if (!tmp)
-                    return FALSE;
-                dst->geom->key_aliases = tmp;
+            /* Reallocate but don't clear any items. There is no need
+             * to clear anything because data is immediately copied
+             * over the whole memory area with memcpy. */
+            if (!XkbGeomRealloc((void **)&dst->geom->key_aliases, dst->geom->sz_key_aliases, src->geom->num_key_aliases,
+                                2 * XkbKeyNameLength, XKB_GEOM_CLEAR_NONE))
+                return FALSE;
 
-                dst->geom->sz_key_aliases = src->geom->num_key_aliases;
-            }
+            dst->geom->sz_key_aliases = src->geom->num_key_aliases;
 
             memcpy(dst->geom->key_aliases, src->geom->key_aliases,
                    src->geom->num_key_aliases * 2 * XkbKeyNameLength);
diff --git a/xkb/xkbgeom.h b/xkb/xkbgeom.h
index fe4da38..d10b956 100644
--- a/xkb/xkbgeom.h
+++ b/xkb/xkbgeom.h
@@ -311,6 +311,17 @@ typedef struct _XkbGeometrySizes {
 	unsigned short	num_key_aliases;
 } XkbGeometrySizesRec,*XkbGeometrySizesPtr;
 
+/**
+ * Specifies which items should be cleared in an XKB geometry array
+ * when the array is reallocated.
+ */
+typedef enum
+{
+    XKB_GEOM_CLEAR_NONE,   /* Don't clear any items, just reallocate.   */
+    XKB_GEOM_CLEAR_EXCESS, /* Clear new extra items after reallocation. */
+    XKB_GEOM_CLEAR_ALL     /* Clear all items after reallocation.       */
+} XkbGeomClearance;
+
 extern	XkbPropertyPtr
 XkbAddGeomProperty(
     XkbGeometryPtr	/* geom */,
@@ -507,6 +518,15 @@ XkbFreeGeometry(
     Bool		/* freeMap */
 );
 
+extern Bool
+XkbGeomRealloc(
+    void **		/* buffer */,
+    int			/* szItems */,
+    int			/* nrItems */,
+    int			/* itemSize */,
+    XkbGeomClearance	/* clearance */
+);
+
 extern Status
 XkbAllocGeomProps(
     XkbGeometryPtr	/* geom */,
commit f40103cee1d591387359f401a5a7c21f4105aeb4
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Thu Mar 31 11:29:01 2011 -0400

    Don't report old relative values in getValuatorEvents
    
    Relative valuator values should not be reported in any future events. If
    a relative valuator value is not set in an internal event, set the value
    to 0 for XI 1.x valuator events sent over the wire.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Simon Thum <simon.thum at gmx.de>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 5fdd357..a5fe0a9 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -408,8 +408,10 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
         for (j = 0; j < xv->num_valuators; j++) {
             if (BitIsOn(ev->valuators.mask, xv->first_valuator + j))
                 valuators[j] = ev->valuators.data[xv->first_valuator + j];
-            else
+            else if (dev->valuator->axes[xv->first_valuator + j].mode == Absolute)
                 valuators[j] = dev->valuator->axisVal[xv->first_valuator + j];
+            else
+                valuators[j] = 0;
         }
 
         if (i + 6 < num_valuators)
commit 8199eac443d2c22d313cb23e39d5e607a8cc7f99
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Mon Mar 28 16:04:48 2011 -0400

    Handle non continuous valuator data in getValuatorEvents
    
    This allows for masked valuators to be handled properly in XI 1.x
    events. Any unset valuators in the device event are set to the last
    known value when transmitted on the wire through XI 1.x valuator events.
    
    Fixes https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/736500
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 07d53e0..5fdd357 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -383,19 +383,18 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
     int i;
     int state = 0;
     int first_valuator, num_valuators;
+    DeviceIntPtr dev = NULL;
 
 
     num_valuators = countValuators(ev, &first_valuator);
     if (num_valuators > 0)
     {
-        DeviceIntPtr dev = NULL;
         dixLookupDevice(&dev, ev->deviceid, serverClient, DixUseAccess);
         /* State needs to be assembled BEFORE the device is updated. */
         state = (dev && dev->key) ? XkbStateFieldFromRec(&dev->key->xkbInfo->state) : 0;
         state |= (dev && dev->button) ? (dev->button->state) : 0;
     }
 
-    /* FIXME: non-continuous valuator data in internal events*/
     for (i = 0; i < num_valuators; i += 6, xv++) {
         INT32 *valuators = &xv->valuator0; // Treat all 6 vals as an array
         int j;
@@ -406,8 +405,12 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
         xv->deviceid = ev->deviceid;
         xv->device_state = state;
 
-        for (j = 0; j < xv->num_valuators; j++)
-            valuators[j] = ev->valuators.data[xv->first_valuator + j];
+        for (j = 0; j < xv->num_valuators; j++) {
+            if (BitIsOn(ev->valuators.mask, xv->first_valuator + j))
+                valuators[j] = ev->valuators.data[xv->first_valuator + j];
+            else
+                valuators[j] = dev->valuator->axisVal[xv->first_valuator + j];
+        }
 
         if (i + 6 < num_valuators)
             xv->deviceid |= MORE_EVENTS;
commit 266ea63bc3e052b753c5484fa08dcc4fb67c8952
Author: Matthieu Herrb <matthieu.herrb at laas.fr>
Date:   Fri Apr 1 22:55:57 2011 +0200

    Xi: fix querydevice request swapping
    
    WriteReplyToClient() swaps rep.length, so it can't be used
    on return of WriteReplyToClient(). So save it's value for later
    use.
    
    Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 8b54211..6eea724 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -153,8 +153,9 @@ ProcXIQueryDevice(ClientPtr client)
         }
     }
 
+    len = rep.length * 4;
     WriteReplyToClient(client, sizeof(xXIQueryDeviceReply), &rep);
-    WriteToClient(client, rep.length * 4, ptr);
+    WriteToClient(client, len, ptr);
     free(ptr);
     free(skip);
     return rc;
commit 552c78592c5e5f52fe16e2429f77c63adf398247
Author: Matthieu Herrb <matthieu.herrb at laas.fr>
Date:   Fri Apr 1 22:54:54 2011 +0200

    Xext: fix test on extension number for the swapped case.
    
    Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xext/geext.c b/Xext/geext.c
index b37c1a0..a6fbb09 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -185,7 +185,7 @@ SGEGenericEvent(xEvent* from, xEvent* to)
     xGenericEvent* gefrom = (xGenericEvent*)from;
     xGenericEvent* geto = (xGenericEvent*)to;
 
-    if (gefrom->extension > MAXEXTENSIONS)
+    if ((gefrom->extension & 0x7f) > MAXEXTENSIONS)
     {
         ErrorF("GE: Invalid extension offset for event.\n");
         return;
commit a074e6b6754d6c2706b2b5de54e22cbffc5b1a17
Author: Matthieu Herrb <matthieu.herrb at laas.fr>
Date:   Fri Apr 1 22:53:40 2011 +0200

    Xi: add XI_Focus{In,Out} to swapped events.
    
    Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xi/extinit.c b/Xi/extinit.c
index 289558f..0b7280d 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -864,6 +864,8 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
     {
         case XI_Enter:
         case XI_Leave:
+        case XI_FocusIn:
+        case XI_FocusOut:
             SDeviceLeaveNotifyEvent((xXILeaveEvent*)from, (xXILeaveEvent*)to);
             break;
         case XI_DeviceChanged:
commit 81257377a2d011ce47fba5822df0f7918dea1d72
Author: Matthieu Herrb <matthieu.herrb at laas.fr>
Date:   Fri Apr 1 22:51:48 2011 +0200

    Xi: take XI2 requests into account also for the swapping case.
    
    Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xi/extinit.c b/Xi/extinit.c
index 46d3459..289558f 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -49,6 +49,7 @@ SOFTWARE.
  *  Dispatch routines and initialization routines for the X input extension.
  *
  */
+#define ARRAY_SIZE(_a)        (sizeof((_a)) / sizeof((_a)[0]))
 
 #define	 NUMTYPES 15
 
@@ -410,7 +411,7 @@ static int
 ProcIDispatch(ClientPtr client)
 {
     REQUEST(xReq);
-    if (stuff->data > (IREQUESTS + XI2REQUESTS) || !ProcIVector[stuff->data])
+    if (stuff->data > ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
         return BadRequest;
 
     return (*ProcIVector[stuff->data])(client);
@@ -429,7 +430,7 @@ static int
 SProcIDispatch(ClientPtr client)
 {
     REQUEST(xReq);
-    if (stuff->data > IREQUESTS || !SProcIVector[stuff->data])
+    if (stuff->data > ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
         return BadRequest;
 
     return (*SProcIVector[stuff->data])(client);
commit ac00ab77d5a00cfd198958aa1afaa4c3ccc6d7bc
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Mon Mar 28 16:04:47 2011 -0400

    Clean up getValuatorEvents using array loop logic
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index c9d1994..07d53e0 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -397,25 +397,17 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
 
     /* FIXME: non-continuous valuator data in internal events*/
     for (i = 0; i < num_valuators; i += 6, xv++) {
+        INT32 *valuators = &xv->valuator0; // Treat all 6 vals as an array
+        int j;
+
         xv->type = DeviceValuator;
         xv->first_valuator = first_valuator + i;
         xv->num_valuators = ((num_valuators - i) > 6) ? 6 : (num_valuators - i);
         xv->deviceid = ev->deviceid;
         xv->device_state = state;
-        switch (xv->num_valuators) {
-        case 6:
-            xv->valuator5 = ev->valuators.data[xv->first_valuator + 5];
-        case 5:
-            xv->valuator4 = ev->valuators.data[xv->first_valuator + 4];
-        case 4:
-            xv->valuator3 = ev->valuators.data[xv->first_valuator + 3];
-        case 3:
-            xv->valuator2 = ev->valuators.data[xv->first_valuator + 2];
-        case 2:
-            xv->valuator1 = ev->valuators.data[xv->first_valuator + 1];
-        case 1:
-            xv->valuator0 = ev->valuators.data[xv->first_valuator + 0];
-        }
+
+        for (j = 0; j < xv->num_valuators; j++)
+            valuators[j] = ev->valuators.data[xv->first_valuator + j];
 
         if (i + 6 < num_valuators)
             xv->deviceid |= MORE_EVENTS;
commit 3c45b59e675ba926ec95842ac3d49e2091e41eb8
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Mar 18 15:00:14 2011 +0000

    Fix XWin compilation after commit 769531b9
    
    commit 769531b9 "Add mode field to pointer movement hooks" changes the
    function signature of miPointerSetPosition() to include the movement mode
    which resulted in the pointer position
    
    Update use of miPointerSetPosition() in winEnqueueMotion() appropriately
    
    (See http://tinderbox.freedesktop.org/builds/2011-03-16-0008/logs/xserver/#build)
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index ee93d8f..080e096 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -372,7 +372,7 @@ void winEnqueueMotion(int x, int y)
   ValuatorMask mask;
   EventListPtr events;
 
-  miPointerSetPosition(g_pwinPointer, &x, &y);
+  miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
   valuators[0] = x;
   valuators[1] = y;
 


More information about the Xquartz-changes mailing list