Skip to content

Commit

Permalink
Merge pull request #65 from hnez/clippy-2024-03-25
Browse files Browse the repository at this point in the history
Fix cargo clippy issues
  • Loading branch information
hnez committed Apr 2, 2024
2 parents 740ffac + d19ca67 commit 002ba08
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 46 deletions.
7 changes: 0 additions & 7 deletions src/backlight/demo_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use std::str::{from_utf8, FromStr};
use sysfs_class::{set_trait_method, trait_method};

pub trait SysClass: Sized {
fn class() -> &'static str;
unsafe fn from_path_unchecked(path: PathBuf) -> Self;
fn path(&self) -> &Path;

Expand Down Expand Up @@ -60,7 +59,6 @@ pub trait SysClass: Sized {
}

pub trait Brightness {
fn brightness(&self) -> Result<u64>;
fn max_brightness(&self) -> Result<u64>;
fn set_brightness(&self, val: u64) -> Result<()>;
}
Expand All @@ -70,10 +68,6 @@ pub struct Backlight {
}

impl SysClass for Backlight {
fn class() -> &'static str {
"backlight"
}

unsafe fn from_path_unchecked(path: PathBuf) -> Self {
Self { path }
}
Expand All @@ -84,7 +78,6 @@ impl SysClass for Backlight {
}

impl Brightness for Backlight {
trait_method!(brightness parse_file u64);
trait_method!(max_brightness parse_file u64);
set_trait_method!("brightness", set_brightness u64);
}
3 changes: 3 additions & 0 deletions src/dbus/systemd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ pub struct Service {
#[derive(Clone)]
pub struct Systemd {
pub reboot: Arc<Topic<bool>>,
#[allow(dead_code)]
pub networkmanager: Service,
#[allow(dead_code)]
pub labgrid: Service,
#[allow(dead_code)]
pub iobus: Service,
}

Expand Down
29 changes: 1 addition & 28 deletions src/digital_io/gpio/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

use std::cell::RefCell;
use std::iter::Iterator;
use std::ops::BitOr;
use std::sync::atomic::{AtomicU8, Ordering};
use std::thread::sleep;
use std::time::Duration;

use anyhow::Result;
use async_std::sync::Arc;

std::thread_local! {
static LINES: RefCell<Vec<(String, Arc<AtomicU8>)>> = RefCell::new(Vec::new());
static LINES: RefCell<Vec<(String, Arc<AtomicU8>)>> = const { RefCell::new(Vec::new()) };
}

pub struct LineHandle {
Expand All @@ -42,30 +39,6 @@ impl LineHandle {
}
}

pub struct LineEvent(u8);

pub struct LineEventHandle {
val: Arc<AtomicU8>,
prev_val: u8,
}

impl Iterator for LineEventHandle {
type Item = Result<LineEvent, ()>;

fn next(&mut self) -> Option<Self::Item> {
loop {
let val = self.val.load(Ordering::Relaxed);

if val != self.prev_val {
self.prev_val = val;
return Some(Ok(LineEvent(val)));
}

sleep(Duration::from_millis(100));
}
}
}

#[allow(clippy::upper_case_acronyms, non_camel_case_types)]
#[derive(Clone, Copy)]
pub enum LineRequestFlags {
Expand Down
11 changes: 1 addition & 10 deletions src/led/demo_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::io::{Error, ErrorKind, Result};
use std::path::{Path, PathBuf};
use std::str::{from_utf8, FromStr};

use sysfs_class::{set_trait_method, trait_method};
use sysfs_class::trait_method;

const FILES_READ: &[(&str, &str)] = &[
("tac:green:out0/max_brightness", "1"),
Expand All @@ -30,7 +30,6 @@ const FILES_READ: &[(&str, &str)] = &[
];

pub trait SysClass: Sized {
fn class() -> &'static str;
unsafe fn from_path_unchecked(path: PathBuf) -> Self;
fn path(&self) -> &Path;

Expand Down Expand Up @@ -68,20 +67,14 @@ pub trait SysClass: Sized {
}

pub trait Brightness {
fn brightness(&self) -> Result<u64>;
fn max_brightness(&self) -> Result<u64>;
fn set_brightness(&self, val: u64) -> Result<()>;
}

pub struct Leds {
path: PathBuf,
}

impl SysClass for Leds {
fn class() -> &'static str {
"leds"
}

unsafe fn from_path_unchecked(path: PathBuf) -> Self {
Self { path }
}
Expand All @@ -92,7 +85,5 @@ impl SysClass for Leds {
}

impl Brightness for Leds {
trait_method!(brightness parse_file u64);
trait_method!(max_brightness parse_file u64);
set_trait_method!("brightness", set_brightness u64);
}
1 change: 1 addition & 0 deletions src/regulators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ use reg::regulator_set;

pub struct Regulators {
pub iobus_pwr_en: Arc<Topic<bool>>,
#[allow(dead_code)]
pub uart_pwr_en: Arc<Topic<bool>>,
}

Expand Down
3 changes: 3 additions & 0 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ impl Barebox {
}

pub struct System {
#[allow(dead_code)]
pub uname: Arc<Topic<Arc<Uname>>>,
#[allow(dead_code)]
pub barebox: Arc<Topic<Arc<Barebox>>>,
#[allow(dead_code)]
pub tacd_version: Arc<Topic<String>>,
}

Expand Down
1 change: 1 addition & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct UiResources {
pub rauc: crate::dbus::Rauc,
pub regulators: crate::regulators::Regulators,
pub setup_mode: crate::setup_mode::SetupMode,
#[allow(dead_code)]
pub system: crate::system::System,
pub systemd: crate::dbus::Systemd,
pub temperatures: crate::temperatures::Temperatures,
Expand Down
1 change: 0 additions & 1 deletion src/usb_hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::watched_tasks::WatchedTasksBuilder;
#[cfg(feature = "demo_mode")]
mod rw {
use std::collections::HashMap;
use std::convert::AsRef;
use std::io::Result;
use std::path::Path;
use std::sync::Mutex;
Expand Down

0 comments on commit 002ba08

Please sign in to comment.