Browse Source

device: Prevent unsafe copying of DeviceSet

Explicitly delete the copy constructor and copy assignment operator for
DeviceSet, which manages device and channel state that should not be
duplicated through implicit shallow copies.

The implicitly generated copy operations could duplicate internal state and
resource references, potentially causing inconsistent device state or
invalid resource ownership.

Since DeviceSet is not intended to be copied or assigned, prohibit both
operations at compile time to prevent unsafe duplication.

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
a2c35b0b97
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      sdrbase/device/deviceset.h

2
sdrbase/device/deviceset.h

@ -56,6 +56,8 @@ public:
DeviceSet(int tabIndex, int deviceType); DeviceSet(int tabIndex, int deviceType);
~DeviceSet(); ~DeviceSet();
DeviceSet(const DeviceSet&) = delete;
DeviceSet& operator=(const DeviceSet&) = delete;
int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); } int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); }
int getIndex() const { return m_deviceTabIndex; } int getIndex() const { return m_deviceTabIndex; }

Loading…
Cancel
Save