Remove compiler warning and avoid a potential issue with IB

Subtracting unsigned types  is tricky, made sure result  does not wrap
to avoid potentially implementation defined behaviour.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5211 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-04-11 15:29:37 +00:00
parent 227a7907df
commit 6d65f4b1b6

View File

@ -3,7 +3,6 @@
#include "mainwindow.h"
#include <cinttypes>
#include <cstdlib>
#include <limits>
#include <QThread>
@ -953,8 +952,12 @@ void MainWindow::displayDialFrequency ()
bool valid {false};
for (int row = 0; row < frequencies->rowCount (); ++row)
{
// we need to do specific checks for above and below here to
// ensure that we can use unsigned Radio::Frequency since we
// potentially use the full 64-bit unsigned range.
auto working_frequency = frequencies->data (frequencies->index (row, 0)).value<Frequency> ();
if (std::llabs (working_frequency - m_dialFreq) < 10000)
auto offset = m_dialFreq > working_frequency ? m_dialFreq - working_frequency : working_frequency - m_dialFreq;
if (offset < 10000u)
{
valid = true;
}