[PATCH 3/3] Replace LookupIDByType() with dixLookupResourceByType(), take 2.

Jamey Sharp jamey at minilop.net
Fri Nov 12 10:42:28 PST 2010


When you declare "pointer val" instead of some more specific type, you
don't need to cast &val to (pointer *), so I'd drop the cast in those
cases. In the other cases I am of course going to suggest (pointer *)
instead of (pointer) again. :-)

Otherwise,
Reviewed-by: Jamey Sharp <jamey at minilop.net>

In the cases where the returned resource is immediately checked for
NULL, you could choose to check the return value against Success
instead. It's purely a question of style and doesn't affect my
reviewed-by--choose whichever you think looks better.

Jamey

On Thu, Nov 11, 2010 at 7:03 AM, Cyril Brulebois <kibi at debian.org> wrote:
> These occurrences are a bit harder to catch through a semantic patch,
> so process them “manually”.
>
> Signed-off-by: Cyril Brulebois <kibi at debian.org>
> ---
>  hw/dmx/dmxgcops.c         |    6 ++++--
>  hw/dmx/glxProxy/glxcmds.c |   12 ++++++++++--
>  hw/dmx/glxProxy/glxext.c  |    6 +++++-
>  3 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c
> index a4cecf4..876df01 100644
> --- a/hw/dmx/dmxgcops.c
> +++ b/hw/dmx/dmxgcops.c
> @@ -523,8 +523,10 @@ static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
>
>     if (noPanoramiXExtension)               return NULL;
>     if (pDrawable->type != DRAWABLE_PIXMAP) return NULL;
> -
> -    if (!(pXinPix = (PanoramiXRes *)LookupIDByType(pDrawable->id, XRT_PIXMAP)))
> +
> +    dixLookupResourceByType((pointer) &pXinPix, pDrawable->id, XRT_PIXMAP,
> +                           NullClient, DixUnknownAccess);
> +    if (!pXinPix)
>         return NULL;
>
>     for (i = 1; i < PanoramiXNumScreens; i++) {
> diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
> index b2e96a9..989b6a4 100644
> --- a/hw/dmx/glxProxy/glxcmds.c
> +++ b/hw/dmx/glxProxy/glxcmds.c
> @@ -2897,6 +2897,7 @@ int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
>     VisualPtr pVisual;
>     VisualID visId;
>     int i, rc;
> +    pointer val;
>
>     /*
>     ** Check if windowId is valid
> @@ -2962,7 +2963,10 @@ int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
>     /*
>     ** Check if there is already a fbconfig associated with this window
>     */
> -    if ( LookupIDByType(glxwindowId, __glXWindowRes) ) {
> +    dixLookupResourceByType((pointer) &val,
> +                           glxwindowId, __glXWindowRes,
> +                           NullClient, DixUnknownAccess);
> +    if (val) {
>        client->errorValue = glxwindowId;
>        return BadAlloc;
>     }
> @@ -2994,11 +2998,15 @@ int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc)
>     ClientPtr client = cl->client;
>     xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
>     XID glxwindow = req->glxwindow;
> +    pointer val;
>
>     /*
>     ** Check if it's a valid GLX window.
>     */
> -    if (!LookupIDByType(glxwindow, __glXWindowRes)) {
> +    dixLookupResourceByType((pointer) &val,
> +                           glxwindow, __glXWindowRes,
> +                           NullClient, DixUnknownAccess);
> +    if (!val) {
>        client->errorValue = glxwindow;
>        return __glXBadDrawable;
>     }
> diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c
> index 886b317..7f63b6b 100644
> --- a/hw/dmx/glxProxy/glxext.c
> +++ b/hw/dmx/glxProxy/glxext.c
> @@ -186,8 +186,12 @@ void __glXFreeGLXWindow(__glXWindow *pGlxWindow)
>  {
>     if (!pGlxWindow->idExists && !pGlxWindow->refcnt) {
>        WindowPtr pWindow = (WindowPtr) pGlxWindow->pDraw;
> +       WindowPtr ret;
>
> -        if (LookupIDByType(pWindow->drawable.id, RT_WINDOW) == pWindow) {
> +       dixLookupResourceByType((pointer) &ret,
> +                               pWindow->drawable.id, RT_WINDOW,
> +                               NullClient, DixUnknownAccess);
> +        if (ret == pWindow) {
>             (*pGlxWindow->pScreen->DestroyWindow)(pWindow);
>         }
>
> --
> 1.7.2.3
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list