diff --git a/fs/accounting/stats_groups_test.go b/fs/accounting/stats_groups_test.go index 8c02229e7..b7a817824 100644 --- a/fs/accounting/stats_groups_test.go +++ b/fs/accounting/stats_groups_test.go @@ -237,5 +237,14 @@ func TestCountError(t *testing.T) { } func percentDiff(start, end uint64) uint64 { - return (start - end) * 100 / start + if start == 0 { + return 0 // Handle zero start value to avoid division by zero + } + var diff uint64 + if end > start { + diff = end - start // Handle case where end is larger than start + } else { + diff = start - end + } + return (diff * 100) / start }