The gf2n implementation used a left shift on a potentially negative
value when masking field elements:
(~(Te)0) << N
This can result in undefined behavior for signed integer types and was
reported by static analysis (cppcheck).
Require the field element type to be unsigned and replace the mask
generation with an explicit N-bit mask constructed from the element type.
Also make the overflow check use the element type to avoid implicit
signed integer operations.
Add comments documenting the packed polynomial representation and the
GF(2^N) reduction steps to clarify the intent of the bit operations.
Fixes static analysis warning about shifting negative values.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
cppcheck reported that the displayTableSettings() declaration argument
order differed from the function definition. The header declared the
arguments as (columnIndexes, columnSizes), while the implementation and
all call sites use (columnSizes, columnIndexes).
Update the declaration to match the implementation and remove ambiguity
between the table column width and ordering arrays.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
cppcheck reported that the addToPowerFilter() declaration argument
order differed from the function definition. The header declared the
arguments as (y, x), while the implementation and all call sites use
(x, y).
Update the declaration to match the implementation and callers to avoid
confusion and potential misuse of the function arguments.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
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 <rgetz503@gmail.com>
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 <rgetz503@gmail.com>
Remove an inadvertent '>' character from the
QCoreApplication::applicationVersion() call in the startup version
logging for both appbench and appsrv.
This typo was identified by cppcheck during static analysis. Correcting
the expression restores valid C++ syntax, allowing the applications to
compile correctly and report their version information in the startup
log.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace signed %ld format specifiers with unsigned %lu conversions when
printing values stored as unsigned long.
The previous format strings passed unsigned values to signed printf
conversions, which could result in undefined behavior due to variadic
argument type mismatches. These issues were identified by cppcheck
invalidPrintfArgType_sint warnings.
Use format specifiers matching the actual argument types to ensure
correct and portable printf usage.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace signed %d format specifiers with unsigned %u when formatting
sample rates and channel numbers.
The previous format strings passed unsigned int values to %d conversions,
which triggered cppcheck invalidPrintfArgType_sint warnings and could
result in undefined behavior due to variadic argument type mismatches.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Change the ft8_crc message length parameter from signed int to uint32_t
since it represents a non-negative FT8 message bit count.
GCC reported a potential buffer overflow in the memcpy() call:
warning: ‘__builtin_memcpy’ specified bound between
18446744073709551560 and 18446744073709551564 exceeds maximum object size
[-Wstringop-overflow=]
The warning was caused by the signed message length allowing negative
values to be converted into a very large unsigned size when calculating
the memcpy() byte count.
Using an unsigned fixed-width type better represents the valid range of
the FT8 message length and prevents invalid negative lengths from being
interpreted as extremely large memory operations.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Fix a copy/paste error in decodeSymbols() where FT8 message type
0.3 was checked twice, preventing type 0.4 messages from being
recognized as replies.
FT8::Packing supports both 0.3 and 0.4 message types using the same
reply bit location.
Detected by cppcheck as a redundant condition.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Remove an invalid out-of-bounds array access that attempted to handle
ERROR_INSUFFICIENT_BUFFER. The statement did not resize the fixed-size
buffer and had no effect other than invoking undefined behavior.
The function only uses QueryDosDeviceA() as an existence check for COM
ports, so removing the dead error-handling code does not change its
behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace variable-length arrays used for DVB-S2 pilot symbol matching with
std::vector allocations.
Use vector::data() when passing buffers to the existing pointer-based
match_ph_amp() function. This removes non-standard VLA usage and improves
C++ portability without changing behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace variable-length arrays used for DVB-S2 pilot symbol matching with
std::vector allocations.
Use vector::data() when passing buffers to the existing pointer-based
match_ph_amp() function. This removes additional non-standard VLA usage and
improves C++ portability without changing behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace the variable-length array used for SOF symbol buffering in the
DVB-S2 frame receiver with a std::vector allocation.
Use vector::data() when passing the buffer to the existing pointer-based
conjugate product function. This removes another non-standard VLA usage and
improves C++ portability without changing behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace non-standard variable-length arrays used for PLHEADER symbol
processing with std::vector allocations. Update buffer copies and pointer
interfaces accordingly while preserving existing behavior.
This removes VLA compiler/static analysis warnings and improves C++
portability.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
cppcheck reported that the std::copy() call used iterators from different
containers when restoring ADSB demod table column sizes.
The copy operation used settings.m_columnSizes as the source start iterator
but settings.m_columnIndexes as the source end iterator. This was likely a
copy/paste error and resulted in an invalid iterator range.
Use settings.m_columnSizes for both source iterators so column size settings
are restored correctly.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
cppcheck reported that GLScopeSettings::operator=() did not assign the
m_freerun member variable.
m_freerun is part of the GLScope configuration state: it is initialized
in resetToDefaults(), and is persisted through serialize()/deserialize().
However, when a GLScopeSettings object was copied using the assignment
operator, the freerun state was not transferred from the source object.
This could result in two GLScopeSettings instances having different
freerun values after assignment, with the destination object retaining
its previous value instead of matching the source object.
Add the missing m_freerun assignment to ensure operator=() performs a
complete copy of the settings state and matches the existing
serialization behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>