diff options
| author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-10-11 15:39:38 +0200 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-10-11 15:39:38 +0200 |
| commit | 8af4b3d7044d83c5426da6e45a9c7948bc7fa231 (patch) | |
| tree | 76e15a6cea6b526fe30c679f6e9bf60b08acf983 /tools/testing/selftests/bpf/bpf_util.h | |
| parent | a5950f2617f71a3dce16520c4907bcdb31e654ba (diff) | |
| parent | c2ebf788f927dcca72beead19fab5f5aba79a098 (diff) | |
Merge branch 'acpi-pm' into pm-sleep
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_util.h')
| -rw-r--r-- | tools/testing/selftests/bpf/bpf_util.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h index 20ecbaa0d85d..6c53a8906eff 100644 --- a/tools/testing/selftests/bpf/bpf_util.h +++ b/tools/testing/selftests/bpf/bpf_util.h @@ -12,6 +12,7 @@ static inline unsigned int bpf_num_possible_cpus(void) unsigned int start, end, possible_cpus = 0; char buff[128]; FILE *fp; + int n; fp = fopen(fcpu, "r"); if (!fp) { @@ -20,17 +21,17 @@ static inline unsigned int bpf_num_possible_cpus(void) } while (fgets(buff, sizeof(buff), fp)) { - if (sscanf(buff, "%u-%u", &start, &end) == 2) { - possible_cpus = start == 0 ? end + 1 : 0; - break; + n = sscanf(buff, "%u-%u", &start, &end); + if (n == 0) { + printf("Failed to retrieve # possible CPUs!\n"); + exit(1); + } else if (n == 1) { + end = start; } + possible_cpus = start == 0 ? end + 1 : 0; + break; } - fclose(fp); - if (!possible_cpus) { - printf("Failed to retrieve # possible CPUs!\n"); - exit(1); - } return possible_cpus; } |
