From af71108cd3609a3a6ba81940e73c67e7876dc787 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 7 May 2025 13:00:12 +0200 Subject: [PATCH] dix: devices: refine NULL checks in GetMaster() The checking / branchin isn't entirely trivial to understand, and the analyzer also gets confused. So rewrite it in an simpler way that's easier to understand both the human reader as well as the analyzer. (and so get rid of yet another false alarm) Signed-off-by: Enrico Weigelt, metux IT consult --- dix/devices.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 732d595d9..434bd317b 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2772,15 +2772,19 @@ GetMaster(DeviceIntPtr dev, int which) return dev; } - if (master && which != MASTER_ATTACHED) { - if (which == MASTER_KEYBOARD || which == KEYBOARD_OR_FLOAT) { - if (master->type != MASTER_KEYBOARD) - master = GetPairedDevice(master); - } - else { - if (master->type != MASTER_POINTER) - master = GetPairedDevice(master); - } + if (!master) + return NULL; + + if (which == MASTER_ATTACHED) + return master; + + if (which == MASTER_KEYBOARD || which == KEYBOARD_OR_FLOAT) { + if (master->type != MASTER_KEYBOARD) + return GetPairedDevice(master); + } + else { + if (master->type != MASTER_POINTER) + return GetPairedDevice(master); } return master;