mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-15 08:56:26 -05:00
backend/session: allow wlr_session_find_gpus to return an error
Sometimes wlr_session_find_gpus will encounter an error. This is different from finding zero GPUs. On error, wlr_session_find_gpus already returns -1. However, this is casted to size_t, so callers uncorrectly assume this is a success. Instead, make wlr_session_find_gpus return a ssize_t and allow callers to handle the error accordingly.
This commit is contained in:
parent
7febdc7334
commit
e8d56ca415
3 changed files with 12 additions and 7 deletions
|
|
@ -150,11 +150,16 @@ static struct wlr_backend *attempt_noop_backend(struct wl_display *display) {
|
|||
static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
|
||||
struct wlr_backend *backend, struct wlr_session *session) {
|
||||
struct wlr_device *gpus[8];
|
||||
size_t num_gpus = wlr_session_find_gpus(session, 8, gpus);
|
||||
struct wlr_backend *primary_drm = NULL;
|
||||
ssize_t num_gpus = wlr_session_find_gpus(session, 8, gpus);
|
||||
if (num_gpus < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to find GPUs");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "Found %zu GPUs", num_gpus);
|
||||
|
||||
for (size_t i = 0; i < num_gpus; ++i) {
|
||||
struct wlr_backend *primary_drm = NULL;
|
||||
for (size_t i = 0; i < (size_t)num_gpus; ++i) {
|
||||
struct wlr_backend *drm = wlr_drm_backend_create(display, session,
|
||||
gpus[i], primary_drm);
|
||||
if (!drm) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue