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 std::move, nullptr, const, layout changes #2325

Merged
merged 11 commits into from
Feb 7, 2025
56 changes: 24 additions & 32 deletions TAO/tao/PortableServer/Active_Object_Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (
{
TAO_Active_Object_Map::set_system_id_size (creation_parameters);

TAO_Id_Uniqueness_Strategy *id_uniqueness_strategy = 0;
TAO_Id_Uniqueness_Strategy *id_uniqueness_strategy {};

if (unique_id_policy)
{
Expand All @@ -118,7 +118,7 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (
// Give ownership to the unique pointer.
std::unique_ptr<TAO_Id_Uniqueness_Strategy> new_id_uniqueness_strategy (id_uniqueness_strategy);

TAO_Lifespan_Strategy *lifespan_strategy = 0;
TAO_Lifespan_Strategy *lifespan_strategy {};

if (persistent_id_policy)
{
Expand All @@ -142,7 +142,7 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (
// Give ownership to the unique pointer.
std::unique_ptr<TAO_Lifespan_Strategy> new_lifespan_strategy (lifespan_strategy);

TAO_Id_Assignment_Strategy *id_assignment_strategy = 0;
TAO_Id_Assignment_Strategy *id_assignment_strategy {};

if (user_id_policy)
{
Expand Down Expand Up @@ -177,7 +177,7 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (
// Give ownership to the unique pointer.
std::unique_ptr<TAO_Id_Assignment_Strategy> new_id_assignment_strategy (id_assignment_strategy);

TAO_Id_Hint_Strategy *id_hint_strategy = 0;
TAO_Id_Hint_Strategy *id_hint_strategy {};
if ((user_id_policy
|| creation_parameters.allow_reactivation_of_system_ids_)
&& creation_parameters.use_active_hint_in_ids_)
Expand All @@ -199,7 +199,7 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (
// Give ownership to the unique pointer.
std::unique_ptr<TAO_Id_Hint_Strategy> new_id_hint_strategy (id_hint_strategy);

servant_map *sm = 0;
servant_map *sm {};
if (unique_id_policy)
{
switch (creation_parameters.reverse_object_lookup_strategy_for_unique_id_policy_)
Expand Down Expand Up @@ -233,7 +233,7 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (
// Give ownership to the unique pointer.
std::unique_ptr<servant_map> new_servant_map (sm);

user_id_map *uim = 0;
user_id_map *uim {};
if (user_id_policy
|| creation_parameters.allow_reactivation_of_system_ids_)
{
Expand Down Expand Up @@ -348,13 +348,13 @@ TAO_Active_Object_Map::is_user_id_in_map (
bool &priorities_match,
bool &deactivated)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
bool result = false;
int const find_result = this->user_id_map_->find (user_id, entry);

if (find_result == 0)
{
if (entry->servant_ == 0)
if (entry->servant_ == nullptr)
{
if (entry->priority_ != priority)
{
Expand Down Expand Up @@ -388,9 +388,8 @@ int
TAO_Unique_Id_Strategy::is_servant_in_map (PortableServer::Servant servant,
bool &deactivated)
{
TAO_Active_Object_Map_Entry *entry = 0;
int result = this->active_object_map_->servant_map_->find (servant,
entry);
TAO_Active_Object_Map_Entry *entry{};
int result = this->active_object_map_->servant_map_->find (servant, entry);
if (result == 0)
{
result = 1;
Expand Down Expand Up @@ -420,7 +419,7 @@ TAO_Unique_Id_Strategy::bind_using_user_id (

if (result == 0)
{
if (servant != 0)
if (servant != nullptr)
{
entry->servant_ = servant;

Expand Down Expand Up @@ -451,24 +450,19 @@ TAO_Unique_Id_Strategy::bind_using_user_id (
if (result == 0)
{
result =
this->active_object_map_->user_id_map_->bind (entry->user_id_,
entry);
this->active_object_map_->user_id_map_->bind (entry->user_id_, entry);
if (result == 0)
{
if (servant != 0)
if (servant != nullptr)
{
result =
this->active_object_map_->servant_map_->bind (
entry->servant_,
entry);
this->active_object_map_->servant_map_->bind (entry->servant_, entry);
}

if (result != 0)
{
this->active_object_map_->user_id_map_->unbind (
entry->user_id_);
this->active_object_map_->id_hint_strategy_->unbind (
*entry);
this->active_object_map_->user_id_map_->unbind (entry->user_id_);
this->active_object_map_->id_hint_strategy_->unbind (*entry);
delete entry;
}
else
Expand Down Expand Up @@ -515,9 +509,8 @@ int
TAO_Unique_Id_Strategy::unbind_using_user_id (
const PortableServer::ObjectId &user_id)
{
TAO_Active_Object_Map_Entry *entry = 0;
int result = this->active_object_map_->user_id_map_->unbind (user_id,
entry);
TAO_Active_Object_Map_Entry *entry {};
int result = this->active_object_map_->user_id_map_->unbind (user_id, entry);
if (result == 0)
{
if (TAO_debug_level > 7)
Expand Down Expand Up @@ -563,7 +556,7 @@ TAO_Unique_Id_Strategy::find_user_id_using_servant (
PortableServer::Servant servant,
PortableServer::ObjectId_out user_id)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
int result = this->active_object_map_->servant_map_->find (servant, entry);

if (result == 0)
Expand All @@ -589,7 +582,7 @@ TAO_Unique_Id_Strategy::find_system_id_using_servant (
PortableServer::ObjectId_out system_id,
CORBA::Short &priority)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
int result = this->active_object_map_->servant_map_->find (servant,
entry);
if (result == 0)
Expand Down Expand Up @@ -640,12 +633,11 @@ TAO_Multiple_Id_Strategy::bind_using_user_id (
CORBA::Short priority,
TAO_Active_Object_Map_Entry *&entry)
{
int result =
this->active_object_map_->user_id_map_->find (user_id, entry);
int result = this->active_object_map_->user_id_map_->find (user_id, entry);

if (result == 0)
{
if (servant != 0)
if (servant != nullptr)
{
entry->servant_ = servant;
}
Expand Down Expand Up @@ -711,7 +703,7 @@ int
TAO_Multiple_Id_Strategy::unbind_using_user_id (
const PortableServer::ObjectId &user_id)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
int result = this->active_object_map_->user_id_map_->unbind (user_id,
entry);
if (result == 0)
Expand Down Expand Up @@ -944,7 +936,7 @@ TAO_System_Id_With_Unique_Id_Strategy::bind_using_system_id (

if (result == 0)
{
if (servant != 0)
if (servant != nullptr)
{
result =
this->active_object_map_->servant_map_->bind (entry->servant_,
Expand Down
42 changes: 16 additions & 26 deletions TAO/tao/PortableServer/Active_Object_Map.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,29 @@ TAO_Active_Object_Map::bind_using_system_id_returning_system_id (
CORBA::Short priority,
PortableServer::ObjectId_out system_id)
{
if (servant == 0 && !this->using_active_maps_)
if (servant == nullptr && !this->using_active_maps_)
{
PortableServer::ObjectId id;

int result = this->user_id_map_->create_key (id);
int const result = this->user_id_map_->create_key (id);

if (result == 0)
{
ACE_NEW_RETURN (system_id,
PortableServer::ObjectId (id),
PortableServer::ObjectId (std::move(id)),
-1);
}

return result;
}

TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};

int result =
this->id_assignment_strategy_->bind_using_system_id (servant,
priority,
entry);
int result = this->id_assignment_strategy_->bind_using_system_id (servant, priority, entry);

if (result == 0)
{
result = this->id_hint_strategy_->system_id (system_id,
*entry);
result = this->id_hint_strategy_->system_id (system_id, *entry);
}

return result;
Expand All @@ -55,12 +51,9 @@ TAO_Active_Object_Map::bind_using_system_id_returning_user_id (
CORBA::Short priority,
PortableServer::ObjectId_out user_id)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};

int result =
this->id_assignment_strategy_->bind_using_system_id (servant,
priority,
entry);
int const result = this->id_assignment_strategy_->bind_using_system_id (servant, priority, entry);
if (result == 0)
ACE_NEW_RETURN (user_id,
PortableServer::ObjectId (entry->user_id_),
Expand All @@ -74,11 +67,8 @@ TAO_Active_Object_Map::bind_using_user_id (
const PortableServer::ObjectId &user_id,
CORBA::Short priority)
{
TAO_Active_Object_Map_Entry *entry = 0;
return this->id_uniqueness_strategy_->bind_using_user_id (servant,
user_id,
priority,
entry);
TAO_Active_Object_Map_Entry *entry {};
return this->id_uniqueness_strategy_->bind_using_user_id (servant, user_id, priority, entry);
}

ACE_INLINE int
Expand All @@ -96,7 +86,7 @@ TAO_Active_Object_Map::find_system_id_using_user_id (
return 0;
}

TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
int result =
this->id_uniqueness_strategy_->bind_using_user_id (0,
user_id,
Expand Down Expand Up @@ -158,7 +148,7 @@ TAO_Active_Object_Map::find_servant_using_user_id (
const PortableServer::ObjectId &user_id,
PortableServer::Servant &servant)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
int result = this->user_id_map_->find (user_id, entry);

if (result == 0)
Expand All @@ -167,7 +157,7 @@ TAO_Active_Object_Map::find_servant_using_user_id (
{
result = -1;
}
else if (entry->servant_ == 0)
else if (entry->servant_ == nullptr)
{
result = -1;
}
Expand Down Expand Up @@ -220,12 +210,12 @@ TAO_Active_Object_Map::find_servant_and_system_id_using_user_id (
PortableServer::ObjectId_out system_id,
CORBA::Short &priority)
{
TAO_Active_Object_Map_Entry *entry = 0;
TAO_Active_Object_Map_Entry *entry {};
int result = this->find_entry_using_user_id (user_id, entry);

if (result == 0)
{
if (entry->servant_ == 0)
if (entry->servant_ == nullptr)
{
result = -1;
}
Expand Down Expand Up @@ -253,7 +243,7 @@ TAO_Active_Object_Map::find_user_id_using_system_id (
if (this->id_hint_strategy_->recover_key (system_id, id) == 0)
{
ACE_NEW_RETURN (user_id,
PortableServer::ObjectId (id),
PortableServer::ObjectId (std::move(id)),
-1);
}

Expand Down
4 changes: 2 additions & 2 deletions TAO/tao/PortableServer/Collocated_Object_Proxy_Broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace TAO
Collocated_Object_Proxy_Broker::_repository_id (CORBA::Object_ptr target)
{
TAO_Stub *stub = target->_stubobj ();
char * _tao_retval = 0;
char * _tao_retval {};

try
{
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace TAO
CORBA::InterfaceDef_ptr
Collocated_Object_Proxy_Broker::_get_interface (CORBA::Object_ptr target)
{
CORBA::InterfaceDef_ptr _tao_retval = 0;
CORBA::InterfaceDef_ptr _tao_retval {};

TAO_Stub *stub = target->_stubobj ();

Expand Down
6 changes: 1 addition & 5 deletions TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_Default_Servant_Dispatcher::~TAO_Default_Servant_Dispatcher ()
{
}

TAO_Root_POA *
TAO_Default_Servant_Dispatcher::create_Root_POA (const ACE_CString &name,
PortableServer::POAManager_ptr poa_manager,
Expand All @@ -18,7 +14,7 @@ TAO_Default_Servant_Dispatcher::create_Root_POA (const ACE_CString &name,
TAO_ORB_Core &orb_core,
TAO_Object_Adapter *object_adapter)
{
TAO_Root_POA *poa = 0;
TAO_Root_POA *poa {};

ACE_NEW_THROW_EX (poa,
TAO_Root_POA (name,
Expand Down
2 changes: 1 addition & 1 deletion TAO/tao/PortableServer/Default_Servant_Dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TAO_PortableServer_Export TAO_Default_Servant_Dispatcher
: public TAO_Servant_Dispatcher
{
public:
virtual ~TAO_Default_Servant_Dispatcher ();
virtual ~TAO_Default_Servant_Dispatcher () = default;

/// Pre_invoke remote request.
void pre_invoke_remote_request (
Expand Down
2 changes: 1 addition & 1 deletion TAO/tao/PortableServer/IdAssignmentPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace TAO
CORBA::Policy_ptr
IdAssignmentPolicy::copy ()
{
IdAssignmentPolicy *copy = 0;
IdAssignmentPolicy *copy {};
ACE_NEW_THROW_EX (copy,
IdAssignmentPolicy (this->value_),
CORBA::NO_MEMORY ());
Expand Down
2 changes: 1 addition & 1 deletion TAO/tao/PortableServer/ImplicitActivationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace TAO
CORBA::Policy_ptr
ImplicitActivationPolicy::copy ()
{
ImplicitActivationPolicy *copy = 0;
ImplicitActivationPolicy *copy {};
ACE_NEW_THROW_EX (copy,
ImplicitActivationPolicy (this->value_),
CORBA::NO_MEMORY ());
Expand Down
2 changes: 1 addition & 1 deletion TAO/tao/PortableServer/LifespanPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace TAO
CORBA::Policy_ptr
LifespanPolicy::copy ()
{
LifespanPolicy *copy = 0;
LifespanPolicy *copy {};
ACE_NEW_THROW_EX (copy,
LifespanPolicy (this->value_),
CORBA::NO_MEMORY ());
Expand Down
Loading
Loading