From: Ján Tomko Date: Tue, 2 Jun 2015 12:29:54 +0000 (+0200) Subject: Simplify virNodeCountThreadSiblings X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=18eb727fe9229e5ef729c64930ae0a196c82a33d;p=libvirt.git Simplify virNodeCountThreadSiblings Use a for loop instead of while. Do not opencode c_isxdigit and virHexToBin. --- diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 9db32337ba..2fafe2d567 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -361,15 +361,9 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu) if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &str) < 0) goto cleanup; - i = 0; - while (str[i] != '\0') { - if (c_isdigit(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++; + for (i = 0; str[i] != '\0'; i++) { + if (c_isxdigit(str[i])) + ret += count_one_bits(virHexToBin(str[i])); } cleanup: