cmd/utils/diskusage: fix unreachable bavail check

This commit is contained in:
mohanson 2024-04-12 17:12:51 +08:00
parent bd91810462
commit f8928d6304
2 changed files with 2 additions and 5 deletions

View file

@ -33,12 +33,10 @@ func getFreeDiskSpace(path string) (uint64, error) {
// Available blocks * size per block = available space in bytes // Available blocks * size per block = available space in bytes
var bavail = stat.Bavail var bavail = stat.Bavail
// nolint:staticcheck if int64(stat.Bavail) < 0 {
if stat.Bavail < 0 {
// FreeBSD can have a negative number of blocks available // FreeBSD can have a negative number of blocks available
// because of the grace limit. // because of the grace limit.
bavail = 0 bavail = 0
} }
//nolint:unconvert return bavail * uint64(stat.Bsize), nil
return uint64(bavail) * uint64(stat.Bsize), nil
} }

View file

@ -39,6 +39,5 @@ func getFreeDiskSpace(path string) (uint64, error) {
// because of the grace limit. // because of the grace limit.
bavail = 0 bavail = 0
} }
//nolint:unconvert
return uint64(bavail) * uint64(stat.F_bsize), nil return uint64(bavail) * uint64(stat.F_bsize), nil
} }