[PATCH 2/3] dix: more lookup function consolidation, macro removal

Eamon Walsh ewalsh at tycho.nsa.gov
Tue Jan 30 14:49:25 PST 2007


Keith Packard wrote:
> On Mon, 2007-01-29 at 20:04 -0500, Eamon Walsh wrote:
>
>   
>> +_X_EXPORT int
>> +dixLookupResource(pointer *result, XID id, RESTYPE rtype,
>> +		  ClientPtr client, Mask mode)
>>     
>
> I'm not entirely comfortable with this change; it doesn't make the old
> distinction between looking up by type and by class very clear, instead
> hiding it in the magic of the resource type bits:
>
>   
>> +    int istype = rtype & (RC_LASTPREDEF - 1);
>>     
>
>   

I made a mistake here upon review.  The proper test should be:
int istype = (rtype & TypeMask) && (rtype != RC_ANY);

 From a user perspective, it seems intuitive to me: pass whatever type 
or class you're interested in.  Maybe the distinction could be made 
clear in the comments and documentation, such as the following which 
would be in the Xserver-spec document?

Looking Up Resources

To look up a resource from its resource ID, use the following:

    int dixLookupResource(
        pointer *result,
        XID id,
        RESTYPE rtype,
        ClientPtr client,
        Mask access_mode);

The id parameter is the resource ID being looked up.  The rtype 
parameter may be set to either a resource type value or a resource class 
value.  The resource being looked up must be of the given type (if a 
type value is passed) or belong to the given class (if a class value is 
passed).  Resource type/class values are discussed in Section X above.

The final two parameters are used for security and auditing purposes.  
The client parameter should refer to the client on whose behalf the 
lookup operation is being performed.  Typically, this is the client that 
sent the protocol request being processed by the calling code.  If there 
is no such client and the lookup is being performed on behalf of the 
server itself, pass serverClient.  The access_mode parameter should be 
set to one of the access type constants defined in resource.h: 
DixReadAccess for read access to the resource, DixWriteAccess for write 
access, and so forth.  These constants can be bitwise-or'ed together.

If the lookup operation is successful, the return value will be Success 
and the result parameter will be set to the resource data.  If the 
lookup operation fails, the return value will be set to one of the error 
codes defined in X.h.  BadValue indicates that no resource with the 
given id and type/class was found.  BadAccess indicates a permission denial.

-- 
Eamon Walsh <ewalsh at tycho.nsa.gov>
National Security Agency




More information about the xorg mailing list