dix: Simplify deprecated *Lookup* wrappers around dixLookup*.

As pointed out by Jamey Sharp: “the result pointer is already guaranteed
to be NULL if the return value is not Success”, so get rid of the
variable used to catch the return value, and used in a ternary operation
to decide whether to return the pointer or NULL. Always return the
result pointer instead.

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
This commit is contained in:
Cyril Brulebois 2010-11-12 21:29:26 +01:00
parent 73fbc4a4a7
commit a937803c1f

View File

@ -65,13 +65,13 @@ WindowPtr
SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode) SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
{ {
WindowPtr pWin; WindowPtr pWin;
int i = dixLookupWindow(&pWin, id, client, access_mode);
static int warn = 1; static int warn = 1;
dixLookupWindow(&pWin, id, client, access_mode);
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupWindow()/SecurityLookupWindow() " ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
"are deprecated. Please convert your driver/module " "are deprecated. Please convert your driver/module "
"to use dixLookupWindow().\n"); "to use dixLookupWindow().\n");
return (i == Success) ? pWin : NULL; return pWin;
} }
/* replaced by dixLookupWindow */ /* replaced by dixLookupWindow */
@ -86,13 +86,13 @@ pointer
SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode) SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
static int warn = 1; static int warn = 1;
dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() " ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
"are deprecated. Please convert your driver/module " "are deprecated. Please convert your driver/module "
"to use dixLookupDrawable().\n"); "to use dixLookupDrawable().\n");
return (i == Success) ? pDraw : NULL; return pDraw;
} }
/* replaced by dixLookupDrawable */ /* replaced by dixLookupDrawable */
@ -107,12 +107,12 @@ ClientPtr
LookupClient(XID id, ClientPtr client) LookupClient(XID id, ClientPtr client)
{ {
ClientPtr pClient; ClientPtr pClient;
int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
static int warn = 1; static int warn = 1;
dixLookupClient(&pClient, id, client, DixUnknownAccess);
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupClient() is deprecated. Please convert your " ErrorF("Warning: LookupClient() is deprecated. Please convert your "
"driver/module to use dixLookupClient().\n"); "driver/module to use dixLookupClient().\n");
return (i == Success) ? pClient : NULL; return pClient;
} }
/* replaced by dixLookupResourceByType */ /* replaced by dixLookupResourceByType */
@ -121,13 +121,13 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
Mask access_mode) Mask access_mode)
{ {
pointer retval; pointer retval;
int i = dixLookupResourceByType(&retval, id, rtype, client, access_mode);
static int warn = 1; static int warn = 1;
dixLookupResourceByType(&retval, id, rtype, client, access_mode);
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() " ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
"are deprecated. Please convert your driver/module " "are deprecated. Please convert your driver/module "
"to use dixLookupResourceByType().\n"); "to use dixLookupResourceByType().\n");
return (i == Success) ? retval : NULL; return retval;
} }
pointer pointer
@ -135,13 +135,13 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
Mask access_mode) Mask access_mode)
{ {
pointer retval; pointer retval;
int i = dixLookupResourceByClass(&retval, id, classes, client, access_mode);
static int warn = 1; static int warn = 1;
dixLookupResourceByClass(&retval, id, classes, client, access_mode);
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() " ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
"are deprecated. Please convert your driver/module " "are deprecated. Please convert your driver/module "
"to use dixLookupResourceByClass().\n"); "to use dixLookupResourceByClass().\n");
return (i == Success) ? retval : NULL; return retval;
} }
/* replaced by dixLookupResourceByType */ /* replaced by dixLookupResourceByType */