From bf733989d1a5e89fe25171413ad5a4eae015a6f6 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Tue, 27 Oct 2026 20:08:28 -0400 Subject: [PATCH] modemdab: Fix integer division in symbol power calculation Fix Coverity CID 657864 by using floating-point division when normalizing symbol power. The previous integer division discarded the fractional part of the divisor. Add 6 before dividing by 7 to account for the loop stepping by 7 samples and rounding the sample count up to include the final partial step. Signed-off-by: Robin Getz --- modemdab/dabofdm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modemdab/dabofdm.cpp b/modemdab/dabofdm.cpp index 1131a4030..9389f3daf 100644 --- a/modemdab/dabofdm.cpp +++ b/modemdab/dabofdm.cpp @@ -736,7 +736,7 @@ bool DABFrontEnd::processFrame() for (int n = ModeI::NullSize; n < ModeI::FrameSize; n += 7) { symbolPower += std::norm(m_mixed[Margin + shift + n]); } - symbolPower /= (ModeI::FrameSize - ModeI::NullSize) / 7; + symbolPower /= ((ModeI::FrameSize - ModeI::NullSize + 6) / 7.0); m_frame.startSample = frameStart + shift; m_frame.frequencyOffsetHz = static_cast(m_frequency);