From 1253697801fc7f7879d33279e170cbef1ea4e5a9 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 31 Jul 2026 20:33:20 -0400 Subject: [PATCH 1/2] gui: Explicitly call QSlider::setRange in LogSlider constructor cppcheck identified that LogSlider::LogSlider() calls the derived setRange(double, double) overload instead of QSlider::setRange(int, int) due to C++ name hiding. The constructor's call to: setRange(0, 1000); was therefore invoking the logarithmic range implementation with min == 0.0, resulting in a call to log10(0). While most callers immediately replace the initial state by calling LogSlider::setRange() with a valid positive range, the constructor still performs an invalid mathematical operation during initialization. Explicitly qualify the call as QSlider::setRange(0, 1000) to initialize the underlying slider without invoking the logarithmic overload. This eliminates the invalid-domain call, avoids undefined behavior from propagating exceptional floating-point values into the slider state, and makes the constructor's intent explicit. This change has no functional impact on normal operation, but removes a latent initialization bug and prevents future regressions caused by overload hiding. Signed-off-by: Robin Getz --- sdrgui/gui/logslider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdrgui/gui/logslider.cpp b/sdrgui/gui/logslider.cpp index cf66d17a7..d6363a411 100644 --- a/sdrgui/gui/logslider.cpp +++ b/sdrgui/gui/logslider.cpp @@ -30,7 +30,7 @@ LogSlider::LogSlider(QWidget *parent) : QSlider(Qt::Horizontal, parent) { - setRange(0, 1000); + QSlider::setRange(0, 1000); connect(this, &QSlider::valueChanged, this, &LogSlider::handleValueChanged); setPageStep(1); setTickPosition(QSlider::TicksAbove); From 6fc50d25461fae742c9e15ff0d262bac3dc5a260 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 31 Jul 2026 20:51:36 -0400 Subject: [PATCH 2/2] gui: Avoid log(0) in FFTNRDialog::setAlpha Cppcheck reported that setAlpha() could call log() with an argument of zero when alpha is clamped to 0.0f, resulting in an invalid-domain mathematical operation. Initialize tau to 0.0f and only compute the logarithm when alpha is strictly positive. This preserves the existing behavior while avoiding the invalid log(0) call. Signed-off-by: Robin Getz --- sdrgui/gui/fftnrdialog.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sdrgui/gui/fftnrdialog.cpp b/sdrgui/gui/fftnrdialog.cpp index 92a057495..23f0ea89d 100644 --- a/sdrgui/gui/fftnrdialog.cpp +++ b/sdrgui/gui/fftnrdialog.cpp @@ -161,9 +161,14 @@ void FFTNRDialog::setAlpha(float alpha, int fftLength, int sampleRate) ui->alpha->blockSignals(false); ui->alphaValue->setText(tr("%1").arg(alphaDisplay)); ui->alphaValue->setToolTip(tr("dB(1 - alpha) alpha=%1").arg(m_alpha, 0, 'f', 5)); - float t = m_flen; - t /= m_sampleRate; - float tau = -(t / log(m_alpha)); + + float t = static_cast(m_flen) / m_sampleRate; + float tau = 0.0f; + if (m_alpha > 0.0f) + { + tau = -(t / std::log(m_alpha)); + } + ui->tauText->setText(tr("%1").arg(tau, 0, 'f', 3)); }