Fix QF1003: could use tagged switch on ... (staticcheck)

This commit is contained in:
Holger Obermaier
2026-02-04 10:56:17 +01:00
parent 12ab80ccad
commit faf5088385
3 changed files with 10 additions and 8 deletions

View File

@@ -118,13 +118,14 @@ func (m *IpmiCollector) readIpmiTool(cmd string, output chan lp.CCMessage) {
if err == nil {
name := strings.ToLower(strings.ReplaceAll(strings.TrimSpace(lv[0]), " ", "_"))
unit := strings.TrimSpace(lv[2])
if unit == "Volts" {
switch unit {
case "Volts":
unit = "Volts"
} else if unit == "degrees C" {
case "degrees C":
unit = "degC"
} else if unit == "degrees F" {
case "degrees F":
unit = "degF"
} else if unit == "Watts" {
case "Watts":
unit = "Watts"
}

View File

@@ -405,7 +405,8 @@ func readEccMode(device *NvidiaCollectorDevice, output chan lp.CCMessage) error
// Changing ECC modes requires a reboot.
// The "pending" ECC mode refers to the target mode following the next reboot.
_, ecc_pend, ret := nvml.DeviceGetEccMode(device.device)
if ret == nvml.SUCCESS {
switch ret {
case nvml.SUCCESS:
var y lp.CCMessage
var err error
switch ecc_pend {
@@ -419,7 +420,7 @@ func readEccMode(device *NvidiaCollectorDevice, output chan lp.CCMessage) error
if err == nil {
output <- y
}
} else if ret == nvml.ERROR_NOT_SUPPORTED {
case nvml.ERROR_NOT_SUPPORTED:
y, err := lp.NewMessage("nv_ecc_mode", device.tags, device.meta, map[string]interface{}{"value": "N/A"}, time.Now())
if err == nil {
output <- y

View File

@@ -108,8 +108,8 @@ func (m *SchedstatCollector) ParseProcLine(linefields []string, tags map[string]
diff_running := running - m.olddata[linefields[0]]["running"]
diff_waiting := waiting - m.olddata[linefields[0]]["waiting"]
var l_running float64 = float64(diff_running) / tsdelta.Seconds() / 1000_000_000
var l_waiting float64 = float64(diff_waiting) / tsdelta.Seconds() / 1000_000_000
l_running := float64(diff_running) / tsdelta.Seconds() / 1000_000_000
l_waiting := float64(diff_waiting) / tsdelta.Seconds() / 1000_000_000
m.olddata[linefields[0]]["running"] = running
m.olddata[linefields[0]]["waiting"] = waiting