diff options
author | Chih-Hung Hsieh <chh@google.com> | 2022-12-20 13:19:16 -0800 |
---|---|---|
committer | Chih-hung Hsieh <chh@google.com> | 2023-01-13 22:55:08 +0000 |
commit | 30c31fd8ee8e7ae1be3ff5f2138adfa38838f479 (patch) | |
tree | 30a6f97c4343591d7d9d80ba0e717814e5432e6d /boottime_tools | |
parent | dfbfb9cccaf4d68d91d18dd645b0acb87c474e0c (diff) | |
download | extras-30c31fd8ee8e7ae1be3ff5f2138adfa38838f479.tar.gz |
Fix uninitialized value warnings.
* Also applied clang-format.
Bug: 263274255
Test: presubmit; make tidy-system-extras_subset
Change-Id: If09fe93189c41b764d218c02b8b2e08398ea1964
Diffstat (limited to 'boottime_tools')
-rw-r--r-- | boottime_tools/bootio/bootio_collector.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/boottime_tools/bootio/bootio_collector.cpp b/boottime_tools/bootio/bootio_collector.cpp index dc13525e..037a3e2b 100644 --- a/boottime_tools/bootio/bootio_collector.cpp +++ b/boottime_tools/bootio/bootio_collector.cpp @@ -66,7 +66,12 @@ void ClearPreviousResults(std::string path) { int ReadIo(char *filename, AppSample *sample) { FILE *file; char line[MAX_LINE]; - unsigned int rchar, wchar, syscr, syscw, readbytes, writebytes; + unsigned int rchar = 0; + unsigned int wchar = 0; + unsigned int syscr = 0; + unsigned int syscw = 0; + unsigned int readbytes = 0; + unsigned int writebytes = 0; file = fopen(filename, "r"); if (!file) return 1; @@ -289,17 +294,17 @@ void PrintPids(DataContainer& data, std::unordered_map<int, uint64_t>& cpuDataMa cpuLoad); isFirstSample = false; } - printf("-----------------------------------------------------------------------------\n"); + if (!newerSample) { + LOG(ERROR) << "newerSample is null"; + } else { + printf("-----------------------------------------------------------------------------" + "\n"); #define NUMBER "%-13" PRId64 - printf("%-15s" NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER "\n", + printf("%-15s" NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER "\n", #undef NUMBER - "Total", - newerSample->rchar(), - newerSample->wchar(), - newerSample->syscr(), - newerSample->syscw(), - newerSample->readbytes(), - newerSample->writebytes()); + "Total", newerSample->rchar(), newerSample->wchar(), newerSample->syscr(), + newerSample->syscw(), newerSample->readbytes(), newerSample->writebytes()); + } } printf("\nAggregations\n%-10s%-13s%-13s%-13s\n", "Total", |