Skip to content

Fix error handling of getloadavg - #1974

Merged
LebedevRI merged 1 commit into
google:mainfrom
mark-horvath-arm:getloadavg-fix
Apr 29, 2025
Merged

Fix error handling of getloadavg#1974
LebedevRI merged 1 commit into
google:mainfrom
mark-horvath-arm:getloadavg-fix

Conversation

@mark-horvath-arm

Copy link
Copy Markdown
Contributor

getloadavg returns with -1 if cannot obtain load average, but the current source casts the return value to size_t right away. The cast result for such a case is probably maximum unsigned long int, so the resizing of the res vector is certainly going to fail.

This change keeps the original return type of getloadavg and casts it just before the resizing of the res vector.

getloadavg returns with -1 if cannot obtain load average, but the
current source casts the return value to size_t right away. The cast
result for such a case is probably maximum unsigned long int, so the
resizing of the res vector is certainly going to fail.

This change keeps the original return type of getloadavg and casts it
just before the resizing of the res vector.

@LebedevRI LebedevRI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants