Commit 64ed2657 authored by Alessio Netti's avatar Alessio Netti
Browse files

Minor warning fixes

- Fixed a few warnings introduced in the latest ProcFS commit
parent 476dec13
......@@ -444,7 +444,7 @@ bool ProcstatParser::_readMetrics() {
v.value = 0;
unsigned int ctr = 0, lineCtr = 0, colCtr = 0, parsedCols = 0;
char *lineToken, *cpuToken, *savePtr;
char *lineToken, *savePtr;
// Reading the file line by line
while( getline(&_stringBuffer, &_chars_read, _metricsFile) > 0 && ctr < _numInternalMetrics ) {
_l = &_lines[lineCtr++];
......@@ -455,11 +455,10 @@ bool ProcstatParser::_readMetrics() {
if (lineToken == NULL) return false;
// We check whether the line is CPU core-related or not (see _readNames)
if (_l->columns>1) {
cpuToken = lineToken;
colCtr = 0;
parsedCols = 0;
// We iterate over the line and capture all of the CPU core-related metrics
while((lineToken = strtok_r(NULL, LINE_SEP, &savePtr)) != NULL && parsedCols < _l->columns) {
while((lineToken = strtok_r(NULL, LINE_SEP, &savePtr)) != NULL && parsedCols < (unsigned)_l->columns) {
// Second part of the if: if the line contains node-level CPU metrics (starts with "cpu") and the
// column is flagged with 2 (sample only at node level) then the metric can be sampled
if(_skipColumn[colCtr] == 1 || (_skipColumn[colCtr] == 2 && _l->cpuID<0)) {
......@@ -537,7 +536,7 @@ bool SARParser::_readMetrics() {
v.value = 0;
unsigned int ctr=0, lineCtr=0, colCtr=0, parsedCols=0, accIdx=0;
char *lineToken, *cpuToken, *savePtr;
char *lineToken, *savePtr;
// Reading the file line by line
while(getline(&_stringBuffer, &_chars_read, _metricsFile) > 0 && ctr < _numInternalMetrics) {
_l = &_lines[lineCtr++];
......@@ -548,7 +547,6 @@ bool SARParser::_readMetrics() {
if(lineToken == NULL) return false;
// We check whether the line is CPU core-related or not (see _readNames)
if(_l->columns>1) {
cpuToken = lineToken;
colCtr = 0;
parsedCols = 0;
accIdx = (_htAggr && _l->cpuID>=0) ? _l->cpuID%_htVal + 1 : _l->cpuID + 1;
......@@ -586,7 +584,7 @@ bool SARParser::_readMetrics() {
// Computing percentages in SAR style
for(auto& l : _lines)
if(!l.skip && l.columns>1 && (!_htAggr || l.cpuID<_htVal)) {
for (colCtr = 0; colCtr < l.columns; colCtr++)
for (colCtr = 0; colCtr < (unsigned)l.columns; colCtr++)
_readings->at(l.dest + colCtr).value = _readings->at(l.dest + colCtr).value * 1000 / _accumulators[l.cpuID + 1];
_accumulators[l.cpuID + 1] = 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment