diff options
author | Marat Dukhan <marat@fb.com> | 2017-08-28 11:24:43 -0700 |
---|---|---|
committer | Marat Dukhan <marat@fb.com> | 2017-08-28 11:24:43 -0700 |
commit | 04c49da93279024aea2c33aade83f1cadb54a05a (patch) | |
tree | 903817e405ebf859ac4b8a0d612bede65a6bd9c4 /src/linux/processors.c | |
parent | 67d4b018a41328cda825337c4ba82bfc2a307948 (diff) | |
download | cpuinfo-04c49da93279024aea2c33aade83f1cadb54a05a.tar.gz |
Fix bug in parsing of package/core ID on Linux
Diffstat (limited to 'src/linux/processors.c')
-rw-r--r-- | src/linux/processors.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/linux/processors.c b/src/linux/processors.c index e464931..87afda4 100644 --- a/src/linux/processors.c +++ b/src/linux/processors.c @@ -40,18 +40,18 @@ #define PRESENT_CPULIST_FILENAME "/sys/devices/system/cpu/present" -inline static const char* parse_number(const char* string, const char* end, uint32_t number_ptr[restrict static 1]) { +inline static const char* parse_number(const char* start, const char* end, uint32_t number_ptr[restrict static 1]) { uint32_t number = 0; - while (string != end) { - const uint32_t digit = (uint32_t) (*string) - (uint32_t) '0'; + const char* parsed = start; + for (; parsed != end; parsed++) { + const uint32_t digit = (uint32_t) (uint8_t) (*parsed) - (uint32_t) '0'; if (digit >= 10) { break; } number = number * UINT32_C(10) + digit; - string += 1; } *number_ptr = number; - return end; + return parsed; } /* Locale-independent */ |