Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use clang-tidy to readability-make-member-function-const #16309

Merged
4 changes: 2 additions & 2 deletions src/access/examples/ExampleAccessControlDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class SubjectStorage
}

public:
CHIP_ERROR Serialize(chip::TLV::TLVWriter & writer) { return writer.Put(chip::TLV::AnonymousTag(), mNode); }
CHIP_ERROR Serialize(chip::TLV::TLVWriter & writer) const { return writer.Put(chip::TLV::AnonymousTag(), mNode); }

CHIP_ERROR Deserialize(chip::TLV::TLVReader & reader)
{
Expand Down Expand Up @@ -193,7 +193,7 @@ class TargetStorage
}

public:
CHIP_ERROR Serialize(chip::TLV::TLVWriter & writer)
CHIP_ERROR Serialize(chip::TLV::TLVWriter & writer) const
{
ReturnErrorOnFailure(writer.Put(chip::TLV::AnonymousTag(), mCluster));
return writer.Put(chip::TLV::AnonymousTag(), mDeviceType);
Expand Down
6 changes: 3 additions & 3 deletions src/app/CASESessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ CHIP_ERROR CASESessionManager::GetPeerAddress(PeerId peerId, Transport::PeerAddr
return CHIP_NO_ERROR;
}

OperationalDeviceProxy * CASESessionManager::FindSession(const SessionHandle & session)
OperationalDeviceProxy * CASESessionManager::FindSession(const SessionHandle & session) const
{
return mConfig.devicePool->FindDevice(session);
}

OperationalDeviceProxy * CASESessionManager::FindExistingSession(PeerId peerId)
OperationalDeviceProxy * CASESessionManager::FindExistingSession(PeerId peerId) const
{
return mConfig.devicePool->FindDevice(peerId);
}

void CASESessionManager::ReleaseSession(OperationalDeviceProxy * session)
void CASESessionManager::ReleaseSession(OperationalDeviceProxy * session) const
{
if (session != nullptr)
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/CASESessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CASESessionManager
CHIP_ERROR FindOrEstablishSession(PeerId peerId, Callback::Callback<OnDeviceConnected> * onConnection,
Callback::Callback<OnDeviceConnectionFailure> * onFailure);

OperationalDeviceProxy * FindExistingSession(PeerId peerId);
OperationalDeviceProxy * FindExistingSession(PeerId peerId) const;

void ReleaseSession(PeerId peerId);

Expand All @@ -94,8 +94,8 @@ class CASESessionManager
CHIP_ERROR GetPeerAddress(PeerId peerId, Transport::PeerAddress & addr);

private:
OperationalDeviceProxy * FindSession(const SessionHandle & session);
void ReleaseSession(OperationalDeviceProxy * device);
OperationalDeviceProxy * FindSession(const SessionHandle & session) const;
void ReleaseSession(OperationalDeviceProxy * device) const;

CASESessionManagerConfig mConfig;
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/DataVersionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct DataVersionFilter

DataVersionFilter() {}

bool IsValidDataVersionFilter()
bool IsValidDataVersionFilter() const
{
return (mEndpointId != kInvalidEndpointId) && (mClusterId != kInvalidClusterId) && (mDataVersion.HasValue());
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ CHIP_ERROR EventManagement::EvictEvent(CHIPCircularTLVBuffer & apBuffer, void *
return CHIP_END_OF_TLV;
}

void EventManagement::SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t & aInitialWrittenEventBytes)
void EventManagement::SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t & aInitialWrittenEventBytes) const
{
#if !CHIP_SYSTEM_CONFIG_NO_LOCKING
ScopedLock lock(sInstance);
Expand Down
6 changes: 3 additions & 3 deletions src/app/EventManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CircularEventBuffer : public TLV::CHIPCircularTLVBuffer
CircularEventBuffer * GetNextCircularEventBuffer() { return mpNext; }

void SetRequiredSpaceforEvicted(size_t aRequiredSpace) { mRequiredSpaceForEvicted = aRequiredSpace; }
size_t GetRequiredSpaceforEvicted() { return mRequiredSpaceForEvicted; }
size_t GetRequiredSpaceforEvicted() const { return mRequiredSpaceForEvicted; }

~CircularEventBuffer() override = default;

Expand Down Expand Up @@ -349,7 +349,7 @@ class EventManagement
*
* @return EventNumber most recently vended event Number for that event priority
*/
EventNumber GetLastEventNumber() { return mLastEventNumber; }
EventNumber GetLastEventNumber() const { return mLastEventNumber; }

/**
* @brief
Expand All @@ -360,7 +360,7 @@ class EventManagement
/**
* Logger would save last logged event number and initial written event bytes number into schedule event number array
*/
void SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t & aInitialWrittenEventBytes);
void SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t & aInitialWrittenEventBytes) const;

