Skip to content

Commit e7586fe

Browse files
committed
Fix potential division by zero
1 parent 2de4b13 commit e7586fe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

backlightd/src/monitors.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ pub(crate) fn turn_on() -> anyhow::Result<()> {
232232

233233
pub(crate) fn get_average_brightness() -> u8 {
234234
let monitors = MONITORS.lock().unwrap();
235+
236+
if monitors.is_empty() {
237+
return 0;
238+
}
239+
235240
let mut sum: usize = 0;
236241

237242
for monitor in &*monitors {

0 commit comments

Comments
 (0)