Skip to content

Commit e57cc17

Browse files
pastaqShadowApex
authored andcommitted
fix(build): Fix build warnings and make test build errors
1 parent f246f6e commit e57cc17

File tree

12 files changed

+44
-42
lines changed

12 files changed

+44
-42
lines changed

src/config/capability_map.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ pub fn load_capability_mappings() -> HashMap<String, CapabilityMapConfig> {
2727
// Try to load the capability map
2828
log::trace!("Found file: {}", file.display());
2929
let mapping = CapabilityMapConfig::from_yaml_file(file.display().to_string());
30-
if mapping.is_err() {
31-
log::warn!(
32-
"Failed to parse capability mapping: {}",
33-
mapping.unwrap_err()
34-
);
35-
continue;
36-
}
37-
let map = mapping.unwrap();
30+
let map = match mapping {
31+
Ok(map) => map,
32+
Err(e) => {
33+
log::warn!("Failed to parse capability mapping: {e}",);
34+
continue;
35+
}
36+
};
3837
mappings.insert(map.id(), map);
3938
}
4039

src/dbus/interface/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,4 @@ pub trait Unregisterable {
252252
}
253253
}
254254

255-
type UnregisterFn = (dyn std::ops::Fn(Connection, String) + 'static + Send + Sync);
255+
type UnregisterFn = dyn std::ops::Fn(Connection, String) + 'static + Send + Sync;

src/dbus/interface/target/touchscreen.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ use zbus_macros::interface;
55
/// The [TargetTouchscreenInterface] provides a DBus interface that can be exposed for managing
66
/// a [TouchscreenDevice]. It works by sending command messages to a channel that the
77
/// [TouchscreenDevice] is listening on.
8+
#[allow(dead_code)]
89
pub struct TargetTouchscreenInterface {}
910

1011
impl TargetTouchscreenInterface {
12+
#[allow(dead_code)]
1113
pub fn new() -> TargetTouchscreenInterface {
1214
TargetTouchscreenInterface {}
1315
}
@@ -23,6 +25,7 @@ impl Default for TargetTouchscreenInterface {
2325
impl TargetTouchscreenInterface {
2426
/// Name of the target device
2527
#[zbus(property)]
28+
#[allow(dead_code)]
2629
async fn name(
2730
&self,
2831
#[zbus(connection)] conn: &Connection,

src/drivers/unified_gamepad/reports.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl From<u8> for ReportType {
6060

6161
/// Feature report types
6262
#[derive(PrimitiveEnum_u8, Clone, Copy, PartialEq, Debug)]
63+
#[allow(dead_code)]
6364
pub enum FeatureReportType {
6465
/// Instruct the driver to return a feature report with the available capabilities
6566
GetInputCapabilities = 0x01,

src/input/composite_device/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5);
2424
#[derive(Error, Debug)]
2525
pub enum ClientError {
2626
#[error("failed to send command to device: {0}")]
27-
SendError(SendError<CompositeCommand>),
27+
SendError(String),
2828
#[error("service encountered an error processing the request: {0}")]
2929
ServiceError(Box<dyn std::error::Error>),
3030
#[error("device no longer exists")]
@@ -33,7 +33,7 @@ pub enum ClientError {
3333

3434
impl From<SendError<CompositeCommand>> for ClientError {
3535
fn from(err: SendError<CompositeCommand>) -> Self {
36-
Self::SendError(err)
36+
Self::SendError(err.to_string())
3737
}
3838
}
3939

src/input/composite_device/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,7 @@ impl CompositeDevice {
730730

731731
// Only send valid events to the target device(s)
732732
if cap == Capability::NotImplemented {
733-
log::trace!(
734-
"Refusing to send '{}' event to target devices.",
735-
cap.to_string()
736-
);
733+
log::trace!("Refusing to send '{cap}' event to target devices.");
737734
return Ok(());
738735
}
739736

src/input/event/evdev.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -936,13 +936,15 @@ fn input_event_from_value(
936936
// the minimum and maximum values for that axis depending on the
937937
// axis direction. This is typically done for DPad button input that
938938
// needs to be translated to an ABS_HAT axis input.
939-
if axis_info.is_some() && axis_direction.is_some() {
940-
let info = axis_info.unwrap();
941-
let direction = axis_direction.unwrap();
942-
match direction {
943-
AxisDirection::None => Some(value),
944-
AxisDirection::Positive => Some(info.maximum() * value),
945-
AxisDirection::Negative => Some(info.minimum() * value),
939+
if let Some(info) = axis_info {
940+
if let Some(direction) = axis_direction {
941+
match direction {
942+
AxisDirection::None => Some(value),
943+
AxisDirection::Positive => Some(info.maximum() * value),
944+
AxisDirection::Negative => Some(info.minimum() * value),
945+
}
946+
} else {
947+
Some(value)
946948
}
947949
} else {
948950
Some(value)
@@ -971,8 +973,8 @@ fn input_event_from_value(
971973
// Cannot denormalize value without axis info
972974
EventType::ABSOLUTE => None,
973975
EventType::RELATIVE => match RelativeAxisCode(code) {
974-
RelativeAxisCode::REL_X => Some(x? as i32),
975-
RelativeAxisCode::REL_Y => Some(y? as i32),
976+
RelativeAxisCode::REL_X => x.map(|v| v as i32),
977+
RelativeAxisCode::REL_Y => y.map(|v| v as i32),
976978
_ => None,
977979
},
978980
_ => None,

src/input/manager.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl Manager {
299299
let path = device.keys().next().cloned();
300300
let response = match path {
301301
Some(path) => Ok(path),
302-
None => Err(ManagerError::CreateTargetDeviceFailed(
302+
_ => Err(ManagerError::CreateTargetDeviceFailed(
303303
"Unable to find device path".to_string(),
304304
)),
305305
};
@@ -860,7 +860,7 @@ impl Manager {
860860
let tx = self.tx.clone();
861861
let task = tokio::spawn(async move {
862862
if let Err(e) = device.run().await {
863-
log::error!("Error running {composite_path}: {}", e.to_string());
863+
log::error!("Error running {composite_path}: {e}");
864864
}
865865
log::debug!("Composite device stopped running: {composite_path}");
866866
if let Err(e) = tx
@@ -870,8 +870,7 @@ impl Manager {
870870
.await
871871
{
872872
log::error!(
873-
"Error sending to composite device {composite_path} the stopped signal: {}",
874-
e.to_string()
873+
"Error sending to composite device {composite_path} the stopped signal: {e}"
875874
);
876875
}
877876
});
@@ -1009,7 +1008,7 @@ impl Manager {
10091008
}
10101009

10111010
// Check if the composite device has to be unique (default to being unique)
1012-
if source_device.unique.map_or_else(|| true, |unique| unique) {
1011+
if source_device.unique.unwrap_or(true) {
10131012
log::trace!(
10141013
"Found unique device {:?}, not adding to composite device {composite_device}",
10151014
source_device
@@ -1659,15 +1658,16 @@ impl Manager {
16591658
// Try to load the composite device profile
16601659
log::trace!("Found file: {}", file.display());
16611660
let device = CompositeDeviceConfig::from_yaml_file(file.display().to_string());
1662-
if device.is_err() {
1663-
log::warn!(
1664-
"Failed to parse composite device config '{}': {}",
1665-
file.display(),
1666-
device.unwrap_err()
1667-
);
1668-
continue;
1669-
}
1670-
let device = device.unwrap();
1661+
let device = match device {
1662+
Ok(dev) => dev,
1663+
Err(e) => {
1664+
log::warn!(
1665+
"Failed to parse composite device config '{}': {e}",
1666+
file.display()
1667+
);
1668+
continue;
1669+
}
1670+
};
16711671
devices.push((file, device));
16721672
}
16731673

src/input/source/evdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub enum EventDevice {
4444
}
4545

4646
impl SourceDeviceCompatible for EventDevice {
47-
fn get_device_ref(&self) -> DeviceInfoRef {
47+
fn get_device_ref(&self) -> DeviceInfoRef<'_> {
4848
match self {
4949
EventDevice::Blocked(source_driver) => source_driver.info_ref(),
5050
EventDevice::Gamepad(source_driver) => source_driver.info_ref(),

src/input/source/hidraw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub enum HidRawDevice {
8585
}
8686

8787
impl SourceDeviceCompatible for HidRawDevice {
88-
fn get_device_ref(&self) -> DeviceInfoRef {
88+
fn get_device_ref(&self) -> DeviceInfoRef<'_> {
8989
match self {
9090
HidRawDevice::Blocked(source_driver) => source_driver.info_ref(),
9191
HidRawDevice::DualSense(source_driver) => source_driver.info_ref(),

0 commit comments

Comments
 (0)