private:
/**
Expand Down
2 changes: 1 addition & 1 deletion src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate, public Comman
/**
* The Magic number of this InteractionModelEngine, the magic number is set during Init()
*/
uint32_t GetMagicNumber() { return mMagic; }
uint32_t GetMagicNumber() const { return mMagic; }

reporting::Engine & GetReportingEngine() { return mReportingEngine; }

Expand Down
2 changes: 1 addition & 1 deletion src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ CHIP_ERROR ReadHandler::OnMessageReceived(Messaging::ExchangeContext * apExchang
return err;
}

bool ReadHandler::IsFromSubscriber(Messaging::ExchangeContext & apExchangeContext)
bool ReadHandler::IsFromSubscriber(Messaging::ExchangeContext & apExchangeContext) const
{
return (IsType(InteractionType::Subscribe) &&
GetInitiatorNodeId() == apExchangeContext.GetSessionHandle()->AsSecureSession()->GetPeerNodeId() &&
Expand Down
12 changes: 6 additions & 6 deletions src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
/**
* Returns whether this ReadHandler represents a subscription that was created by the other side of the provided exchange.
*/
bool IsFromSubscriber(Messaging::ExchangeContext & apExchangeContext);
bool IsFromSubscriber(Messaging::ExchangeContext & apExchangeContext) const;

bool IsReportable() const { return mState == HandlerState::GeneratingReports && !mHoldReport && (mDirty || !mHoldSync); }
bool IsGeneratingReports() const { return mState == HandlerState::GeneratingReports; }
Expand All @@ -145,12 +145,12 @@ class ReadHandler : public Messaging::ExchangeDelegate
bool CheckEventClean(EventManagement & aEventManager);

bool IsType(InteractionType type) const { return (mInteractionType == type); }
bool IsChunkedReport() { return mIsChunkedReport; }
bool IsPriming() { return mIsPrimingReports; }
bool IsChunkedReport() const { return mIsChunkedReport; }
bool IsPriming() const { return mIsPrimingReports; }
bool IsActiveSubscription() const { return mActiveSubscription; }
bool IsFabricFiltered() const { return mIsFabricFiltered; }
CHIP_ERROR OnSubscribeRequest(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload);
void GetSubscriptionId(uint64_t & aSubscriptionId) { aSubscriptionId = mSubscriptionId; }
void GetSubscriptionId(uint64_t & aSubscriptionId) const { aSubscriptionId = mSubscriptionId; }
AttributePathExpandIterator * GetAttributePathExpandIterator() { return &mAttributePathExpandIterator; }
void SetDirty()
{
Expand All @@ -161,7 +161,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
mAttributeEncoderState = AttributeValueEncoder::AttributeEncodeState();
}
void ClearDirty() { mDirty = false; }
bool IsDirty() { return mDirty; }
bool IsDirty() const { return mDirty; }
NodeId GetInitiatorNodeId() const { return mInitiatorNodeId; }
FabricIndex GetAccessingFabricIndex() const { return mSubjectDescriptor.fabricIndex; }

Expand All @@ -175,7 +175,7 @@ class ReadHandler : public Messaging::ExchangeDelegate

const AttributeValueEncoder::AttributeEncodeState & GetAttributeEncodeState() const { return mAttributeEncoderState; }
void SetAttributeEncodeState(const AttributeValueEncoder::AttributeEncodeState & aState) { mAttributeEncoderState = aState; }
uint32_t GetLastWrittenEventsBytes() { return mLastWrittenEventsBytes; }
uint32_t GetLastWrittenEventsBytes() const { return mLastWrittenEventsBytes; }
CHIP_ERROR SendStatusReport(Protocols::InteractionModel::Status aStatus);

private:
Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Engine
}
}

