Skip to content

Commit

Permalink
restructured conditionals with more specific error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
quaternic committed Jul 3, 2024
1 parent af86cdd commit 233ef61
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions glutin/src/api/egl/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::collections::HashSet;
use std::ffi::{c_void, CStr};
use std::ptr;

use bitflags::Flags;

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, aarch64-linux-android, ubuntu-latest, apk --)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, aarch64-linux-android, ubuntu-latest, apk --)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, aarch64-linux-android, ubuntu-latest, apk --)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-pc-windows-msvc, windows-latest, --no-default-features, egl)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-pc-windows-msvc, windows-latest, --no-default-features, egl)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-msvc, windows-latest, --no-default-features, egl)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-msvc, windows-latest, --no-default-features, egl)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, aarch64-linux-android, ubuntu-latest, apk --)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check failure on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (1.70.0, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,wayland,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest, --no-default-features, egl,x11)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-gnu, windows-latest, -i686-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-msvc, windows-latest, --no-default-features, egl)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-msvc, windows-latest, --no-default-features, egl)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-msvc, windows-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-pc-windows-gnu, windows-latest, -x86_64-pc-windows-gnu)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`

Check warning on line 7 in glutin/src/api/egl/device.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, x86_64-unknown-linux-gnu, ubuntu-latest)

unused import: `bitflags::Flags`
use glutin_egl_sys::egl;
use glutin_egl_sys::egl::types::EGLDeviceEXT;

Expand Down Expand Up @@ -36,18 +37,21 @@ impl Device {
let client_extensions =
CLIENT_EXTENSIONS.get_or_init(|| get_extensions(egl, egl::NO_DISPLAY));

// Querying devices requires EGL_EXT_device_enumeration and
// EGL_EXT_device_query.
// Querying devices requires EGL_EXT_device_enumeration or EGL_EXT_device_base.
//
// Or we can check for the EGL_EXT_device_base extension since it contains both
// extensions.
if !client_extensions.contains("EGL_EXT_device_base")
&& !client_extensions.contains("EGL_EXT_device_enumeration")
{
return Err(ErrorKind::NotSupported(
"enumerating devices is not supported by the EGL instance",
)
.into());
// The former depends on EGL_EXT_device_query, so also check that for validation.
if !client_extensions.contains("EGL_EXT_device_base") {
let query = client_extensions.contains("EGL_EXT_device_query");
let enumr = client_extensions.contains("EGL_EXT_device_enumeration");
if !(query & enumr) {
let msg = if query {
"enumerating devices is not supported by the EGL instance"
} else {
// this should not happen as device_enumeration depends on device_query
"EGL_EXT_device_enumeration without EGL_EXT_device_query, buggy driver?"
};
return Err(ErrorKind::NotSupported(msg).into());
}
}

let mut device_count = 0;
Expand Down

0 comments on commit 233ef61

Please sign in to comment.