From 51d8bcfc0db6b0ee56ab9d8b8eff337b713b9278 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 17 May 2024 15:22:46 +0200 Subject: [PATCH] xace: typesafe hook function for XACE_SCREEN_ACCESS he generic XaceHook() call isn't typesafe (und unnecessarily slow). Better add an explicit function, just like we already have for others. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- Xext/xace.c | 8 +++++++- Xext/xace.h | 1 + dbe/dbe.c | 2 +- dix/dispatch.c | 9 ++++----- xfixes/cursor.c | 6 ++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Xext/xace.c b/Xext/xace.c index 9c5e9ddd4..847f14328 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -115,6 +115,13 @@ int XaceHookServerAccess(ClientPtr client, Mask access_mode) return rec.status; } +int XaceHookScreenAccess(ClientPtr client, ScreenPtr screen, Mask access_mode) +{ + XaceScreenAccessRec rec = { client, screen, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_SCREEN_ACCESS], &rec); + return rec.status; +} + /* Entry point for hook functions. Called by Xserver. */ int @@ -139,7 +146,6 @@ XaceHook(int hook, ...) * sets calldata directly to a single argument (with no return result) */ switch (hook) { - case XACE_SCREEN_ACCESS: case XACE_SCREENSAVER_ACCESS: u.screen.client = va_arg(ap, ClientPtr); u.screen.screen = va_arg(ap, ScreenPtr); diff --git a/Xext/xace.h b/Xext/xace.h index 0de4a6355..8404fb736 100644 --- a/Xext/xace.h +++ b/Xext/xace.h @@ -91,6 +91,7 @@ int XaceHookReceiveAccess(ClientPtr client, WindowPtr win, xEventPtr ev, int cou int XaceHookClientAccess(ClientPtr client, ClientPtr target, Mask access_mode); int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext); int XaceHookServerAccess(ClientPtr client, Mask access_mode); +int XaceHookScreenAccess(ClientPtr client, ScreenPtr screen, Mask access_mode); /* Register a callback for a given hook. diff --git a/dbe/dbe.c b/dbe/dbe.c index b9f6690a6..29cac9533 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -614,7 +614,7 @@ ProcDbeGetVisualInfo(ClientPtr client) pDrawables[i]->pScreen; pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); - rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); + rc = XaceHookScreenAccess(client, pScreen, DixGetAttrAccess); if (rc != Success) goto freeScrVisInfo; diff --git a/dix/dispatch.c b/dix/dispatch.c index 290534618..266f5f89f 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2523,7 +2523,7 @@ ProcInstallColormap(ClientPtr client) if (rc != Success) goto out; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); + rc = XaceHookScreenAccess(client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) { if (rc == BadValue) rc = BadColor; @@ -2552,7 +2552,7 @@ ProcUninstallColormap(ClientPtr client) if (rc != Success) goto out; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); + rc = XaceHookScreenAccess(client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) { if (rc == BadValue) rc = BadColor; @@ -2582,8 +2582,7 @@ ProcListInstalledColormaps(ClientPtr client) if (rc != Success) return rc; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixGetAttrAccess); + rc = XaceHookScreenAccess(client, pWin->drawable.pScreen, DixGetAttrAccess); if (rc != Success) return rc; @@ -3154,7 +3153,7 @@ ProcQueryBestSize(ClientPtr client) if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return BadMatch; pScreen = pDraw->pScreen; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); + rc = XaceHookScreenAccess(client, pScreen, DixGetAttrAccess); if (rc != Success) return rc; (*pScreen->QueryBestSize) (stuff->class, &stuff->width, diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 85aa272a7..8f4752d61 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -880,8 +880,7 @@ ProcXFixesHideCursor(ClientPtr client) * This is the first time this client has hid the cursor * for this screen. */ - ret = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixHideAccess); + ret = XaceHookScreenAccess(client, pWin->drawable.pScreen, DixHideAccess); if (ret != Success) return ret; @@ -938,8 +937,7 @@ ProcXFixesShowCursor(ClientPtr client) return BadMatch; } - rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixShowAccess); + rc = XaceHookScreenAccess(client, pWin->drawable.pScreen, DixShowAccess); if (rc != Success) return rc;