[PATCH xserver 1/4] dix: Factor out extension availability check

Adam Jackson ajax at redhat.com
Mon Apr 23 20:19:12 UTC 2018


Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 dix/extension.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/dix/extension.c b/dix/extension.c
index b4c1c5f16f..7d432c7224 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -210,6 +210,14 @@ CloseDownExtensions(void)
     lastError = FirstExtensionError;
 }
 
+static Bool
+ExtensionAvailable(ClientPtr client, ExtensionEntry *ext)
+{
+    if (XaceHook(XACE_EXT_ACCESS, client, ext) != Success)
+        return FALSE;
+    return TRUE;
+}
+
 int
 ProcQueryExtension(ClientPtr client)
 {
@@ -231,7 +239,7 @@ ProcQueryExtension(ClientPtr client)
         reply.present = xFalse;
     else {
         i = FindExtension((char *) &stuff[1], stuff->nbytes);
-        if (i < 0 || XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+        if (i < 0 || !ExtensionAvailable(client, extensions[i]))
             reply.present = xFalse;
         else {
             reply.present = xTrue;
@@ -266,7 +274,7 @@ ProcListExtensions(ClientPtr client)
 
         for (i = 0; i < NumExtensions; i++) {
             /* call callbacks to find out whether to show extension */
-            if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
+            if (!ExtensionAvailable(client, extensions[i]))
                 continue;
 
             total_length += strlen(extensions[i]->name) + 1;
@@ -279,7 +287,7 @@ ProcListExtensions(ClientPtr client)
         for (i = 0; i < NumExtensions; i++) {
             int len;
 
-            if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
+            if (!ExtensionAvailable(client, extensions[i]))
                 continue;
 
             *bufptr++ = len = strlen(extensions[i]->name);
-- 
2.17.0



More information about the xorg-devel mailing list