From 7ef19de1044413fa7023dbee194866ac136c2ea3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 3 Mar 2025 14:07:12 +0100 Subject: [PATCH] kdrive: correctly use keyboard driver proc return values The Enable() and Init() procs are defined to return Bool, the actual functions (as well as their callers) are using X11 reply status codes, but practically using only one bit of information. This happens to magically works, because all involved types come down to plain int. Instead of relying on some black magic, better write clean and easily understandable code instead. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/kdrive/ephyr/ephyr.c | 10 +++++----- hw/kdrive/src/kinput.c | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 7958cf7fc..2ba0b4597 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "mi/mipointer_priv.h" @@ -1316,7 +1317,7 @@ KdPointerDriver EphyrMouseDriver = { /* Keyboard */ -static Status +static Bool EphyrKeyboardInit(KdKeyboardInfo * ki) { KeySymsRec keySyms; @@ -1344,15 +1345,14 @@ EphyrKeyboardInit(KdKeyboardInfo * ki) ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; - return Success; + return TRUE; } -static Status +static Bool EphyrKeyboardEnable(KdKeyboardInfo * ki) { ((EphyrKbdPrivate *) ki->driverPrivate)->enabled = TRUE; - - return Success; + return TRUE; } static void diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index fae933166..4d81bfd28 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -541,9 +541,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) return BadImplementation; } - if ((*ki->driver->Init) (ki) != Success) { + if (!(ki->driver->Init(ki))) return BadRequest; - } xiclass = AtomFromName(XI_KEYBOARD); AssignTypeAndName(pDevice, xiclass, @@ -560,9 +559,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) if (!ki->driver->Enable) return BadImplementation; - if ((*ki->driver->Enable) (ki) != Success) { + if (!(ki->driver->Enable(ki))) return BadMatch; - } pDev->on = TRUE; return Success;