[PATCH:libXfixes 2/2] XFixesFetchRegionAndBounds: use nread in call to XReadPad

Alan Coopersmith alan.coopersmith at oracle.com
Sat Mar 9 09:31:52 PST 2013


We already went through the trouble of calculating a variable with the
amount to read, might as well use it instead of recalculating it.

Also move initialization of the variable to the point it's needed/used

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/Region.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Region.c b/src/Region.c
index 94c5403..042f966 100644
--- a/src/Region.c
+++ b/src/Region.c
@@ -335,7 +335,6 @@ XFixesFetchRegionAndBounds (Display	    *dpy,
     bounds->height = rep.height;
     nbytes = (long) rep.length << 2;
     nrects = rep.length >> 1;
-    nread = nrects << 3;
     rects = Xmalloc (nrects * sizeof (XRectangle));
     if (!rects)
     {
@@ -344,7 +343,8 @@ XFixesFetchRegionAndBounds (Display	    *dpy,
 	SyncHandle ();
 	return NULL;
     }
-    _XRead16 (dpy, (short *) rects, nrects << 3);
+    nread = nrects << 3;
+    _XRead16 (dpy, (short *) rects, nread);
     /* skip any padding */
     if(nbytes > nread)
     {
-- 
1.7.9.2



More information about the xorg-devel mailing list