From: Arran Cudbard-Bell Date: Thu, 16 Sep 2021 14:06:02 +0000 (-0500) Subject: Whitespace X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23c601f92115eff687ca45f516229c3e6b92fdd8;p=thirdparty%2Ffreeradius-server.git Whitespace --- diff --git a/src/lib/util/hw.c b/src/lib/util/hw.c index 3fe36e780f..6534223ce6 100644 --- a/src/lib/util/hw.c +++ b/src/lib/util/hw.c @@ -71,30 +71,31 @@ uint32_t fr_hw_num_cores_active(void) { uint32_t lcores = 0, tsibs = 0; - char buff[32]; - char path[64]; + char buff[32]; + char path[64]; - for (lcores = 0;;lcores++) { - FILE *cpu; + for (lcores = 0;;lcores++) { + FILE *cpu; - snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%u/topology/thread_siblings_list", lcores); + snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%u/topology/thread_siblings_list", lcores); - cpu = fopen(path, "r"); - if (!cpu) break; + cpu = fopen(path, "r"); + if (!cpu) break; - while (fscanf(cpu, "%[0-9]", buff)) { - tsibs++; - if (fgetc(cpu) != ',') break; - } + while (fscanf(cpu, "%[0-9]", buff)) { + tsibs++; + if (fgetc(cpu) != ',') break; + } + + fclose(cpu); + } - fclose(cpu); - } + if (!tsibs || !lcores) return 1; /* * Prevent clang scanner from warning about divide by zero */ - tsibs = tsibs / (lcores ? lcores : 1); - return lcores / (tsibs ? tsibs : 1); + return lcores / (tsibs / lcores); } #else size_t fr_hw_cache_line_size(void)