Skip to content

Commit

Permalink
Merge pull request #78 from markusressel/enhancement/validate_hwmon_i…
Browse files Browse the repository at this point in the history
…d_config

added validation check for hwmon index
  • Loading branch information
markusressel authored Dec 19, 2021
2 parents 6b628f1 + 7e426f2 commit 8ba9871
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ func validateSensors(config *Configuration) {
if !isSensorConfigInUse(sensorConfig, config.Curves) {
ui.Warning("Unused sensor configuration: %s", sensorConfig.ID)
}

if sensorConfig.HwMon != nil {
if sensorConfig.HwMon.Index <= 0 {
ui.Fatal("Sensor %s: invalid index, must be >= 1", sensorConfig.ID)
}
}
}
}

Expand Down Expand Up @@ -209,5 +215,11 @@ func validateFans(config *Configuration) {
if len(fanConfig.Curve) <= 0 {
ui.Fatal("Fan %s: missing curve definition in configuration entry", fanConfig.ID)
}

if fanConfig.HwMon != nil {
if fanConfig.HwMon.Index <= 0 {
ui.Fatal("Fan %s: invalid index, must be >= 1", fanConfig.ID)
}
}
}
}

0 comments on commit 8ba9871

Please sign in to comment.