mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
treewide: apply clippy lints; remove dead code
This commit is contained in:
parent
099e5c4ba6
commit
587d6a070f
2 changed files with 6 additions and 20 deletions
|
@ -432,8 +432,8 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) ->
|
||||||
|
|
||||||
// Try each threshold path pattern for this battery
|
// Try each threshold path pattern for this battery
|
||||||
for pattern in &threshold_paths {
|
for pattern in &threshold_paths {
|
||||||
let start_threshold_path = ps_path.join(&pattern.start_path);
|
let start_threshold_path = ps_path.join(pattern.start_path);
|
||||||
let stop_threshold_path = ps_path.join(&pattern.stop_path);
|
let stop_threshold_path = ps_path.join(pattern.stop_path);
|
||||||
|
|
||||||
if start_threshold_path.exists() && stop_threshold_path.exists() {
|
if start_threshold_path.exists() && stop_threshold_path.exists() {
|
||||||
// Found a battery with threshold support
|
// Found a battery with threshold support
|
||||||
|
@ -460,8 +460,8 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) ->
|
||||||
let mut success_count = 0;
|
let mut success_count = 0;
|
||||||
|
|
||||||
for battery in supported_batteries {
|
for battery in supported_batteries {
|
||||||
let start_path = battery.path.join(&battery.pattern.start_path);
|
let start_path = battery.path.join(battery.pattern.start_path);
|
||||||
let stop_path = battery.path.join(&battery.pattern.stop_path);
|
let stop_path = battery.path.join(battery.pattern.stop_path);
|
||||||
|
|
||||||
// Attempt to set both thresholds
|
// Attempt to set both thresholds
|
||||||
match (
|
match (
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub fn get_system_info() -> SystemInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
struct CpuTimes {
|
pub struct CpuTimes {
|
||||||
user: u64,
|
user: u64,
|
||||||
nice: u64,
|
nice: u64,
|
||||||
system: u64,
|
system: u64,
|
||||||
|
@ -57,8 +57,6 @@ struct CpuTimes {
|
||||||
irq: u64,
|
irq: u64,
|
||||||
softirq: u64,
|
softirq: u64,
|
||||||
steal: u64,
|
steal: u64,
|
||||||
guest: u64,
|
|
||||||
guest_nice: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CpuTimes {
|
impl CpuTimes {
|
||||||
|
@ -147,18 +145,6 @@ fn read_all_cpu_times() -> Result<HashMap<u32, CpuTimes>> {
|
||||||
parts[8]
|
parts[8]
|
||||||
))
|
))
|
||||||
})?,
|
})?,
|
||||||
guest: parts[9].parse().map_err(|_| {
|
|
||||||
SysMonitorError::ProcStatParseError(format!(
|
|
||||||
"Failed to parse guest time: {}",
|
|
||||||
parts[9]
|
|
||||||
))
|
|
||||||
})?,
|
|
||||||
guest_nice: parts[10].parse().map_err(|_| {
|
|
||||||
SysMonitorError::ProcStatParseError(format!(
|
|
||||||
"Failed to parse guest_nice time: {}",
|
|
||||||
parts[10]
|
|
||||||
))
|
|
||||||
})?,
|
|
||||||
};
|
};
|
||||||
cpu_times_map.insert(core_id, times);
|
cpu_times_map.insert(core_id, times);
|
||||||
}
|
}
|
||||||
|
@ -288,7 +274,7 @@ pub fn get_cpu_core_info(
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let usage = 100.0 * (1.0 - (idle_diff as f32 / total_diff as f32));
|
let usage = 100.0 * (1.0 - (idle_diff as f32 / total_diff as f32));
|
||||||
Some(usage.max(0.0).min(100.0)) // clamp between 0 and 100
|
Some(usage.clamp(0.0, 100.0)) // clamp between 0 and 100
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue