Skip to content

Commit

Permalink
fixed crash when machine has no fans
Browse files Browse the repository at this point in the history
if the fan count is zero the loop to retrieve the min, max and current fan speed is entirely skipped
fixes #71
  • Loading branch information
D0miH committed Jan 20, 2020
1 parent 10adabc commit 6ef8543
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iGlance/iGlance/Components/FanComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FanComponent {
*/
func getMinFanSpeed() throws -> Int {
var minFanSpeed: Int = 0
for i in 0...fanCount-1 {
for i in 0..<fanCount {
let minSpeed = try SMCKit.fanMinSpeed(i)
if minSpeed > minFanSpeed {
minFanSpeed = minSpeed
Expand All @@ -89,7 +89,7 @@ class FanComponent {
*/
func getMaxFanSpeed() throws -> Int {
var maxFanSpeed: Int = 0
for i in 0...fanCount-1 {
for i in 0..<fanCount {
let maxSpeed = try SMCKit.fanMaxSpeed(i)
if maxSpeed > maxFanSpeed {
maxFanSpeed = maxSpeed
Expand All @@ -103,7 +103,7 @@ class FanComponent {
*/
func getCurrentFanSpeed() throws -> Int {
var currentFanSpeed: Int = 0
for i in 0...fanCount-1 {
for i in 0..<fanCount {
let currentSpeed = try SMCKit.fanCurrentSpeed(i)
if currentSpeed > currentFanSpeed {
currentFanSpeed = currentSpeed
Expand Down

0 comments on commit 6ef8543

Please sign in to comment.