Skip to content

Commit b9f0e24

Browse files
committed
Prevent usage exceeding 100% for incorrectly reported values
1 parent 892b66e commit b9f0e24

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

table.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ func printTable(title string, m []Mount, sortBy int, cols []int) {
9191
var usage, inodeUsage float64
9292
if v.Total > 0 {
9393
usage = float64(v.Used) / float64(v.Total)
94+
if usage > 1.0 {
95+
usage = 1.0
96+
}
9497
}
9598
if v.Inodes > 0 {
9699
inodeUsage = float64(v.InodesUsed) / float64(v.Inodes)
100+
if inodeUsage > 1.0 {
101+
inodeUsage = 1.0
102+
}
97103
}
98104

99105
tab.AppendRow([]interface{}{

0 commit comments

Comments
 (0)