(submit/cleanup-vidmode-dispatch) Xext: vidmode: simplify dispatcher

These dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-04 13:06:27 +02:00
parent 9a6a2574e9
commit 24d90b9c09

View File

@ -451,6 +451,10 @@ ProcVidModeAddModeLine(ClientPtr client)
int dotClock;
int ver;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
DEBUG_P("XF86VidModeAddModeline");
ver = ClientMajorVersion(client);
@ -621,6 +625,10 @@ ProcVidModeDeleteModeLine(ClientPtr client)
int len, dotClock;
int ver;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
DEBUG_P("XF86VidModeDeleteModeline");
ver = ClientMajorVersion(client);
@ -745,6 +753,10 @@ ProcVidModeModModeLine(ClientPtr client)
int len, dotClock;
int ver;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
DEBUG_P("XF86VidModeModModeline");
ver = ClientMajorVersion(client);
@ -1006,6 +1018,10 @@ ProcVidModeSwitchMode(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1034,6 +1050,10 @@ ProcVidModeSwitchToMode(ClientPtr client)
DEBUG_P("XF86VidModeSwitchToMode");
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
ver = ClientMajorVersion(client);
if (ver < 2) {
@ -1138,6 +1158,10 @@ ProcVidModeLockModeSwitch(ClientPtr client)
DEBUG_P("XF86VidModeLockModeSwitch");
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1301,6 +1325,10 @@ ProcVidModeSetViewPort(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1399,6 +1427,10 @@ ProcVidModeSetGamma(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1466,6 +1498,10 @@ ProcVidModeSetGammaRamp(ClientPtr client)
ScreenPtr pScreen;
VidModePtr pVidMode;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
REQUEST(xXF86VidModeSetGammaRampReq);
REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
@ -1673,9 +1709,6 @@ ProcVidModeDispatch(ClientPtr client)
return ProcVidModeGetGammaRampSize(client);
case X_XF86VidModeGetPermissions:
return ProcVidModeGetPermissions(client);
default:
if (VidModeAllowNonLocal || client->local) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return ProcVidModeAddModeLine(client);
case X_XF86VidModeDeleteModeLine:
@ -1698,10 +1731,6 @@ ProcVidModeDispatch(ClientPtr client)
return BadRequest;
}
}
else
return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
static int _X_COLD
SProcVidModeGetModeLine(ClientPtr client)
@ -2063,9 +2092,6 @@ SProcVidModeDispatch(ClientPtr client)
return SProcVidModeGetGammaRampSize(client);
case X_XF86VidModeGetPermissions:
return SProcVidModeGetPermissions(client);
default:
if (VidModeAllowNonLocal || client->local) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return SProcVidModeAddModeLine(client);
case X_XF86VidModeDeleteModeLine:
@ -2088,10 +2114,6 @@ SProcVidModeDispatch(ClientPtr client)
return BadRequest;
}
}
else
return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
void
VidModeAddExtension(Bool allow_non_local)