Merge pull request #18117 from vjpai/use_result

Avoid unused result warning
pull/18034/head
Vijay Pai 6 years ago committed by GitHub
commit bf2b0e5220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/cpp/server/load_reporter/get_cpu_stats_linux.cc

@ -32,7 +32,10 @@ std::pair<uint64_t, uint64_t> GetCpuStatsImpl() {
FILE* fp;
fp = fopen("/proc/stat", "r");
uint64_t user, nice, system, idle;
fscanf(fp, "cpu %lu %lu %lu %lu", &user, &nice, &system, &idle);
if (fscanf(fp, "cpu %lu %lu %lu %lu", &user, &nice, &system, &idle) != 4) {
// Something bad happened with the information, so assume it's all invalid
user = nice = system = idle = 0;
}
fclose(fp);
busy = user + nice + system;
total = busy + idle;

Loading…
Cancel
Save