Initialize mean_, stddev_, and b_ in the Stats constructor so the cached
members are not left indeterminate before finalize() populates them.
The finalized_ state already protects these members from being read before
they are calculated, so this is a defensive initialization rather than a
functional fix.
Detected by cppcheck.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
cppcheck reported uninitialized scalar members in the FT4 constructor.
Initialize pass_ and cached sample values hack_0_ and hack_1_ to avoid
undefined behavior when these members are used before assignment.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Coverity reported an uninitialized scalar variable in FT4::soft_c2m().
Initialize the maximum tone phase value to avoid using an undefined value
when no tone exceeds the initial magnitude threshold.
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 cppcheck warnings about uninitialized mx variables in coarse
strength and soft symbol conversion calculations.
Replace the mxi sentinel logic with an explicit -infinity initial
maximum value, allowing the maximum search to operate directly on the
value being tracked. This removes reliance on short-circuit evaluation
for initialization and simplifies the code.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace the temporary CRC working buffer in `LDPC::ft8_crc()` with a
`std::vector<int>`.
The vector is value-initialized, preserving the existing zero-padding
behavior, while `std::memcpy()` copies the input message into the front
of the buffer. This removes the manual `malloc()`/`free()` pair, simplifies
the implementation, and uses RAII for temporary storage.
This change also addresses a cppcheck warning about a possible null pointer
dereference following malloc() failure. If memory allocation now fails,
std::vector will throw std::bad_alloc rather than returning a null pointer
that would be dereferenced. The algorithm and behavior are otherwise
unchanged.
Signed-off-by: Robin Getz <rgetz503@gmail.com>