Skip to content

Commit

Permalink
clippy on udev
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Nov 20, 2023
1 parent 1acaa79 commit ec93264
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ jobs:
if: matrix.job.use-cross == false
run: |
cargo fmt -- --check
cargo clippy --all-targets
cargo clippy --all-targets --all-features
cargo clippy --all-targets -- -Dwarnings
cargo clippy --all-targets --all-features -- -Dwarnings
- name: Test
id: test
Expand Down
20 changes: 10 additions & 10 deletions src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub struct UdevInfo {
/// ```
pub fn get_udev_info(port_path: &str) -> Result<UdevInfo, Error> {
let path: String = format!("/sys/bus/usb/devices/{}", port_path);
let device = udevlib::Device::from_syspath(&Path::new(&path)).map_err(|e| {
let device = udevlib::Device::from_syspath(Path::new(&path)).map_err(|e| {
Error::new(
ErrorKind::Udev,
&format!(
"Failed to get udev info for device at {}: Error({})",
path,
e.to_string()
e
),
)
})?;
Expand All @@ -54,13 +54,13 @@ pub fn get_udev_info(port_path: &str) -> Result<UdevInfo, Error> {
/// ```
pub fn get_udev_driver_name(port_path: &str) -> Result<Option<String>, Error> {
let path: String = format!("/sys/bus/usb/devices/{}", port_path);
let device = udevlib::Device::from_syspath(&Path::new(&path)).map_err(|e| {
let device = udevlib::Device::from_syspath(Path::new(&path)).map_err(|e| {
Error::new(
ErrorKind::Udev,
&format!(
"Failed to get udev info for device at {}: Error({})",
path,
e.to_string()
e
),
)
})?;
Expand All @@ -79,13 +79,13 @@ pub fn get_udev_driver_name(port_path: &str) -> Result<Option<String>, Error> {
/// ```
pub fn get_udev_syspath(port_path: &str) -> Result<Option<String>, Error> {
let path: String = format!("/sys/bus/usb/devices/{}", port_path);
let device = udevlib::Device::from_syspath(&Path::new(&path)).map_err(|e| {
let device = udevlib::Device::from_syspath(Path::new(&path)).map_err(|e| {
Error::new(
ErrorKind::Udev,
&format!(
"Failed to get udev info for device at {}: Error({})",
path,
e.to_string()
e
),
)
})?;
Expand All @@ -112,14 +112,14 @@ pub fn get_udev_attribute<T: AsRef<std::ffi::OsStr> + std::fmt::Display>(
attribute: T,
) -> Result<Option<String>, Error> {
let path: String = format!("/sys/bus/usb/devices/{}", port_path);
let device = udevlib::Device::from_syspath(&Path::new(&path)).map_err(|e| {
let device = udevlib::Device::from_syspath(Path::new(&path)).map_err(|e| {
Error::new(
ErrorKind::Udev,
&format!(
"Failed to get udev attribute {} for device at {}: Error({})",
attribute,
path,
e.to_string()
e
),
)
})?;
Expand Down Expand Up @@ -150,7 +150,7 @@ pub fn hwdb_get(modalias: &str, key: &'static str) -> Result<Option<String>, Err
let hwdb = udevlib::Hwdb::new().map_err(|e| {
Error::new(
ErrorKind::Udev,
&format!("Failed to get hwdb: Error({})", e.to_string()),
&format!("Failed to get hwdb: Error({})", e),
)
})?;

Expand All @@ -169,7 +169,7 @@ mod tests {
fn test_udev_info() {
let udevi = get_udev_info("1-0:1.0").unwrap();
assert_eq!(udevi.driver, Some("hub".into()));
assert_eq!(udevi.syspath.unwrap().contains("usb1/1-0:1.0"), true);
assert!(udevi.syspath.unwrap().contains("usb1/1-0:1.0"));
}

/// Tests can lookup bInterfaceClass of the root hub, which is always 09
Expand Down

0 comments on commit ec93264

Please sign in to comment.