Simplify virNodeCountThreadSiblings
Use a for loop instead of while. Do not opencode c_isxdigit and virHexToBin.
This commit is contained in:
parent
e37bcbd9b8
commit
18eb727fe9
@ -361,15 +361,9 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
|
|||||||
if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &str) < 0)
|
if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &str) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
i = 0;
|
for (i = 0; str[i] != '\0'; i++) {
|
||||||
while (str[i] != '\0') {
|
if (c_isxdigit(str[i]))
|
||||||
if (c_isdigit(str[i]))
|
ret += count_one_bits(virHexToBin(str[i]));
|
||||||
ret += count_one_bits(str[i] - '0');
|
|
||||||
else if (str[i] >= 'A' && str[i] <= 'F')
|
|
||||||
ret += count_one_bits(str[i] - 'A' + 10);
|
|
||||||
else if (str[i] >= 'a' && str[i] <= 'f')
|
|
||||||
ret += count_one_bits(str[i] - 'a' + 10);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user