Skip to content
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

Better meminfo.c IO error handling #190

Closed
wants to merge 5 commits into from

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Apr 25, 2020

Fixes #189 and also a couple other things that I found, especially in relation to errno handling.

I recommend to review them per-commit.

Please review/test them well as I haven't managed to run the test suite yet.

nh2 added 5 commits April 25, 2020 20:20
`perror()` itself is not guaranteed to not modify `errno`.
The message says "fscanf() failed: %s" but then went on to print the
`errno` of `fclose()`, not `fscanf()`.
Note this changes the behaviour of the function:

Before, it returned `-1` when `sysconf()` returned that
`_SC_PAGESIZE` was indeterminated, now it `fatal()`s.

This is because the function contract is

    // Returns the value (>= 0) or -errno on error.

and returning `-1` is not according to that contract, because
that would mean `-EPERM`.
@rfjakob
Copy link
Owner

rfjakob commented Apr 26, 2020

I have merged everything except the fread retries, 50081ce slightly edited, thanks!

@rfjakob rfjakob closed this Apr 26, 2020
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.

parse_meminfo() does not handle short reads
2 participants