Skip to content

Commit

Permalink
chore: clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-zlobintsev committed Oct 21, 2023
1 parent fe52ed4 commit 0107065
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions lact-daemon/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::pedantic)]
#![allow(clippy::missing_panics_doc)]

mod config;
mod fork;
Expand Down
15 changes: 8 additions & 7 deletions lact-daemon/src/server/gpu_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ impl GpuController {
}
}

pub fn get_stats(&self, gpu_config: Option<&config::Gpu>) -> anyhow::Result<DeviceStats> {
Ok(DeviceStats {
pub fn get_stats(&self, gpu_config: Option<&config::Gpu>) -> DeviceStats {
DeviceStats {
fan: FanStats {
control_enabled: gpu_config
.map(|config| config.fan_control_enabled)
.unwrap_or_default(),
control_mode: gpu_config
.and_then(|config| config.fan_control_settings.as_ref())
.map(|settings| settings.mode.clone()),
.map(|settings| settings.mode),
static_speed: gpu_config
.and_then(|config| config.fan_control_settings.as_ref())
.map(|settings| settings.static_speed),
Expand Down Expand Up @@ -274,7 +274,7 @@ impl GpuController {
core_clock_levels: self.handle.get_core_clock_levels().ok(),
memory_clock_levels: self.handle.get_memory_clock_levels().ok(),
pcie_clock_levels: self.handle.get_pcie_clock_levels().ok(),
})
}
}

pub fn get_clocks_info(&self) -> anyhow::Result<ClocksInfo> {
Expand Down Expand Up @@ -308,6 +308,7 @@ impl GpuController {
.set_fan_control_method(FanControlMethod::Manual)
.context("Could not set fan control method")?;

#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
let static_speed_converted = (f64::from(u8::MAX) * static_speed) as u8;

hw_mon
Expand Down Expand Up @@ -349,8 +350,8 @@ impl GpuController {
let handle = tokio::task::spawn_local(async move {
loop {
select! {
_ = sleep(interval) => (),
_ = task_notify.notified() => break,
() = sleep(interval) => (),
() = task_notify.notified() => break,
}

let mut temps = hw_mon.get_temps();
Expand Down Expand Up @@ -409,7 +410,7 @@ impl GpuController {
if let Some(ref settings) = config.fan_control_settings {
match settings.mode {
lact_schema::FanControlMode::Static => {
self.set_static_fan_control(settings.static_speed).await?
self.set_static_fan_control(settings.static_speed).await?;
}
lact_schema::FanControlMode::Curve => {
if settings.curve.0.is_empty() {
Expand Down
11 changes: 5 additions & 6 deletions lact-daemon/src/server/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ impl<'a> Handler {

match controller.apply_config(&new_config).await {
Ok(()) => {
self.wait_config_confirm(id, gpu_config, new_config, apply_timer)
.await?;
self.wait_config_confirm(id, gpu_config, new_config, apply_timer)?;
Ok(apply_timer)
}
Err(apply_err) => {
Expand All @@ -108,7 +107,7 @@ impl<'a> Handler {
}

/// Should be called after applying new config without writing it
async fn wait_config_confirm(
fn wait_config_confirm(
&self,
id: String,
previous_config: config::Gpu,
Expand All @@ -129,7 +128,7 @@ impl<'a> Handler {
.expect("GPU controller disappeared");

tokio::select! {
_ = tokio::time::sleep(Duration::from_secs(apply_timer)) => {
() = tokio::time::sleep(Duration::from_secs(apply_timer)) => {
info!("no confirmation received, reverting settings");

if let Err(err) = controller.apply_config(&previous_config).await {
Expand Down Expand Up @@ -197,7 +196,7 @@ impl<'a> Handler {
.try_borrow()
.map_err(|err| anyhow!("Could not read config: {err:?}"))?;
let gpu_config = config.gpus.get(id);
self.controller_by_id(id)?.get_stats(gpu_config)
Ok(self.controller_by_id(id)?.get_stats(gpu_config))
}

pub fn get_clocks_info(&'a self, id: &str) -> anyhow::Result<ClocksInfo> {
Expand Down Expand Up @@ -361,7 +360,7 @@ impl<'a> Handler {
.map(|config| config.daemon.disable_clocks_cleanup)
.unwrap_or(false);

for (id, controller) in self.gpu_controllers.iter() {
for (id, controller) in &*self.gpu_controllers {
if !disable_clocks_cleanup && controller.handle.get_clocks_table().is_ok() {
debug!("resetting clocks table");
if let Err(err) = controller.handle.reset_clocks_table() {
Expand Down
6 changes: 2 additions & 4 deletions lact-gui/src/app/root_stack/thermals_page/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,8 @@ impl ThermalsPage {
self.fan_curve_frame.set_curve(curve);
}

if !stats.fan.control_enabled {
if self.fan_curve_frame.get_curve().is_empty() {
self.fan_curve_frame.set_curve(&default_fan_curve());
}
if !stats.fan.control_enabled && self.fan_curve_frame.get_curve().is_empty() {
self.fan_curve_frame.set_curve(&default_fan_curve());
}
}
}
Expand Down

0 comments on commit 0107065

Please sign in to comment.