Fix CPU frequency parsing on Linux (#355) (#356)

* Fix reading CPU info from file

Macro CHECK do nothing for release mode, meaning it doesn't invoke the
arguments

* Add myself to AUTHORS and CONTRIBUTORS
This commit is contained in:
MVafin 2017-03-28 09:35:17 +03:00 committed by Eric
parent 94c512c043
commit ec15860da5
3 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,7 @@ Jussi Knuuttila <jussi.knuuttila@gmail.com>
Kaito Udagawa <umireon@gmail.com> Kaito Udagawa <umireon@gmail.com>
Lei Xu <eddyxu@gmail.com> Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com> Matt Clarkson <mattyclarkson@gmail.com>
Maxim Vafin <maxvafin@gmail.com>
Nick Hutchinson <nshutchinson@gmail.com> Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com> Oleksandr Sochka <sasha.sochka@gmail.com>
Paul Redmond <paul.redmond@gmail.com> Paul Redmond <paul.redmond@gmail.com>

View File

@ -41,6 +41,7 @@ Kaito Udagawa <umireon@gmail.com>
Kai Wolf <kai.wolf@gmail.com> Kai Wolf <kai.wolf@gmail.com>
Lei Xu <eddyxu@gmail.com> Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com> Matt Clarkson <mattyclarkson@gmail.com>
Maxim Vafin <maxvafin@gmail.com>
Nick Hutchinson <nshutchinson@gmail.com> Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com> Oleksandr Sochka <sasha.sochka@gmail.com>
Pascal Leroy <phl@google.com> Pascal Leroy <phl@google.com>

View File

@ -75,7 +75,9 @@ bool ReadIntFromFile(const char* file, long* value) {
char line[1024]; char line[1024];
char* err; char* err;
memset(line, '\0', sizeof(line)); memset(line, '\0', sizeof(line));
CHECK(read(fd, line, sizeof(line) - 1)); ssize_t read_err = read(fd, line, sizeof(line) - 1);
((void)read_err); // prevent unused warning
CHECK(read_err >= 0);
const long temp_value = strtol(line, &err, 10); const long temp_value = strtol(line, &err, 10);
if (line[0] != '\0' && (*err == '\n' || *err == '\0')) { if (line[0] != '\0' && (*err == '\n' || *err == '\0')) {
*value = temp_value; *value = temp_value;