Fix hwmon error capture (#2915)
Fix golangci-lint "ineffectual assignment" by correctly capturing any errors within the hwmon gathering loop. Signed-off-by: Ben Kochie <superq@gmail.com>pull/2917/head
parent
fe78e7e51a
commit
29fca60a45
|
@ -444,6 +444,7 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastErr error
|
||||||
for _, hwDir := range hwmonFiles {
|
for _, hwDir := range hwmonFiles {
|
||||||
hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name())
|
hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name())
|
||||||
fileInfo, err := os.Lstat(hwmonXPathName)
|
fileInfo, err := os.Lstat(hwmonXPathName)
|
||||||
|
@ -462,10 +463,10 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastErr := c.updateHwmon(ch, hwmonXPathName); lastErr != nil {
|
if err = c.updateHwmon(ch, hwmonXPathName); err != nil {
|
||||||
err = lastErr
|
lastErr = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return lastErr
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue