Skip to content

Fix non-functional error-check in cpucycles() - #3

Open
Gnoxter wants to merge 1 commit into
thoughtpolice:masterfrom
Gnoxter:master
Open

Fix non-functional error-check in cpucycles()#3
Gnoxter wants to merge 1 commit into
thoughtpolice:masterfrom
Gnoxter:master

Conversation

@Gnoxter

@Gnoxter Gnoxter commented May 2, 2016

Copy link
Copy Markdown

read() returns a ssize_t while sizeof() is a
size_t. Thus the ssize_t is promoted to an
unsigned integer. This leads to
misinterpreting a -1 returned by read()
on an error condition as successful read().

This commit fixes this by casting the sizeof()
to an ssize_t. Alternatively a == -1 check should
be sufficient as one would expect perf
to make the requested data available in proper size
or fail accordingly.

Signed-off-by: Gnoxter gnoxter@linuxlounge.net

read() returns a ssize_t while sizeof() is a
size_t. Thus the ssize_t is promoted to an
unsigned integer. This leads to
misinterpreting a -1 returned by read()
on an error condition as successful read().

This commit fixes this by casting the sizeof()
to an ssize_t. Alternatively a == -1 check should
be sufficient as one would expect perf
to make the requested data available in proper size
or fail accordingly.

Signed-off-by: Gnoxter <gnoxter@linuxlounge.net>
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