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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2026-01-13 17:53:55 +01:00
committed by Enrico Weigelt
parent cc48601cac
commit bd9fb86977

View File

@@ -26,6 +26,7 @@
#include <X11/X.h>
#include <sys/ioctl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
@@ -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 */