uint32_t GetNumReportsInFlight() { return mNumReportsInFlight; }
uint32_t GetNumReportsInFlight() const { return mNumReportsInFlight; }

void ScheduleUrgentEventDeliverySync();

Expand Down
6 changes: 3 additions & 3 deletions src/app/server/Dnssd.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class DLL_EXPORT DnssdServer
void SetSecuredPort(uint16_t port) { mSecuredPort = port; }

/// Gets the secure Matter port
uint16_t GetSecuredPort() { return mSecuredPort; }
uint16_t GetSecuredPort() const { return mSecuredPort; }

/// Sets the unsecure Matter port
void SetUnsecuredPort(uint16_t port) { mUnsecuredPort = port; }

/// Gets the unsecure Matter port
uint16_t GetUnsecuredPort() { return mUnsecuredPort; }
uint16_t GetUnsecuredPort() const { return mUnsecuredPort; }

/// Sets the interface id used for advertising
void SetInterfaceId(Inet::InterfaceId interfaceId) { mInterfaceId = interfaceId; }
Expand All @@ -63,7 +63,7 @@ class DLL_EXPORT DnssdServer
void SetDiscoveryTimeoutSecs(int16_t secs) { mDiscoveryTimeoutSecs = secs; }

/// Gets the factory-new state commissionable node discovery timeout
int16_t GetDiscoveryTimeoutSecs() { return mDiscoveryTimeoutSecs; }
int16_t GetDiscoveryTimeoutSecs() const { return mDiscoveryTimeoutSecs; }

//
// Override the referenced fabric table from the default that is present
Expand Down
8 changes: 4 additions & 4 deletions src/app/util/binding-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class BindingTable

Iterator operator++();

bool operator==(const Iterator & rhs) { return mIndex == rhs.mIndex; }
bool operator==(const Iterator & rhs) const { return mIndex == rhs.mIndex; }

bool operator!=(const Iterator & rhs) { return mIndex != rhs.mIndex; }
bool operator!=(const Iterator & rhs) const { return mIndex != rhs.mIndex; }

uint8_t GetIndex() { return mIndex; }
uint8_t GetIndex() const { return mIndex; }

private:
BindingTable * mTable;
Expand All @@ -71,7 +71,7 @@ class BindingTable

// Returns the number of active entries in the binding table.
// *NOTE* The function does not return the capacity of the binding table.
uint8_t Size() { return mSize; }
uint8_t Size() const { return mSize; }

Iterator begin();

Expand Down
2 changes: 1 addition & 1 deletion src/ble/BleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class BleEndPointPool
return nullptr;
}

