From cb508b2632f661e19b44f1375ddce3ffb415f4c5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 25 May 2019 19:38:14 +0200 Subject: various scope improvements --- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/NXpicture.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 4ea7d2d73..e35d1e9bc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -309,12 +309,6 @@ static PicturePtr createSourcePicture(void) unsigned int totalPictureSize; - DevUnion *ppriv; - - char *privPictureRecAddr; - - int i; - /* * Compute size of entire PictureRect, plus privates. */ @@ -327,9 +321,9 @@ static PicturePtr createSourcePicture(void) if (pPicture != NULL) { - ppriv = (DevUnion *) (pPicture + 1); + DevUnion *ppriv = (DevUnion *) (pPicture + 1); - for (i = 0; i < picturePrivateCount; ++i) + for (int i = 0; i < picturePrivateCount; ++i) { /* * Other privates are inaccessible. @@ -338,7 +332,7 @@ static PicturePtr createSourcePicture(void) ppriv[i].ptr = NULL; } - privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; + char *privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; ppriv[nxagentPicturePrivateIndex].ptr = (void *) privPictureRecAddr; -- cgit v1.2.3 From 78eff73e4a8cf6a428dd4bd5ed50e0515ec8794f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 00:51:32 +0200 Subject: render: Propagate allocation failure from createSourcePicture() commit 211d4c2d353b5e379716484055a3f58235ea65f4 Author: Chris Wilson Date: Wed Dec 14 15:55:22 2011 +0000 render: Propagate allocation failure from createSourcePicture() All the callers were already checking for failure, except that createSourcePicture() itself was failing to check whether it successfully allocated the Picture. [ajax: Rebase, fix line wrap of preceding line] Signed-off-by: Chris Wilson Reviewed-by: Jeremy Huddleston --- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nx-X11/programs/Xserver/hw/nxagent/NXpicture.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index e35d1e9bc..01821f474 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -318,6 +318,8 @@ static PicturePtr createSourcePicture(void) sizeof(nxagentPrivPictureRec); pPicture = (PicturePtr) calloc(1, totalPictureSize); + if (!pPicture) + return 0; if (pPicture != NULL) { -- cgit v1.2.3 From 528e1e4ef520506733ac3eeef374fcca41214cd1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 01:31:17 +0200 Subject: NXpicture.c: code simplification --- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/NXpicture.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 01821f474..491af5b30 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -303,21 +303,17 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) static PicturePtr createSourcePicture(void) { - PicturePtr pPicture; - extern int nxagentPicturePrivateIndex; - unsigned int totalPictureSize; - /* * Compute size of entire PictureRect, plus privates. */ - totalPictureSize = sizeof(PictureRec) + + unsigned int totalPictureSize = sizeof(PictureRec) + picturePrivateCount * sizeof(DevUnion) + sizeof(nxagentPrivPictureRec); - pPicture = (PicturePtr) calloc(1, totalPictureSize); + PicturePtr pPicture = (PicturePtr) calloc(1, totalPictureSize); if (!pPicture) return 0; -- cgit v1.2.3