Skip to content

Commit

Permalink
Merge pull request #46 from confluence/same-min-max-frequency-divide-…
Browse files Browse the repository at this point in the history
…by-zero-fix

Don't try to divide by zero if CPU scaling frequency min and max are equal
  • Loading branch information
rodlie authored Jul 2, 2024
2 parents 0178e00 + b5262d6 commit f179578
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/powerkit_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ const QPair<int, QString> Cpu::getCpuFreqLabel()

int freqMin = Cpu::getMinFrequency();
int freqMax = Cpu::getMaxFrequency();
int progress = ((currentCpuFreq - freqMin) * 100) / (freqMax - freqMin);
int progress;
if (freqMax == freqMin) {
progress = 100;
} else {
progress = ((currentCpuFreq - freqMin) * 100) / (freqMax - freqMin);
}

result.first = progress;
result.second = QString("%1\nGhz").arg(QString::number(currentFancyFreq / 1000000, 'f', 2));
Expand Down

0 comments on commit f179578

Please sign in to comment.