diff --git a/src/access/examples/ExampleAccessControlDelegate.cpp b/src/access/examples/ExampleAccessControlDelegate.cpp index 6d9b5595994ee4..f6b219b66a93e7 100644 --- a/src/access/examples/ExampleAccessControlDelegate.cpp +++ b/src/access/examples/ExampleAccessControlDelegate.cpp @@ -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) { @@ -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); diff --git a/src/app/CASESessionManager.cpp b/src/app/CASESessionManager.cpp index 58ec144a8f3fa6..af580d35148ee7 100644 --- a/src/app/CASESessionManager.cpp +++ b/src/app/CASESessionManager.cpp @@ -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) { diff --git a/src/app/CASESessionManager.h b/src/app/CASESessionManager.h index e2ab839b0df8a6..4f7c118c92a92f 100644 --- a/src/app/CASESessionManager.h +++ b/src/app/CASESessionManager.h @@ -75,7 +75,7 @@ class CASESessionManager CHIP_ERROR FindOrEstablishSession(PeerId peerId, Callback::Callback * onConnection, Callback::Callback * onFailure); - OperationalDeviceProxy * FindExistingSession(PeerId peerId); + OperationalDeviceProxy * FindExistingSession(PeerId peerId) const; void ReleaseSession(PeerId peerId); @@ -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; }; diff --git a/src/app/DataVersionFilter.h b/src/app/DataVersionFilter.h index ba93de61689693..1a6608e04a47eb 100644 --- a/src/app/DataVersionFilter.h +++ b/src/app/DataVersionFilter.h @@ -32,7 +32,7 @@ struct DataVersionFilter DataVersionFilter() {} - bool IsValidDataVersionFilter() + bool IsValidDataVersionFilter() const { return (mEndpointId != kInvalidEndpointId) && (mClusterId != kInvalidClusterId) && (mDataVersion.HasValue()); } diff --git a/src/app/EventManagement.cpp b/src/app/EventManagement.cpp index 1adb330321a2d9..88d4b7be7808f6 100644 --- a/src/app/EventManagement.cpp +++ b/src/app/EventManagement.cpp @@ -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); diff --git a/src/app/EventManagement.h b/src/app/EventManagement.h index 68d29cc66404df..9d6802105cc237 100644 --- a/src/app/EventManagement.h +++ b/src/app/EventManagement.h @@ -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; @@ -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 @@ -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: /** diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index f89ada218da0ec..572e9cbb35e833 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -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; } diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 952d360046c11d..0ef94fd1f80706 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -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() && diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index e5c4d7e83b2dff..f2c4bfc390ecb4 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -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; } @@ -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() { @@ -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; } @@ -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: diff --git a/src/app/reporting/Engine.h b/src/app/reporting/Engine.h index c29f100d0e5ac2..3ed8512dad8b47 100644 --- a/src/app/reporting/Engine.h +++ b/src/app/reporting/Engine.h @@ -118,7 +118,7 @@ class Engine } } - uint32_t GetNumReportsInFlight() { return mNumReportsInFlight; } + uint32_t GetNumReportsInFlight() const { return mNumReportsInFlight; } void ScheduleUrgentEventDeliverySync(); diff --git a/src/app/server/Dnssd.h b/src/app/server/Dnssd.h index c396fa5964b72d..efc7b86ea5ce08 100644 --- a/src/app/server/Dnssd.h +++ b/src/app/server/Dnssd.h @@ -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; } @@ -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 diff --git a/src/app/util/binding-table.h b/src/app/util/binding-table.h index 1ae270fd109035..792a796b737356 100644 --- a/src/app/util/binding-table.h +++ b/src/app/util/binding-table.h @@ -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; @@ -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(); diff --git a/src/ble/BleLayer.cpp b/src/ble/BleLayer.cpp index 50cf13ebe3e242..d634e1940e806e 100644 --- a/src/ble/BleLayer.cpp +++ b/src/ble/BleLayer.cpp @@ -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) { diff --git a/src/ble/BtpEngine.h b/src/ble/BtpEngine.h index 1c3bed32206df9..d861c3df5e4c0c 100644 --- a/src/ble/BtpEngine.h +++ b/src/ble/BtpEngine.h @@ -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; } diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index d8c3b30e1a1206..4e176ac8bf4934 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -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) { @@ -249,7 +249,7 @@ CHIP_ERROR AutoCommissioner::StartCommissioning(DeviceCommissioner * commissione return CHIP_NO_ERROR; } -Optional AutoCommissioner::GetCommandTimeout(CommissioningStage stage) +Optional 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. diff --git a/src/controller/AutoCommissioner.h b/src/controller/AutoCommissioner.h index 5c2438fc28ee33..fa4693adf2152c 100644 --- a/src/controller/AutoCommissioner.h +++ b/src/controller/AutoCommissioner.h @@ -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 GetCommandTimeout(CommissioningStage stage); - EndpointId GetEndpoint(const CommissioningStage & stage); + Optional GetCommandTimeout(CommissioningStage stage) const; + EndpointId GetEndpoint(const CommissioningStage & stage) const; DeviceCommissioner * mCommissioner = nullptr; CommissioneeDeviceProxy * mCommissioneeDeviceProxy = nullptr; diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index 0cde726a50de15..cda0978655f74c 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -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) { diff --git a/src/controller/SetUpCodePairer.h b/src/controller/SetUpCodePairer.h index 51c3bbf46ca453..19b57999f0eeae 100644 --- a/src/controller/SetUpCodePairer.h +++ b/src/controller/SetUpCodePairer.h @@ -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; diff --git a/src/credentials/DeviceAttestationVendorReserved.h b/src/credentials/DeviceAttestationVendorReserved.h index f016d8799f8cc5..7042b2c946ca3b 100644 --- a/src/credentials/DeviceAttestationVendorReserved.h +++ b/src/credentials/DeviceAttestationVendorReserved.h @@ -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. @@ -169,7 +169,7 @@ class DeviceAttestationVendorReservedConstructor return CHIP_NO_ERROR; } - size_t GetNumberOfElements() { return mNumEntriesUsed; } + size_t GetNumberOfElements() const { return mNumEntriesUsed; } private: /* diff --git a/src/credentials/FabricTable.cpp b/src/credentials/FabricTable.cpp index 4f584437ba05d7..2642e82cb2dbda 100644 --- a/src/credentials/FabricTable.cpp +++ b/src/credentials/FabricTable.cpp @@ -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 = diff --git a/src/credentials/FabricTable.h b/src/credentials/FabricTable.h index 45d1163643e03f..adcfbd680b05a3 100644 --- a/src/credentials/FabricTable.h +++ b/src/credentials/FabricTable.h @@ -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); diff --git a/src/credentials/GroupDataProvider.h b/src/credentials/GroupDataProvider.h index d6e25c7e3d0dcd..f5fa345213f1b2 100644 --- a/src/credentials/GroupDataProvider.h +++ b/src/credentials/GroupDataProvider.h @@ -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 @@ -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; } @@ -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 diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 5dc549fb5b7e89..f9c03fd2e0dc8f 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -291,7 +291,7 @@ struct FabricData : public PersistentData } // 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); @@ -334,7 +334,7 @@ struct FabricData : public PersistentData } // 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)); diff --git a/src/include/platform/FailSafeContext.h b/src/include/platform/FailSafeContext.h index b575494574fe48..41eaac12023c07 100644 --- a/src/include/platform/FailSafeContext.h +++ b/src/include/platform/FailSafeContext.h @@ -47,15 +47,15 @@ class FailSafeContext return mFailSafeArmed && MatchesFabricIndex(accessingFabricIndex); } - inline bool IsFailSafeArmed() { return mFailSafeArmed; } + inline bool IsFailSafeArmed() const { return mFailSafeArmed; } - inline bool MatchesFabricIndex(FabricIndex accessingFabricIndex) + inline bool MatchesFabricIndex(FabricIndex accessingFabricIndex) const { VerifyOrDie(mFailSafeArmed); return (accessingFabricIndex == mFabricIndex); } - inline bool NocCommandHasBeenInvoked() { return mNocCommandHasBeenInvoked; } + inline bool NocCommandHasBeenInvoked() const { return mNocCommandHasBeenInvoked; } inline void SetNocCommandInvoked(FabricIndex nocFabricIndex) { @@ -63,7 +63,7 @@ class FailSafeContext mFabricIndex = nocFabricIndex; } - inline FabricIndex GetFabricIndex() + inline FabricIndex GetFabricIndex() const { VerifyOrDie(mFailSafeArmed); return mFabricIndex; diff --git a/src/inet/InetInterface.cpp b/src/inet/InetInterface.cpp index be344cbe43b983..9f5356eef52c23 100644 --- a/src/inet/InetInterface.cpp +++ b/src/inet/InetInterface.cpp @@ -283,7 +283,7 @@ bool InterfaceAddressIterator::HasBroadcastAddress() return HasCurrent() && mIntfIter.HasBroadcastAddress(); } -CHIP_ERROR InterfaceId::GetLinkLocalAddr(IPAddress * llAddr) +CHIP_ERROR InterfaceId::GetLinkLocalAddr(IPAddress * llAddr) const { VerifyOrReturnError(llAddr != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -754,7 +754,7 @@ bool InterfaceAddressIterator::HasBroadcastAddress() return HasCurrent() && (mCurAddr->ifa_flags & IFF_BROADCAST) != 0; } -CHIP_ERROR InterfaceId::GetLinkLocalAddr(IPAddress * llAddr) +CHIP_ERROR InterfaceId::GetLinkLocalAddr(IPAddress * llAddr) const { VerifyOrReturnError(llAddr != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -995,7 +995,7 @@ bool InterfaceAddressIterator::HasBroadcastAddress() return HasCurrent() && mIntfIter.HasBroadcastAddress(); } -CHIP_ERROR InterfaceId::GetLinkLocalAddr(IPAddress * llAddr) +CHIP_ERROR InterfaceId::GetLinkLocalAddr(IPAddress * llAddr) const { VerifyOrReturnError(llAddr != nullptr, CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/inet/InetInterface.h b/src/inet/InetInterface.h index 1189b0a9024e45..aa303b57a2627f 100644 --- a/src/inet/InetInterface.h +++ b/src/inet/InetInterface.h @@ -180,7 +180,7 @@ class InterfaceId * any address configured. * @retval #CHIP_NO_ERROR On success. */ - CHIP_ERROR GetLinkLocalAddr(IPAddress * llAddr); + CHIP_ERROR GetLinkLocalAddr(IPAddress * llAddr) const; private: #if CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/lib/core/CHIPTLV.h b/src/lib/core/CHIPTLV.h index 9f3947c1df98bc..9dff35af5e476a 100644 --- a/src/lib/core/CHIPTLV.h +++ b/src/lib/core/CHIPTLV.h @@ -938,7 +938,7 @@ class DLL_EXPORT TLVReader CHIP_ERROR SkipData(); CHIP_ERROR SkipToEndOfContainer(); CHIP_ERROR VerifyElement(); - Tag ReadTag(TLVTagControl tagControl, const uint8_t *& p); + Tag ReadTag(TLVTagControl tagControl, const uint8_t *& p) const; CHIP_ERROR EnsureData(CHIP_ERROR noDataErr); CHIP_ERROR ReadData(uint8_t * buf, uint32_t len); CHIP_ERROR GetElementHeadLength(uint8_t & elemHeadBytes) const; @@ -2370,7 +2370,7 @@ class DLL_EXPORT TLVUpdater * implicit form. */ void SetImplicitProfileId(uint32_t profileId); - uint32_t GetImplicitProfileId() { return mUpdaterReader.ImplicitProfileId; } + uint32_t GetImplicitProfileId() const { return mUpdaterReader.ImplicitProfileId; } /** * Copies the current element from input TLV to output TLV. @@ -2610,7 +2610,7 @@ class DLL_EXPORT TLVUpdater } CHIP_ERROR EndContainer(TLVType outerContainerType) { return mUpdaterWriter.EndContainer(outerContainerType); } uint32_t GetLengthWritten() { return mUpdaterWriter.GetLengthWritten(); } - uint32_t GetRemainingFreeLength() { return mUpdaterWriter.mRemainingLen; } + uint32_t GetRemainingFreeLength() const { return mUpdaterWriter.mRemainingLen; } private: void AdjustInternalWriterFreeSpace(); diff --git a/src/lib/core/CHIPTLVReader.cpp b/src/lib/core/CHIPTLVReader.cpp index 18950d7111e863..9c5f23c5d60389 100644 --- a/src/lib/core/CHIPTLVReader.cpp +++ b/src/lib/core/CHIPTLVReader.cpp @@ -784,7 +784,7 @@ CHIP_ERROR TLVReader::VerifyElement() return CHIP_NO_ERROR; } -Tag TLVReader::ReadTag(TLVTagControl tagControl, const uint8_t *& p) +Tag TLVReader::ReadTag(TLVTagControl tagControl, const uint8_t *& p) const { uint16_t vendorId; uint16_t profileNum; diff --git a/src/lib/support/CHIPArgParser.cpp b/src/lib/support/CHIPArgParser.cpp index 6fd0858d855e25..e3102d4c09eee1 100644 --- a/src/lib/support/CHIPArgParser.cpp +++ b/src/lib/support/CHIPArgParser.cpp @@ -1141,7 +1141,7 @@ HelpOptions::HelpOptions(const char * appName, const char * appUsage, const char /** * Print a short description of the command's usage followed by instructions on how to get more help. */ -void HelpOptions::PrintBriefUsage(FILE * s) +void HelpOptions::PrintBriefUsage(FILE * s) const { PutStringWithNewLine(s, AppUsage); fprintf(s, "Try `%s --help' for more information.\n", AppName); @@ -1150,7 +1150,7 @@ void HelpOptions::PrintBriefUsage(FILE * s) /** * Print the full usage information, including information on all available options. */ -void HelpOptions::PrintLongUsage(OptionSet ** optSets, FILE * s) +void HelpOptions::PrintLongUsage(OptionSet ** optSets, FILE * s) const { PutStringWithBlankLine(s, AppUsage); if (AppDesc != nullptr) @@ -1160,7 +1160,7 @@ void HelpOptions::PrintLongUsage(OptionSet ** optSets, FILE * s) PrintOptionHelp(optSets, s); } -void HelpOptions::PrintVersion(FILE * s) +void HelpOptions::PrintVersion(FILE * s) const { fprintf(s, "%s ", AppName); PutStringWithNewLine(s, (AppVersion != nullptr) ? AppVersion : "(unknown version)"); diff --git a/src/lib/support/CHIPArgParser.hpp b/src/lib/support/CHIPArgParser.hpp index daeab0be9e6729..f22484fcf6089f 100644 --- a/src/lib/support/CHIPArgParser.hpp +++ b/src/lib/support/CHIPArgParser.hpp @@ -149,9 +149,9 @@ class HelpOptions : public OptionSetBase HelpOptions(const char * appName, const char * appUsage, const char * appVersion); HelpOptions(const char * appName, const char * appUsage, const char * appVersion, const char * appDesc); - void PrintBriefUsage(FILE * s); - void PrintLongUsage(OptionSet * optSets[], FILE * s); - void PrintVersion(FILE * s); + void PrintBriefUsage(FILE * s) const; + void PrintLongUsage(OptionSet * optSets[], FILE * s) const; + void PrintVersion(FILE * s) const; bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) override; }; diff --git a/src/lib/support/SerializableIntegerSet.h b/src/lib/support/SerializableIntegerSet.h index b61b640ef39a61..45d7604d43ccbb 100644 --- a/src/lib/support/SerializableIntegerSet.h +++ b/src/lib/support/SerializableIntegerSet.h @@ -88,13 +88,13 @@ class SerializableU64SetBase * @brief * Get the length of the byte data if the array is serialized. */ - size_t SerializedSize() { return sizeof(uint64_t) * mNextAvailable; } + size_t SerializedSize() const { return sizeof(uint64_t) * mNextAvailable; } /** * @brief * Get the maximum length of the byte data if the array were full and serialized. */ - size_t MaxSerializedSize() { return sizeof(uint64_t) * mCapacity; } + size_t MaxSerializedSize() const { return sizeof(uint64_t) * mCapacity; } /** * @brief diff --git a/src/messaging/ExchangeMgr.h b/src/messaging/ExchangeMgr.h index e4e5d0f723f77a..673140f949d712 100644 --- a/src/messaging/ExchangeMgr.h +++ b/src/messaging/ExchangeMgr.h @@ -187,7 +187,7 @@ class DLL_EXPORT ExchangeManager : public SessionMessageDelegate ReliableMessageMgr * GetReliableMessageMgr() { return &mReliableMessageMgr; }; - FabricIndex GetFabricIndex() { return mFabricIndex; } + FabricIndex GetFabricIndex() const { return mFabricIndex; } uint16_t GetNextKeyId() { return ++mNextKeyId; } diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 96ca50f464c0bd..104f90d805cb7a 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -343,7 +343,7 @@ bool ThreadStackManagerImpl::_IsThreadEnabled() return (strcmp(role, kOpenthreadDeviceRoleDisabled) != 0); } -bool ThreadStackManagerImpl::_IsThreadAttached() +bool ThreadStackManagerImpl::_IsThreadAttached() const { return mAttached; } diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index 4ae2fc71ed6d48..431812c8788238 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -69,7 +69,7 @@ class ThreadStackManagerImpl : public ThreadStackManager bool _IsThreadEnabled(); - bool _IsThreadAttached(); + bool _IsThreadAttached() const; CHIP_ERROR _AttachToThreadNetwork(ByteSpan netInfo, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback); diff --git a/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp b/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp index d813b83da7cfb7..50d3548bfa58e8 100644 --- a/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp @@ -265,8 +265,6 @@ void WiFiDriverImpl::ConnectNetwork(ByteSpan networkId, ConnectCallback * callba void WiFiDriverImpl::DisconnectNetwork(ByteSpan networkId) { - Status status = Status::kSuccess; - VerifyOrReturn(mWiFiInterface != nullptr, ChipLogError(DeviceLayer, "Wifi network not available")); VerifyOrReturn(NetworkMatch(mStagingNetwork, networkId), ChipLogError(DeviceLayer, "Network not found")); ChipLogProgress(NetworkProvisioning, "Mbed WiFi driver disconnect network: SSID: %.*s", static_cast(networkId.size()), diff --git a/src/protocols/bdx/BdxTransferSession.cpp b/src/protocols/bdx/BdxTransferSession.cpp index f92fb109284cd2..945381e2fefa2c 100644 --- a/src/protocols/bdx/BdxTransferSession.cpp +++ b/src/protocols/bdx/BdxTransferSession.cpp @@ -894,7 +894,7 @@ void TransferSession::PrepareStatusReport(StatusCode code) mAwaitingResponse = false; // Prevent triggering timeout } -bool TransferSession::IsTransferLengthDefinite() +bool TransferSession::IsTransferLengthDefinite() const { return (mTransferLength > 0); } diff --git a/src/protocols/bdx/BdxTransferSession.h b/src/protocols/bdx/BdxTransferSession.h index 7c37ed3019c3e3..7696d0473c9dc8 100644 --- a/src/protocols/bdx/BdxTransferSession.h +++ b/src/protocols/bdx/BdxTransferSession.h @@ -349,7 +349,7 @@ class DLL_EXPORT TransferSession CHIP_ERROR VerifyProposedMode(const BitFlags & proposed); void PrepareStatusReport(StatusCode code); - bool IsTransferLengthDefinite(); + bool IsTransferLengthDefinite() const; OutputEventType mPendingOutput = OutputEventType::kNone; TransferState mState = TransferState::kUnitialized; diff --git a/src/system/WakeEvent.cpp b/src/system/WakeEvent.cpp index 8c6cda1aa8fa87..a670cc687cff3c 100644 --- a/src/system/WakeEvent.cpp +++ b/src/system/WakeEvent.cpp @@ -91,7 +91,7 @@ void WakeEvent::Close(LayerSockets & systemLayer) mWriteFD = -1; } -void WakeEvent::Confirm() +void WakeEvent::Confirm() const { uint8_t buffer[128]; ssize_t res; @@ -107,7 +107,7 @@ void WakeEvent::Confirm() } while (res == sizeof(buffer)); } -CHIP_ERROR WakeEvent::Notify() +CHIP_ERROR WakeEvent::Notify() const { char byte = 1; @@ -143,7 +143,7 @@ void WakeEvent::Close(LayerSockets & systemLayer) mReadFD = -1; } -void WakeEvent::Confirm() +void WakeEvent::Confirm() const { uint64_t value; @@ -153,7 +153,7 @@ void WakeEvent::Confirm() } } -CHIP_ERROR WakeEvent::Notify() +CHIP_ERROR WakeEvent::Notify() const { uint64_t value = 1; diff --git a/src/system/WakeEvent.h b/src/system/WakeEvent.h index 1c5c3d843b9ef5..b979c67ab17752 100644 --- a/src/system/WakeEvent.h +++ b/src/system/WakeEvent.h @@ -48,8 +48,8 @@ class WakeEvent CHIP_ERROR Open(LayerSockets & systemLayer); /**< Initialize the pipeline */ void Close(LayerSockets & systemLayer); /**< Close both ends of the pipeline. */ - CHIP_ERROR Notify(); /**< Set the event. */ - void Confirm(); /**< Clear the event. */ + CHIP_ERROR Notify() const; /**< Set the event. */ + void Confirm() const; /**< Clear the event. */ private: friend class WakeEventTest; diff --git a/src/transport/GroupSession.h b/src/transport/GroupSession.h index 484d46ca4c27ff..88315d0527c97f 100644 --- a/src/transport/GroupSession.h +++ b/src/transport/GroupSession.h @@ -92,7 +92,7 @@ class IncomingGroupSession : public Session GroupId GetGroupId() const { return mGroupId; } - NodeId GetSourceNodeId() { return mSourceNodeId; } + NodeId GetSourceNodeId() const { return mSourceNodeId; } private: const GroupId mGroupId; @@ -153,7 +153,7 @@ class OutgoingGroupSession : public Session GroupId GetGroupId() const { return mGroupId; } - NodeId GetSourceNodeId() { return mSourceNodeId; } + NodeId GetSourceNodeId() const { return mSourceNodeId; } private: const GroupId mGroupId; diff --git a/src/transport/PeerMessageCounter.h b/src/transport/PeerMessageCounter.h index 2be1109b68b78e..edfac7bf8ddb5a 100644 --- a/src/transport/PeerMessageCounter.h +++ b/src/transport/PeerMessageCounter.h @@ -192,7 +192,7 @@ class PeerMessageCounter mSynced.mWindow.reset(); } - uint32_t GetCounter() { return mSynced.mMaxCounter; } + uint32_t GetCounter() const { return mSynced.mMaxCounter; } private: // Counter position indicator with respect to our current