Skip to content

cmd/utils/diskusage: fix unreachable bavail check #29516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

cmd/utils/diskusage: fix unreachable bavail check #29516

wants to merge 1 commit into from

Conversation

mohanson
Copy link
Contributor

@mohanson mohanson commented Apr 12, 2024

stat.Bavail's type is uint64, see: https://pkg.go.dev/golang.org/x/sys/unix#Statfs_t, so the if stat.Bavail < 0 { conditional check will never hold.

For non-FreeBSD systems, Bavail is almost impossible to be larger than 1 << 63 - 1, so I think the correct and the most convenient approach is to convert uint64 to int64 for comparison.

This code was introduced from this PR: #22310

@mohanson
Copy link
Contributor Author

Sorry, duplicate of this PR: #24844

@mohanson mohanson closed this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant