[PATCH-RESEND] dix: move cursor realize code to its own function

Keith Packard keithp at keithp.com
Thu Jan 14 09:45:05 PST 2010


On Thu, 14 Jan 2010 17:18:41 +0200, Tiago Vignatti <tiago.vignatti at nokia.com> wrote:
> The semantic remains, only code was moved: reuse chunk of code to realize
> cursor on both AllocARGBCursor and AllocGlyphCursor.

Sounds like a sensible idea.

> +    if (rc != Success)
> +        goto error;
> +
> +    if (RealizeCursorAllScreens(pCurs)) {
> +        *ppCurs = pCurs;
> +        return Success;
>      }
> -    *ppCurs = pCurs;
> -    return rc;
> +
> +error:
> +    dixFreePrivates(pCurs->devPrivates);
> +    FreeCursorBits(bits);
> +    xfree(pCurs);
> +
> +    return BadAlloc;

I'd rather see this use a slightly different pattern:

    if (rc != Success)
       goto error;
    rc = RealizeCursorAllScreens(pCurs);
    if (rc != Success)
       goto error;
    *ppCurs = pCurs;
    return Success;
error:
    dixFreePrivates(pCurs->devPrivates);
    FreeCursorBits(bits);
    xfree(pCurs);

    return rc;

This returns the value from XaceHook on failure, and makes all errors go
through an easily identified path (with no-one falling through the
error: label).
    

> +    if (rc != Success)
> +        goto error;
>  
> -                    (*pscr->UnrealizeCursor)(inputInfo.pointer, pscr, pCurs);
> +    if (RealizeCursorAllScreens(pCurs)) {
> +        *ppCurs = pCurs;
> +        return Success;
> +    }

Same thing here;

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.x.org/archives/xorg-devel/attachments/20100114/cbd710b9/attachment.pgp 


More information about the xorg-devel mailing list