Skip to content

Commit c92fbed

Browse files
MiguelCompanymergify[bot]
authored andcommitted
Avoid casting GUID_t into InstanceHandle_t (#6148)
Signed-off-by: Miguel Company <[email protected]> (cherry picked from commit 699c88d)
1 parent 69c88df commit c92fbed

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/cpp/fastdds/domain/DomainParticipantImpl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ DomainParticipantImpl::DomainParticipantImpl(
132132
{
133133
EPROSIMA_LOG_ERROR(DOMAIN_PARTICIPANT, "Error generating GUID for participant");
134134
}
135+
handle_ = guid_;
135136

136137
/* Fill physical data properties if they are found and empty */
137138
std::string* property_value = fastdds::rtps::PropertyPolicyHelper::find_property(
@@ -304,6 +305,7 @@ ReturnCode_t DomainParticipantImpl::enable()
304305
}
305306

306307
guid_ = part->getGuid();
308+
handle_ = guid_;
307309

308310
{
309311
std::lock_guard<std::mutex> _(mtx_gs_);
@@ -775,7 +777,7 @@ IContentFilterFactory* DomainParticipantImpl::find_content_filter_factory(
775777

776778
const InstanceHandle_t& DomainParticipantImpl::get_instance_handle() const
777779
{
778-
return static_cast<const InstanceHandle_t&>(guid_);
780+
return handle_;
779781
}
780782

781783
const fastdds::rtps::GUID_t& DomainParticipantImpl::guid() const

src/cpp/fastdds/domain/DomainParticipantImpl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,9 @@ class DomainParticipantImpl
723723
//!Pre-calculated guid
724724
fastdds::rtps::GUID_t guid_;
725725

726+
//!Translation into InstanceHandle_t of the guid
727+
InstanceHandle_t handle_;
728+
726729
//!For instance handle creation
727730
std::atomic<uint32_t> next_instance_id_;
728731

0 commit comments

Comments
 (0)