Browse Source

dsp: Prevent unsafe copying of IIRFilter

Explicitly delete the copy constructor and copy assignment operator for
IIRFilter to prevent accidental duplication of filter state.

Copying an IIRFilter instance could duplicate internal filter state and
coefficient references, potentially causing incorrect processing or
resource-management problems.

Since IIRFilter is not intended to be copied or assigned, prohibit both
operations at compile time.

cppcheck identified the missing copy constructor and assignment operator
with its noCopyConstructor and noOperatorEq warnings.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 1 month ago
parent
commit
00bbb81a2b
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 4
      sdrbase/dsp/iirfilter.h

4
sdrbase/dsp/iirfilter.h

@ -31,6 +31,8 @@ template <typename Type, uint32_t Order> class IIRFilter @@ -31,6 +31,8 @@ template <typename Type, uint32_t Order> class IIRFilter
public:
IIRFilter(const Type *a, const Type *b);
~IIRFilter();
IIRFilter(const IIRFilter&) = delete;
IIRFilter& operator=(const IIRFilter&) = delete;
void setCoeffs(const Type *a, const Type *b);
Type run(const Type& sample);
@ -46,6 +48,8 @@ template <typename Type> class IIRFilter<Type, 2> @@ -46,6 +48,8 @@ template <typename Type> class IIRFilter<Type, 2>
public:
IIRFilter(const Type *a, const Type *b);
~IIRFilter();
IIRFilter(const IIRFilter&) = delete;
IIRFilter& operator=(const IIRFilter&) = delete;
void setCoeffs(const Type *a, const Type *b);
Type run(const Type& sample);

Loading…
Cancel
Save