From bd9fb86977c7e634200b059379ac7eb1f548301b Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 13 Jan 2026 17:53:55 +0100 Subject: [PATCH] xfree86: os-support: bsd: move fd assignment into probe functions Instead of returning the fd, assign it into xf86Info.consoleFd directly from within the console probe functions (they're already assigning other fields anyways) and turn the return value into bool (just report success). Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/os-support/bsd/bsd_init.c | 31 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index e70d554d86..c462420d9d 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -86,20 +87,20 @@ static int initialVT = -1; * an X server. */ #ifdef SYSCONS_SUPPORT -static int xf86OpenSyscons(void); +static bool xf86OpenSyscons(void); #endif /* SYSCONS_SUPPORT */ #ifdef PCVT_SUPPORT -static int xf86OpenPcvt(void); +static bool xf86OpenPcvt(void); #endif /* PCVT_SUPPORT */ #ifdef WSCONS_SUPPORT -static int xf86OpenWScons(void); +static bool xf86OpenWScons(void); #endif typedef struct console_driver { const char *name; - int (*open) (void); + bool (*open) (void); } console_driver_t; /* @@ -206,11 +207,9 @@ xf86OpenConsole(void) } } - xf86Info.consoleFd = -1; - /* detect which driver we are running on */ for (unsigned idx=0; idx < ARRAY_SIZE(console_drivers); idx++) { - if ((xf86Info.consoleFd = console_drivers[idx].open()) >= 0) + if (console_drivers[idx].open()) break; } @@ -281,8 +280,7 @@ xf86OpenConsole(void) #ifdef SYSCONS_SUPPORT -static int -xf86OpenSyscons(void) +static bool xf86OpenSyscons(void) { int fd = -1; vtmode_t vtmode; @@ -380,15 +378,15 @@ xf86OpenSyscons(void) fd = -1; } } - return fd; + xf86Info.consoleFd = fd; + return (fd > 0); } #endif /* SYSCONS_SUPPORT */ #ifdef PCVT_SUPPORT -static int -xf86OpenPcvt(void) +static bool xf86OpenPcvt(void) { /* This looks much like syscons, since pcvt is API compatible */ int fd = -1; @@ -481,15 +479,15 @@ xf86OpenPcvt(void) } #endif } - return fd; + xf86Info.consoleFd = fd; + return (fd > 0); } #endif /* PCVT_SUPPORT */ #ifdef WSCONS_SUPPORT -static int -xf86OpenWScons(void) +static bool xf86OpenWScons(void) { int fd = -1; int mode = WSDISPLAYIO_MODE_MAPPED; @@ -514,7 +512,8 @@ xf86OpenWScons(void) xf86Info.consType = WSCONS; LogMessageVerb(X_PROBED, 1, "Using wscons driver\n"); } - return fd; + xf86Info.consoleFd = fd; + return (fd > 0); } #endif /* WSCONS_SUPPORT */