summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrare-magma <nun0@posteo.co>2022-06-08 18:37:41 +0200
committerrare-magma <nun0@posteo.co>2022-06-08 18:37:41 +0200
commit3704569b810211b7e31688d9b965736bdbba6155 (patch)
tree511eb3219815832f6cf311807da50df865b8dcf6
parent7f90fef35466c20860ab171a279d9a4cb98d84b6 (diff)
use defer to close smart stream
-rw-r--r--devices/temp_nix.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/devices/temp_nix.go b/devices/temp_nix.go
index 70cf91c..7fa3613 100644
--- a/devices/temp_nix.go
+++ b/devices/temp_nix.go
@@ -45,19 +45,19 @@ func getTemps(temps map[string]int) map[string]error {
log.Println(err)
continue
}
+ defer dev.Close()
+
switch sm := dev.(type) {
case *smart.SataDevice:
data, _ := sm.ReadSMARTData()
for _, attr := range data.Attrs {
if attr.Id == 194 {
temps[disk.Name+"_"+disk.Model] = int(attr.Value)
- sm.Close()
}
}
case *smart.NVMeDevice:
data, _ := sm.ReadSMART()
temps[disk.Name+"_"+disk.Model] = int(data.Temperature)
- sm.Close()
default:
}
}