1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

battery: tighten treshhold validation

This commit is contained in:
NotAShelf 2025-05-15 21:07:05 +03:00
parent ded671296a
commit 759ba2a10a
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF

View file

@ -92,6 +92,11 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) ->
/// Validates that the threshold values are in acceptable ranges
fn validate_thresholds(start_threshold: u8, stop_threshold: u8) -> Result<()> {
if start_threshold == 0 || stop_threshold == 0 {
return Err(ControlError::InvalidValueError(
"Thresholds must be greater than 0%".to_string(),
));
}
if start_threshold >= stop_threshold {
return Err(ControlError::InvalidValueError(format!(
"Start threshold ({start_threshold}) must be less than stop threshold ({stop_threshold})"