Skip to content

Commit 002ba08

Browse files
authored
Merge pull request #65 from hnez/clippy-2024-03-25
Fix cargo clippy issues
2 parents 740ffac + d19ca67 commit 002ba08

File tree

8 files changed

+10
-46
lines changed

8 files changed

+10
-46
lines changed

src/backlight/demo_mode.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::str::{from_utf8, FromStr};
2222
use sysfs_class::{set_trait_method, trait_method};
2323

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

@@ -60,7 +59,6 @@ pub trait SysClass: Sized {
6059
}
6160

6261
pub trait Brightness {
63-
fn brightness(&self) -> Result<u64>;
6462
fn max_brightness(&self) -> Result<u64>;
6563
fn set_brightness(&self, val: u64) -> Result<()>;
6664
}
@@ -70,10 +68,6 @@ pub struct Backlight {
7068
}
7169

7270
impl SysClass for Backlight {
73-
fn class() -> &'static str {
74-
"backlight"
75-
}
76-
7771
unsafe fn from_path_unchecked(path: PathBuf) -> Self {
7872
Self { path }
7973
}
@@ -84,7 +78,6 @@ impl SysClass for Backlight {
8478
}
8579

8680
impl Brightness for Backlight {
87-
trait_method!(brightness parse_file u64);
8881
trait_method!(max_brightness parse_file u64);
8982
set_trait_method!("brightness", set_brightness u64);
9083
}

src/dbus/systemd.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ pub struct Service {
5959
#[derive(Clone)]
6060
pub struct Systemd {
6161
pub reboot: Arc<Topic<bool>>,
62+
#[allow(dead_code)]
6263
pub networkmanager: Service,
64+
#[allow(dead_code)]
6365
pub labgrid: Service,
66+
#[allow(dead_code)]
6467
pub iobus: Service,
6568
}
6669

src/digital_io/gpio/test.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@
1616
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1717

1818
use std::cell::RefCell;
19-
use std::iter::Iterator;
2019
use std::ops::BitOr;
2120
use std::sync::atomic::{AtomicU8, Ordering};
22-
use std::thread::sleep;
23-
use std::time::Duration;
2421

2522
use anyhow::Result;
2623
use async_std::sync::Arc;
2724

2825
std::thread_local! {
29-
static LINES: RefCell<Vec<(String, Arc<AtomicU8>)>> = RefCell::new(Vec::new());
26+
static LINES: RefCell<Vec<(String, Arc<AtomicU8>)>> = const { RefCell::new(Vec::new()) };
3027
}
3128

3229
pub struct LineHandle {
@@ -42,30 +39,6 @@ impl LineHandle {
4239
}
4340
}
4441

45-
pub struct LineEvent(u8);
46-
47-
pub struct LineEventHandle {
48-
val: Arc<AtomicU8>,
49-
prev_val: u8,
50-
}
51-
52-
impl Iterator for LineEventHandle {
53-
type Item = Result<LineEvent, ()>;
54-
55-
fn next(&mut self) -> Option<Self::Item> {
56-
loop {
57-
let val = self.val.load(Ordering::Relaxed);
58-
59-
if val != self.prev_val {
60-
self.prev_val = val;
61-
return Some(Ok(LineEvent(val)));
62-
}
63-
64-
sleep(Duration::from_millis(100));
65-
}
66-
}
67-
}
68-
6942
#[allow(clippy::upper_case_acronyms, non_camel_case_types)]
7043
#[derive(Clone, Copy)]
7144
pub enum LineRequestFlags {

src/led/demo_mode.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::io::{Error, ErrorKind, Result};
1919
use std::path::{Path, PathBuf};
2020
use std::str::{from_utf8, FromStr};
2121

22-
use sysfs_class::{set_trait_method, trait_method};
22+
use sysfs_class::trait_method;
2323

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

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

@@ -68,20 +67,14 @@ pub trait SysClass: Sized {
6867
}
6968

7069
pub trait Brightness {
71-
fn brightness(&self) -> Result<u64>;
7270
fn max_brightness(&self) -> Result<u64>;
73-
fn set_brightness(&self, val: u64) -> Result<()>;
7471
}
7572

7673
pub struct Leds {
7774
path: PathBuf,
7875
}
7976

8077
impl SysClass for Leds {
81-
fn class() -> &'static str {
82-
"leds"
83-
}
84-
8578
unsafe fn from_path_unchecked(path: PathBuf) -> Self {
8679
Self { path }
8780
}
@@ -92,7 +85,5 @@ impl SysClass for Leds {
9285
}
9386

9487
impl Brightness for Leds {
95-
trait_method!(brightness parse_file u64);
9688
trait_method!(max_brightness parse_file u64);
97-
set_trait_method!("brightness", set_brightness u64);
9889
}

src/regulators.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ use reg::regulator_set;
6767

6868
pub struct Regulators {
6969
pub iobus_pwr_en: Arc<Topic<bool>>,
70+
#[allow(dead_code)]
7071
pub uart_pwr_en: Arc<Topic<bool>>,
7172
}
7273

src/system.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ impl Barebox {
134134
}
135135

136136
pub struct System {
137+
#[allow(dead_code)]
137138
pub uname: Arc<Topic<Arc<Uname>>>,
139+
#[allow(dead_code)]
138140
pub barebox: Arc<Topic<Arc<Barebox>>>,
141+
#[allow(dead_code)]
139142
pub tacd_version: Arc<Topic<String>>,
140143
}
141144

src/ui.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct UiResources {
5151
pub rauc: crate::dbus::Rauc,
5252
pub regulators: crate::regulators::Regulators,
5353
pub setup_mode: crate::setup_mode::SetupMode,
54+
#[allow(dead_code)]
5455
pub system: crate::system::System,
5556
pub systemd: crate::dbus::Systemd,
5657
pub temperatures: crate::temperatures::Temperatures,

src/usb_hub.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use crate::watched_tasks::WatchedTasksBuilder;
3131
#[cfg(feature = "demo_mode")]
3232
mod rw {
3333
use std::collections::HashMap;
34-
use std::convert::AsRef;
3534
use std::io::Result;
3635
use std::path::Path;
3736
use std::sync::Mutex;

0 commit comments

Comments
 (0)