From 5ca776aaba0cb55ee5ce1ae9417e166457f74449 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 3 Sep 2025 11:48:37 +0200 Subject: [PATCH] test: misc: turn set_screen() macro into an inline function * a bit more type-safe and cleaner to read * cache the screen pointer on cache * preparation for upcoming refactoring of screen array access Signed-off-by: Enrico Weigelt, metux IT consult --- test/misc.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/misc.c b/test/misc.c index 5dbe8cade1..b282f0e970 100644 --- a/test/misc.c +++ b/test/misc.c @@ -64,23 +64,30 @@ dix_version_compare(void) assert(rc < 0); } +static inline void set_screen(unsigned int idx, short x, short y, short w, short h) +{ + ScreenPtr pScreen = screenInfo.screens[idx]; + pScreen->x = x; + pScreen->y = y; + pScreen->width = w; + pScreen->height = h; +} + static void dix_update_desktop_dimensions(void) { int i; - int x, y, w, h; - int w2, h2; ScreenRec screens[MAXSCREENS]; for (i = 0; i < MAXSCREENS; i++) screenInfo.screens[i] = &screens[i]; - x = 0; - y = 0; - w = 10; - h = 5; - w2 = 35; - h2 = 25; + short x = 0; + short y = 0; + short w = 10; + short h = 5; + short w2 = 35; + short h2 = 25; #define assert_dimensions(_x, _y, _w, _h) \ update_desktop_dimensions(); \ @@ -89,12 +96,6 @@ dix_update_desktop_dimensions(void) assert(screenInfo.width == _w); \ assert(screenInfo.height == _h); -#define set_screen(idx, _x, _y, _w, _h) \ - screenInfo.screens[idx]->x = _x; \ - screenInfo.screens[idx]->y = _y; \ - screenInfo.screens[idx]->width = _w; \ - screenInfo.screens[idx]->height = _h; \ - /* single screen */ screenInfo.numScreens = 1; set_screen(0, x, y, w, h);