[freebsd] fix SwapMemory for hosts without swap

This commit is contained in:
Nikolay Sivko 2015-11-23 12:44:35 +03:00
parent d49c4afc40
commit d4e648e253
1 changed files with 3 additions and 4 deletions

View File

@ -91,7 +91,6 @@ func SwapMemory() (*SwapMemoryStat, error) {
if err != nil {
return nil, err
}
var ret *SwapMemoryStat
for _, line := range strings.Split(string(out), "\n") {
values := strings.Fields(line)
// skip title line
@ -117,13 +116,13 @@ func SwapMemory() (*SwapMemoryStat, error) {
return nil, err
}
ret = &SwapMemoryStat{
return &SwapMemoryStat{
Total: total_v,
Used: used_v,
Free: free_v,
UsedPercent: up_v,
}
}, nil
}
return ret, nil
return nil, errors.New("no swap devices found")
}