BLEEndPoint * Find(BLE_CONNECTION_OBJECT c)
BLEEndPoint * Find(BLE_CONNECTION_OBJECT c) const
{
if (c == BLE_CONNECTION_UNINITIALIZED)
{
Expand Down
8 changes: 4 additions & 4 deletions src/ble/BtpEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ class BtpEngine
inline void SetTxFragmentSize(uint16_t size) { mTxFragmentSize = size; }
inline void SetRxFragmentSize(uint16_t size) { mRxFragmentSize = size; }

uint16_t GetRxFragmentSize() { return mRxFragmentSize; }
uint16_t GetTxFragmentSize() { return mTxFragmentSize; }
uint16_t GetRxFragmentSize() const { return mRxFragmentSize; }
uint16_t GetTxFragmentSize() const { return mTxFragmentSize; }

SequenceNumber_t GetAndIncrementNextTxSeqNum();
SequenceNumber_t GetAndRecordRxAckSeqNum();

inline SequenceNumber_t GetLastReceivedSequenceNumber() { return mRxNewestUnackedSeqNum; }
inline SequenceNumber_t GetNewestUnackedSentSequenceNumber() { return mTxNewestUnackedSeqNum; }
inline SequenceNumber_t GetLastReceivedSequenceNumber() const { return mRxNewestUnackedSeqNum; }
inline SequenceNumber_t GetNewestUnackedSentSequenceNumber() const { return mTxNewestUnackedSeqNum; }

inline bool ExpectingAck() const { return mExpectingAck; }

Expand Down
4 changes: 2 additions & 2 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStage(CommissioningStag
return CommissioningStage::kError;
}

EndpointId AutoCommissioner::GetEndpoint(const CommissioningStage & stage)
EndpointId AutoCommissioner::GetEndpoint(const CommissioningStage & stage) const
{
switch (stage)
{
Expand Down Expand Up @@ -249,7 +249,7 @@ CHIP_ERROR AutoCommissioner::StartCommissioning(DeviceCommissioner * commissione
return CHIP_NO_ERROR;
}

Optional<System::Clock::Timeout> AutoCommissioner::GetCommandTimeout(CommissioningStage stage)
Optional<System::Clock::Timeout> AutoCommissioner::GetCommandTimeout(CommissioningStage stage) const
{
// Per spec, all commands that are sent with the arm failsafe held need at least a 30s timeout.
// Network clusters can indicate the time required to connect, so if we are connecting, use that time as long as it is > 30s.
Expand Down
4 changes: 2 additions & 2 deletions src/controller/AutoCommissioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class AutoCommissioner : public CommissioningDelegate
ByteSpan GetPAI() const { return ByteSpan(mPAI, mPAILen); }

CHIP_ERROR NOCChainGenerated(ByteSpan noc, ByteSpan icac, ByteSpan rcac, AesCcm128KeySpan ipk, NodeId adminSubject);
Optional<System::Clock::Timeout> GetCommandTimeout(CommissioningStage stage);
EndpointId GetEndpoint(const CommissioningStage & stage);
Optional<System::Clock::Timeout> GetCommandTimeout(CommissioningStage stage) const;
EndpointId GetEndpoint(const CommissioningStage & stage) const;

DeviceCommissioner * mCommissioner = nullptr;
CommissioneeDeviceProxy * mCommissioneeDeviceProxy = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void SetUpCodePairer::OnDiscoveredDeviceOverBleError(void * appState, CHIP_ERROR
}
#endif // CONFIG_NETWORK_LAYER_BLE

bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & nodeData)
bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & nodeData) const
{
if (nodeData.commissioningMode == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/controller/SetUpCodePairer.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DLL_EXPORT SetUpCodePairer
static void OnDiscoveredDeviceOverBleError(void * appState, CHIP_ERROR err);
#endif // CONFIG_NETWORK_LAYER_BLE

bool NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & nodeData);
bool NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & nodeData) const;
Dnssd::DiscoveryFilter currentFilter;

DeviceCommissioner * mCommissioner = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/credentials/DeviceAttestationVendorReserved.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DeviceAttestationVendorReservedDeconstructor
return CHIP_NO_ERROR;
}

size_t GetNumberOfElements() { return mNumVendorReservedData; }
size_t GetNumberOfElements() const { return mNumVendorReservedData; }

/**
* @brief Return next VendorReserved element. PrepareToReadVendorReservedElements must be called first.
Expand Down Expand Up @@ -169,7 +169,7 @@ class DeviceAttestationVendorReservedConstructor
return CHIP_NO_ERROR;
}

size_t GetNumberOfElements() { return mNumEntriesUsed; }
size_t GetNumberOfElements() const { return mNumEntriesUsed; }

private:
/*
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/FabricTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ CHIP_ERROR FabricInfo::VerifyCredentials(const ByteSpan & noc, const ByteSpan &
}

CHIP_ERROR FabricInfo::GenerateDestinationID(const ByteSpan & ipk, const ByteSpan & random, NodeId destNodeId,
MutableByteSpan & destinationId)
MutableByteSpan & destinationId) const
{
constexpr uint16_t kSigmaParamRandomNumberSize = 32;
constexpr size_t kDestinationMessageLen =
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/FabricTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class DLL_EXPORT FabricInfo
bool IsInitialized() const { return IsOperationalNodeId(mOperationalId.GetNodeId()); }

CHIP_ERROR GenerateDestinationID(const ByteSpan & ipk, const ByteSpan & random, NodeId destNodeId,
MutableByteSpan & destinationId);
MutableByteSpan & destinationId) const;

CHIP_ERROR MatchDestinationID(const ByteSpan & destinationId, const ByteSpan & initiatorRandom, const ByteSpan * ipkList,
size_t ipkListEntries);
Expand Down
11 changes: 7 additions & 4 deletions src/credentials/GroupDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ class GroupDataProvider
GroupId group_id = kUndefinedGroupId;
// Set of group keys that generate operational group keys for use with this group
KeysetId keyset_id = 0;
bool operator==(const GroupKey & other) { return this->group_id == other.group_id && this->keyset_id == other.keyset_id; }
bool operator==(const GroupKey & other) const
{
return this->group_id == other.group_id && this->keyset_id == other.keyset_id;
}
};

struct GroupEndpoint
Expand All @@ -99,7 +102,7 @@ class GroupDataProvider
// Endpoint on the Node to which messages to this group may be forwarded
EndpointId endpoint_id = kInvalidEndpointId;

bool operator==(const GroupEndpoint & other)
bool operator==(const GroupEndpoint & other) const
{
return this->group_id == other.group_id && this->endpoint_id == other.endpoint_id;
}
Expand Down Expand Up @@ -217,8 +220,8 @@ class GroupDataProvider
GroupDataProvider(const GroupDataProvider &) = delete;
GroupDataProvider & operator=(const GroupDataProvider &) = delete;

uint16_t GetMaxGroupsPerFabric() { return mMaxGroupsPerFabric; }
uint16_t GetMaxGroupKeysPerFabric() { return mMaxGroupKeysPerFabric; }
uint16_t GetMaxGroupsPerFabric() const { return mMaxGroupsPerFabric; }
uint16_t GetMaxGroupKeysPerFabric() const { return mMaxGroupKeysPerFabric; }

/**
* Initialize the GroupDataProvider, including possibly any persistent
Expand Down
4 changes: 2 additions & 2 deletions src/credentials/GroupDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ struct FabricData : public PersistentData<kPersistentBufferMax>
}

// Remove the fabric from the fabrics' linked list
CHIP_ERROR Unregister(PersistentStorageDelegate * storage)
CHIP_ERROR Unregister(PersistentStorageDelegate * storage) const
{
FabricList fabric_list;
CHIP_ERROR err = fabric_list.Load(storage);
Expand Down Expand Up @@ -334,7 +334,7 @@ struct FabricData : public PersistentData<kPersistentBufferMax>
}

// Check the fabric is registered in the fabrics' linked list
CHIP_ERROR Validate(PersistentStorageDelegate * storage)
CHIP_ERROR Validate(PersistentStorageDelegate * storage) const
{
FabricList fabric_list;
ReturnErrorOnFailure(fabric_list.Load(storage));
Expand Down
Loading