Re: [PATCH 3/5] cursor: Clean up pointer barrier creation code a tiny bit
On Sat, Nov 03, 2012 at 06:39:34PM -0400, Jasper St. Pierre wrote: From: Jasper St. Pierre jstpie...@mecheye.net This will make it much simpler when we add more error paths to the code that constructs pointer barrier clients. Signed-off-by: Jasper St. Pierre jstpie...@mecheye.net --- xfixes/cursor.c | 54 ++ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 9d7c0f0..a34f65c 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -1245,28 +1245,34 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, } } -static struct PointerBarrierClient * +static int CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client, - xXFixesCreatePointerBarrierReq * stuff) + xXFixesCreatePointerBarrierReq * stuff, + PointerBarrierClientPtr *client_out) { CursorScreenPtr cs = GetCursorScreen(screen); struct PointerBarrierClient *ret = malloc(sizeof(*ret)); -if (ret) { -ret-screen = screen; -ret-barrier.x1 = min(stuff-x1, stuff-x2); -ret-barrier.x2 = max(stuff-x1, stuff-x2); -ret-barrier.y1 = min(stuff-y1, stuff-y2); -ret-barrier.y2 = max(stuff-y1, stuff-y2); -ret-barrier.directions = stuff-directions 0x0f; -if (barrier_is_horizontal(ret-barrier)) -ret-barrier.directions = ~(BarrierPositiveX | BarrierNegativeX); -if (barrier_is_vertical(ret-barrier)) -ret-barrier.directions = ~(BarrierPositiveY | BarrierNegativeY); -xorg_list_add(ret-entry, cs-barriers); +*client_out = NULL; + +if (!ret) { +return BadAlloc; } -return ret; +ret-screen = screen; +ret-barrier.x1 = min(stuff-x1, stuff-x2); +ret-barrier.x2 = max(stuff-x1, stuff-x2); +ret-barrier.y1 = min(stuff-y1, stuff-y2); +ret-barrier.y2 = max(stuff-y1, stuff-y2); +ret-barrier.directions = stuff-directions 0x0f; +if (barrier_is_horizontal(ret-barrier)) +ret-barrier.directions = ~(BarrierPositiveX | BarrierNegativeX); +if (barrier_is_vertical(ret-barrier)) +ret-barrier.directions = ~(BarrierPositiveY | BarrierNegativeY); +xorg_list_add(ret-entry, cs-barriers); + +*client_out = ret; +return Success; } int @@ -1279,7 +1285,7 @@ ProcXFixesCreatePointerBarrier(ClientPtr client) REQUEST(xXFixesCreatePointerBarrierReq); -REQUEST_FIXED_SIZE(xXFixesCreatePointerBarrierReq, pad_to_int32(stuff-num_devices)); +REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq); did you really intend to undo the previous patch? Cheers, Peter LEGAL_NEW_RESOURCE(stuff-barrier, client); err = dixLookupWindow(pWin, stuff-window, client, DixReadAccess); @@ -1304,9 +1310,9 @@ ProcXFixesCreatePointerBarrier(ClientPtr client) if (barrier_is_horizontal(b) barrier_is_vertical(b)) return BadValue; -if (!(barrier = CreatePointerBarrierClient(pWin-drawable.pScreen, - client, stuff))) -return BadAlloc; +if ((err = CreatePointerBarrierClient(pWin-drawable.pScreen, + client, stuff, barrier))) +return err; if (!AddResource(stuff-barrier, PointerBarrierType, barrier-barrier)) return BadAlloc; @@ -1318,13 +1324,9 @@ int SProcXFixesCreatePointerBarrier(ClientPtr client) { REQUEST(xXFixesCreatePointerBarrierReq); -int i; -CARD16 *in_devices = (CARD16 *) stuff[1]; swaps(stuff-length); -swaps(stuff-num_devices); -REQUEST_FIXED_SIZE(xXFixesCreatePointerBarrierReq, pad_to_int32(stuff-num_devices)); - +REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq); swapl(stuff-barrier); swapl(stuff-window); swaps(stuff-x1); @@ -1332,10 +1334,6 @@ SProcXFixesCreatePointerBarrier(ClientPtr client) swaps(stuff-x2); swaps(stuff-y2); swapl(stuff-directions); -for (i = 0; i stuff-num_devices; i++) { -swapl(in_devices + i); -} - return ProcXFixesVector[stuff-xfixesReqType] (client); } -- 1.7.12.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 3/5] cursor: Clean up pointer barrier creation code a tiny bit
From: Jasper St. Pierre jstpie...@mecheye.net This will make it much simpler when we add more error paths to the code that constructs pointer barrier clients. Signed-off-by: Jasper St. Pierre jstpie...@mecheye.net --- xfixes/cursor.c | 54 ++ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 9d7c0f0..a34f65c 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -1245,28 +1245,34 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, } } -static struct PointerBarrierClient * +static int CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client, - xXFixesCreatePointerBarrierReq * stuff) + xXFixesCreatePointerBarrierReq * stuff, + PointerBarrierClientPtr *client_out) { CursorScreenPtr cs = GetCursorScreen(screen); struct PointerBarrierClient *ret = malloc(sizeof(*ret)); -if (ret) { -ret-screen = screen; -ret-barrier.x1 = min(stuff-x1, stuff-x2); -ret-barrier.x2 = max(stuff-x1, stuff-x2); -ret-barrier.y1 = min(stuff-y1, stuff-y2); -ret-barrier.y2 = max(stuff-y1, stuff-y2); -ret-barrier.directions = stuff-directions 0x0f; -if (barrier_is_horizontal(ret-barrier)) -ret-barrier.directions = ~(BarrierPositiveX | BarrierNegativeX); -if (barrier_is_vertical(ret-barrier)) -ret-barrier.directions = ~(BarrierPositiveY | BarrierNegativeY); -xorg_list_add(ret-entry, cs-barriers); +*client_out = NULL; + +if (!ret) { +return BadAlloc; } -return ret; +ret-screen = screen; +ret-barrier.x1 = min(stuff-x1, stuff-x2); +ret-barrier.x2 = max(stuff-x1, stuff-x2); +ret-barrier.y1 = min(stuff-y1, stuff-y2); +ret-barrier.y2 = max(stuff-y1, stuff-y2); +ret-barrier.directions = stuff-directions 0x0f; +if (barrier_is_horizontal(ret-barrier)) +ret-barrier.directions = ~(BarrierPositiveX | BarrierNegativeX); +if (barrier_is_vertical(ret-barrier)) +ret-barrier.directions = ~(BarrierPositiveY | BarrierNegativeY); +xorg_list_add(ret-entry, cs-barriers); + +*client_out = ret; +return Success; } int @@ -1279,7 +1285,7 @@ ProcXFixesCreatePointerBarrier(ClientPtr client) REQUEST(xXFixesCreatePointerBarrierReq); -REQUEST_FIXED_SIZE(xXFixesCreatePointerBarrierReq, pad_to_int32(stuff-num_devices)); +REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq); LEGAL_NEW_RESOURCE(stuff-barrier, client); err = dixLookupWindow(pWin, stuff-window, client, DixReadAccess); @@ -1304,9 +1310,9 @@ ProcXFixesCreatePointerBarrier(ClientPtr client) if (barrier_is_horizontal(b) barrier_is_vertical(b)) return BadValue; -if (!(barrier = CreatePointerBarrierClient(pWin-drawable.pScreen, - client, stuff))) -return BadAlloc; +if ((err = CreatePointerBarrierClient(pWin-drawable.pScreen, + client, stuff, barrier))) +return err; if (!AddResource(stuff-barrier, PointerBarrierType, barrier-barrier)) return BadAlloc; @@ -1318,13 +1324,9 @@ int SProcXFixesCreatePointerBarrier(ClientPtr client) { REQUEST(xXFixesCreatePointerBarrierReq); -int i; -CARD16 *in_devices = (CARD16 *) stuff[1]; swaps(stuff-length); -swaps(stuff-num_devices); -REQUEST_FIXED_SIZE(xXFixesCreatePointerBarrierReq, pad_to_int32(stuff-num_devices)); - +REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq); swapl(stuff-barrier); swapl(stuff-window); swaps(stuff-x1); @@ -1332,10 +1334,6 @@ SProcXFixesCreatePointerBarrier(ClientPtr client) swaps(stuff-x2); swaps(stuff-y2); swapl(stuff-directions); -for (i = 0; i stuff-num_devices; i++) { -swapl(in_devices + i); -} - return ProcXFixesVector[stuff-xfixesReqType] (client); } -- 1.7.12.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 3/5] cursor: Clean up pointer barrier creation code a tiny bit
From: Jasper St. Pierre jstpie...@mecheye.net This will make it much simpler when we add more error paths to the code that constructs pointer barrier clients. Signed-off-by: Jasper St. Pierre jstpie...@mecheye.net --- xfixes/cursor.c | 42 -- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 75b0374..f66bd68 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -1245,28 +1245,34 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, } } -static struct PointerBarrierClient * +static int CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client, - xXFixesCreatePointerBarrierReq * stuff) + xXFixesCreatePointerBarrierReq * stuff, + PointerBarrierClientPtr *client_out) { CursorScreenPtr cs = GetCursorScreen(screen); struct PointerBarrierClient *ret = malloc(sizeof(*ret)); -if (ret) { -ret-screen = screen; -ret-barrier.x1 = min(stuff-x1, stuff-x2); -ret-barrier.x2 = max(stuff-x1, stuff-x2); -ret-barrier.y1 = min(stuff-y1, stuff-y2); -ret-barrier.y2 = max(stuff-y1, stuff-y2); -ret-barrier.directions = stuff-directions 0x0f; -if (barrier_is_horizontal(ret-barrier)) -ret-barrier.directions = ~(BarrierPositiveX | BarrierNegativeX); -if (barrier_is_vertical(ret-barrier)) -ret-barrier.directions = ~(BarrierPositiveY | BarrierNegativeY); -xorg_list_add(ret-entry, cs-barriers); +*client_out = NULL; + +if (!ret) { +return BadAlloc; } -return ret; +ret-screen = screen; +ret-barrier.x1 = min(stuff-x1, stuff-x2); +ret-barrier.x2 = max(stuff-x1, stuff-x2); +ret-barrier.y1 = min(stuff-y1, stuff-y2); +ret-barrier.y2 = max(stuff-y1, stuff-y2); +ret-barrier.directions = stuff-directions 0x0f; +if (barrier_is_horizontal(ret-barrier)) +ret-barrier.directions = ~(BarrierPositiveX | BarrierNegativeX); +if (barrier_is_vertical(ret-barrier)) +ret-barrier.directions = ~(BarrierPositiveY | BarrierNegativeY); +xorg_list_add(ret-entry, cs-barriers); + +*client_out = ret; +return Success; } int @@ -1304,9 +1310,9 @@ ProcXFixesCreatePointerBarrier(ClientPtr client) if (barrier_is_horizontal(b) barrier_is_vertical(b)) return BadValue; -if (!(barrier = CreatePointerBarrierClient(pWin-drawable.pScreen, - client, stuff))) -return BadAlloc; +if ((err = CreatePointerBarrierClient(pWin-drawable.pScreen, + client, stuff, barrier))) +return err; if (!AddResource(stuff-barrier, PointerBarrierType, barrier-barrier)) return BadAlloc; -- 1.7.12.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel