From 76964aa043c1328fbe45f4ac1758d13e1fcd94ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:54:36 +0100 Subject: [PATCH] [groups] Remove NDEBUG from GroupSession.h (#16445) * [groups] Remove NDEBUG from GroupSession.h Using NDEBUG to change public structure layouts is problematic since it may introduce hard to debug bugs when integrating the CHIP library with external components that are built with different compiler options. * Restyled by whitespace * Remove ReferenceCounted completely as suggested by the author Co-authored-by: Restyled.io --- src/transport/GroupSession.h | 50 ++---------------------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/transport/GroupSession.h b/src/transport/GroupSession.h index 4114e77db212d1..f546da9772aeb3 100644 --- a/src/transport/GroupSession.h +++ b/src/transport/GroupSession.h @@ -18,48 +18,20 @@ #include #include -#include #include #include namespace chip { namespace Transport { -#ifndef NDEBUG -class GroupSessionDeleter -{ -public: - static void Release(IncomingGroupSession * entry) {} - static void Release(OutgoingGroupSession * entry) {} -}; -#endif - class IncomingGroupSession : public Session -#ifndef NDEBUG - // The group session is ephemeral, its lifespan is controlled by whoever is using it. To prevent the object being destroyed - // while there are still SessionHandle or SessionHolder pointing to it, we enforce a reference counter check at its destruction - // in debug build. - , - public ReferenceCounted -#endif { public: IncomingGroupSession(GroupId group, FabricIndex fabricIndex, NodeId sourceNodeId) : mGroupId(group), mSourceNodeId(sourceNodeId) { SetFabricIndex(fabricIndex); } - ~IncomingGroupSession() override - { - NotifySessionReleased(); -#ifndef NDEBUG - VerifyOrDie(GetReferenceCount() == 0); -#endif - } - -#ifndef NDEBUG - void Retain() override { ReferenceCounted::Retain(); } - void Release() override { ReferenceCounted::Release(); } -#endif + ~IncomingGroupSession() override { NotifySessionReleased(); } Session::SessionType GetSessionType() const override { return Session::SessionType::kGroupIncoming; } #if CHIP_PROGRESS_LOGGING @@ -102,31 +74,13 @@ class IncomingGroupSession : public Session }; class OutgoingGroupSession : public Session -#ifndef NDEBUG - // The group session is ephemeral, its lifespan is controlled by whoever is using it. To prevent the object being destroyed - // while there are still SessionHandle or SessionHolder pointing to it, we enforce a reference counter check at its destruction - // in debug build. - , - public ReferenceCounted -#endif { public: OutgoingGroupSession(GroupId group, FabricIndex fabricIndex, NodeId sourceNodeId) : mGroupId(group), mSourceNodeId(sourceNodeId) { SetFabricIndex(fabricIndex); } - ~OutgoingGroupSession() override - { - NotifySessionReleased(); -#ifndef NDEBUG - VerifyOrDie(GetReferenceCount() == 0); -#endif - } - -#ifndef NDEBUG - void Retain() override { ReferenceCounted::Retain(); } - void Release() override { ReferenceCounted::Release(); } -#endif + ~OutgoingGroupSession() override { NotifySessionReleased(); } Session::SessionType GetSessionType() const override { return Session::SessionType::kGroupOutgoing; } #if CHIP_PROGRESS_LOGGING