[PATCH] xres: Return the atom naming the type, not its internal type number

Eric Engestrom eric.engestrom at imgtec.com
Wed Dec 9 05:37:15 PST 2015


On 08/12/15 20:08, Adam Jackson wrote:
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>   Xext/xres.c | 34 +++++++++++++++++++++-------------
>   1 file changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/Xext/xres.c b/Xext/xres.c
> index 83cc691..5d3faa3 100644
> --- a/Xext/xres.c
> +++ b/Xext/xres.c
> @@ -274,6 +274,24 @@ ResFindAllRes(void *value, XID id, RESTYPE type, void *cdata)
>       counts[(type & TypeMask) - 1]++;
>   }
>
> +static CARD32
> +resourceTypeAtom(int i)
> +{
> +    CARD32 ret;
> +
> +    const char *name = LookupResourceName(i);
> +    if (strcmp(name, XREGISTRY_UNKNOWN))
> +        ret = MakeAtom(name, strlen(name), TRUE);
> +    else {
> +        char buf[40];
> +
> +        snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);

Shouldn't that be just `i` ?

> +        ret = MakeAtom(buf, strlen(buf), TRUE);
> +    }
> +
> +    return ret;
> +}
> +
>   static int
>   ProcXResQueryClientResources(ClientPtr client)
>   {
> @@ -318,22 +336,12 @@ ProcXResQueryClientResources(ClientPtr client)
>
>       if (num_types) {
>           xXResType scratch;
> -        const char *name;
>
>           for (i = 0; i < lastResourceType; i++) {
>               if (!counts[i])
>                   continue;
>
> -            name = LookupResourceName(i + 1);
> -            if (strcmp(name, XREGISTRY_UNKNOWN))
> -                scratch.resource_type = MakeAtom(name, strlen(name), TRUE);
> -            else {
> -                char buf[40];
> -
> -                snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);
> -                scratch.resource_type = MakeAtom(buf, strlen(buf), TRUE);
> -            }
> -
> +            scratch.resource_type = resourceTypeAtom(i + 1);
>               scratch.count = counts[i];
>
>               if (client->swapped) {
> @@ -785,7 +793,7 @@ AddSubResourceSizeSpec(void *value,
>                   sizeFunc(value, id, &size);
>
>                   crossRef->spec.resource = id;
> -                crossRef->spec.type = type;
> +                crossRef->spec.type = resourceTypeAtom(type);
>                   crossRef->bytes = size.resourceSize;
>                   crossRef->refCount = size.refCnt;
>                   crossRef->useCount = 1;
> @@ -858,7 +866,7 @@ AddResourceSizeValue(void *ptr, XID id, RESTYPE type, void *cdata)
>               sizeFunc(ptr, id, &size);
>
>               value->size.spec.resource = id;
> -            value->size.spec.type = type;
> +            value->size.spec.type = resourceTypeAtom(type);
>               value->size.bytes = size.resourceSize;
>               value->size.refCount = size.refCnt;
>               value->size.useCount = 1;
>


More information about the xorg-devel mailing list