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

Conversation

jwillemsen
Copy link
Member

@jwillemsen jwillemsen commented Feb 6, 2025

* TAO/tao/PortableServer/Active_Object_Map.cpp:
* TAO/tao/PortableServer/Active_Object_Map.inl:
* TAO/tao/PortableServer/Object_Adapter.cpp:
* TAO/tao/PortableServer/Object_Adapter.inl:
* TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp:
* TAO/tao/PortableServer/RequestProcessingStrategyServantActivator.cpp:
* TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp:
* TAO/tao/PortableServer/Root_POA.cpp:

Summary by CodeRabbit

  • Refactor
    • Enhanced the codebase by modernizing pointer initialization and null pointer checks for clearer and more maintainable logic.
    • Simplified destructors to use default implementations, improving code clarity and reducing unnecessary complexity.
    • Streamlined copy constructors and destructors, removing unnecessary code while preserving functionality.
  • Style
    • Improved formatting and consistency across multiple components for a more uniform code structure.
  • Chores
    • Streamlined initialization routines to promote overall system robustness and readability.

These updates maintain existing functionality while contributing to a more stable and efficient system for end-users.

    * TAO/tao/PortableServer/Active_Object_Map.cpp:
    * TAO/tao/PortableServer/Active_Object_Map.inl:
    * TAO/tao/PortableServer/Object_Adapter.cpp:
    * TAO/tao/PortableServer/Object_Adapter.inl:
    * TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp:
    * TAO/tao/PortableServer/RequestProcessingStrategyServantActivator.cpp:
    * TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp:
    * TAO/tao/PortableServer/Root_POA.cpp:
Copy link

coderabbitai bot commented Feb 6, 2025

Walkthrough

This pull request modernizes the code by replacing integer-based null pointer checks with nullptr throughout several modules. Additionally, variable declarations have been enhanced by marking unchanged values as const and initializing pointers with {}. The changes also include updates to use std::move for efficient transfers and various formatting improvements to increase code readability. No modifications to control flow or public interface declarations were made.

Changes

File(s) Change Summary
TAO/.../Active_Object_Map.cpp, TAO/.../RequestProcessingStrategyDefaultServant.cpp, TAO/.../RequestProcessingStrategyServantActivator.cpp, TAO/.../RequestProcessingStrategyServantLocator.cpp, TAO/.../Root_POA.cpp Replaced null pointer comparisons and return values from 0 to nullptr for modern C++ style.
TAO/.../Active_Object_Map.inl, TAO/.../Object_Adapter.cpp, TAO/.../Object_Adapter.inl Enhanced variable declarations by converting non-const result to const, initializing pointers with {}, applying std::move where appropriate, and refining code formatting.
TAO/.../Collocated_Object_Proxy_Broker.cpp, TAO/.../Default_Servant_Dispatcher.cpp, TAO/.../IdAssignmentPolicy.cpp, TAO/.../ImplicitActivationPolicy.cpp, TAO/.../LifespanPolicy.cpp Updated pointer initializations from 0 to {} to improve clarity.
TAO/.../Operation_Table_Binary_Search.cpp, TAO/.../Operation_Table_Linear_Search.cpp, TAO/.../Operation_Table_Perfect_Hash.cpp, TAO/.../POA_Current.cpp, TAO/.../PortableServer_Functions.cpp, TAO/.../Regular_POA.cpp, TAO/.../Servant_Base.cpp Changed null pointer checks from 0 to nullptr for improved type safety.
TAO/.../Default_Servant_Dispatcher.cpp, TAO/.../Default_Servant_Dispatcher.h Removed empty destructor and updated its declaration to default in the TAO_Default_Servant_Dispatcher class.
TAO/.../Network_Priority_Hook.h, TAO/.../Object_Adapter.h, TAO/.../POA_Cached_Policies.cpp, TAO/.../POA_Cached_Policies.h, TAO/.../POA_Policy_Set.cpp, TAO/.../POA_Policy_Set.h, TAO/.../Servant_Base.h Updated destructors to default implementations for several classes, enhancing clarity and simplicity in class definitions.
TAO/.../DiffServ_Network_Priority_Hook.cpp, TAO/.../DiffServ_Network_Priority_Hook.h, TAO/.../DiffServ_Protocols_Hooks.cpp, TAO/.../DiffServ_Protocols_Hooks.h Removed empty constructors and destructors for several classes, simplifying their definitions and relying on default implementations.

Poem

I'm a little rabbit, hopping with cheer,
Seeing nullptr shine so bright and clear!
With constants and moves, the code's a delight,
Each change a soft nudge toward modern light.
In lines of code, my heart does skip—oh what a day!
Cheers to refined code in every hop I make!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
TAO/tao/PortableServer/Active_Object_Map.inl (1)

24-24: Improve code quality with modern C++ features.

Good improvements:

  1. Making result const as it's not modified after initialization
  2. Using brace initialization for pointers instead of = 0

Also applies to: 36-36

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0718af0 and 0d56284.

📒 Files selected for processing (8)
  • TAO/tao/PortableServer/Active_Object_Map.cpp (5 hunks)
  • TAO/tao/PortableServer/Active_Object_Map.inl (4 hunks)
  • TAO/tao/PortableServer/Object_Adapter.cpp (1 hunks)
  • TAO/tao/PortableServer/Object_Adapter.inl (4 hunks)
  • TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp (1 hunks)
  • TAO/tao/PortableServer/RequestProcessingStrategyServantActivator.cpp (2 hunks)
  • TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp (1 hunks)
  • TAO/tao/PortableServer/Root_POA.cpp (14 hunks)
✅ Files skipped from review due to trivial changes (4)
  • TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp
  • TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp
  • TAO/tao/PortableServer/Object_Adapter.inl
  • TAO/tao/PortableServer/Object_Adapter.cpp
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: ubuntu-20.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-20.04 clang++-10
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2019Debug64Cxx20
  • GitHub Check: VS2019Debug64Cxx17
  • GitHub Check: VS2019Release32
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: VS2019Debug32
  • GitHub Check: VS2019Release64
  • GitHub Check: VS2019Debug64
  • GitHub Check: VS2019WChar
  • GitHub Check: MINGW64-gcc
  • GitHub Check: windows-2019 vs2019
  • GitHub Check: macos-14-C++
  • GitHub Check: ubuntu-20.04 g++-10
  • GitHub Check: alpine-3.18
  • GitHub Check: ubuntu-22.04 g++-12
  • GitHub Check: macos-13-C++
🔇 Additional comments (6)
TAO/tao/PortableServer/Active_Object_Map.inl (1)

29-29: Optimize object transfers with std::move.

Good use of move semantics to avoid unnecessary copying of the id object when constructing PortableServer::ObjectId.

Also applies to: 246-246

TAO/tao/PortableServer/RequestProcessingStrategyServantActivator.cpp (1)

87-89: Improve code clarity with modern pointer handling.

Good improvements:

  1. Combined initialization and assignment of servant
  2. Using nullptr for pointer comparison instead of 0
TAO/tao/PortableServer/Active_Object_Map.cpp (1)

357-357: Modernize pointer comparisons consistently.

Good consistent replacement of 0 with nullptr for pointer comparisons throughout the file, improving code clarity and type safety.

Also applies to: 423-423, 457-457, 941-941

TAO/tao/PortableServer/Root_POA.cpp (3)

603-603: Modernize guard return values.

Good consistent update of TAO_POA_GUARD_RETURN statements to return nullptr instead of 0, improving type safety.

Also applies to: 696-696, 734-734, 753-753, 762-762, 1134-1134, 1468-1468, 2490-2490


1390-1390: Improve pointer comparisons with nullptr.

Good consistent replacement of 0 with nullptr for pointer comparisons, enhancing code clarity and type safety.

Also applies to: 1323-1323, 2486-2486, 2493-2493


2504-2504: Return nullptr from server_protocol.

Good update to return nullptr instead of 0 from the server_protocol method.

    * TAO/tao/PortableServer/Active_Object_Map.cpp:
    * TAO/tao/PortableServer/Active_Object_Map.inl:
    * TAO/tao/PortableServer/Collocated_Object_Proxy_Broker.cpp:
    * TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp:
    * TAO/tao/PortableServer/IdAssignmentPolicy.cpp:
    * TAO/tao/PortableServer/ImplicitActivationPolicy.cpp:
    * TAO/tao/PortableServer/LifespanPolicy.cpp:
    * TAO/tao/PortableServer/LifespanStrategyPersistent.cpp:
    * TAO/tao/PortableServer/Object_Adapter.cpp:
    * TAO/tao/PortableServer/Operation_Table_Binary_Search.cpp:
    * TAO/tao/PortableServer/Operation_Table_Linear_Search.cpp:
    * TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp:
    * TAO/tao/PortableServer/POA_Current.cpp:
    * TAO/tao/PortableServer/PortableServer_Functions.cpp:
    * TAO/tao/PortableServer/Regular_POA.cpp:
    * TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp:
    * TAO/tao/PortableServer/Servant_Base.cpp:
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (13)
TAO/tao/PortableServer/Regular_POA.cpp (1)

35-35: Consider modernizing remaining null checks.

For consistency with the PR's objectives and the modernization already done on line 48, consider updating the remaining null checks to use nullptr:

-  if (this->parent_ != 0)
+  if (this->parent_ != nullptr)
-  if (this->parent_ != 0)
+  if (this->parent_ != nullptr)

Also applies to: 54-54

TAO/tao/PortableServer/PortableServer_Functions.cpp (1)

35-41: Consider further modernization opportunities.

There are additional opportunities to modernize the code:

  1. Initialize the id pointer with nullptr instead of 0
  2. Use nullptr instead of 0 in the error return
  3. Consider using smart pointers for better memory management
-    PortableServer::ObjectId *id = 0;
+    PortableServer::ObjectId *id = nullptr;
     ACE_NEW_RETURN (id,
                     PortableServer::ObjectId (buffer_size,
                                               buffer_size,
                                               buffer,
                                               1),
-                    0);
+                    nullptr);
TAO/tao/PortableServer/Servant_Base.cpp (1)

441-449: Consider modernizing additional null pointer checks for consistency.

For consistency with the modernization effort, consider updating the following:

  1. Line 449: Replace poa_current_impl != 0 with poa_current_impl != nullptr
-  if (poa_current_impl != 0
+  if (poa_current_impl != nullptr
TAO/tao/PortableServer/Collocated_Object_Proxy_Broker.cpp (3)

53-53: Consider using nullptr for pointer initialization.

While using {} for zero-initialization is valid, using nullptr would be more idiomatic for pointer types in modern C++.

-    char * _tao_retval {};
+    char * _tao_retval {nullptr};

166-166: Consider using nullptr for pointer initialization.

While using {} for zero-initialization is valid, using nullptr would be more idiomatic for pointer types in modern C++.

-    CORBA::InterfaceDef_ptr _tao_retval {};
+    CORBA::InterfaceDef_ptr _tao_retval {nullptr};

20-22: Consider modernizing null checks with nullptr.

For consistency with modern C++ practices, consider updating the null checks throughout the file to use nullptr instead of 0.

-    if (stub != 0 &&
+    if (stub != nullptr &&

This change should be applied to all similar checks in the file (lines 20, 58, 96, 134, 173, 193).

Also applies to: 58-60, 96-98, 134-136, 173-175, 193-193

TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp (2)

12-35: Consider additional C++ modernization opportunities.

While the pointer initialization change is good, there are a few more modernization opportunities in this method:

  1. Replace the 0 with nullptr in the TAO_Root_POA constructor call
  2. Mark the string and policy set parameters as const references

Here's the suggested improvement:

 TAO_Root_POA *
-TAO_Default_Servant_Dispatcher::create_Root_POA (const ACE_CString &name,
+TAO_Default_Servant_Dispatcher::create_Root_POA (const ACE_CString &name,
                                                 PortableServer::POAManager_ptr poa_manager,
-                                                const TAO_POA_Policy_Set &policies,
+                                                const TAO_POA_Policy_Set &policies,
                                                 ACE_Lock &lock,
                                                 TAO_SYNCH_MUTEX &thread_lock,
                                                 TAO_ORB_Core &orb_core,
                                                 TAO_Object_Adapter *object_adapter)
 {
   TAO_Root_POA *poa {};

   ACE_NEW_THROW_EX (poa,
                     TAO_Root_POA (name,
                                  poa_manager,
                                  policies,
-                                 0,
+                                 nullptr,
                                  lock,
                                  thread_lock,
                                  orb_core,
                                  object_adapter),
                     CORBA::NO_MEMORY ());

   return poa;
 }

8-10: Consider defaulting the empty destructor.

The empty destructor could be defaulted using = default for better maintainability.

-TAO_Default_Servant_Dispatcher::~TAO_Default_Servant_Dispatcher ()
-{
-}
+TAO_Default_Servant_Dispatcher::~TAO_Default_Servant_Dispatcher () = default;
TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp (1)

39-39: Consider modernizing the skeleton function initialization.

While updating null pointer checks, consider also modernizing the skeleton function initialization.

-      skelfunc = 0; // insure that somebody can't call a wrong function!
+      skelfunc = nullptr; // ensure that somebody can't call a wrong function!

Note: Also fixed the typo in the comment (insure → ensure).

Also applies to: 64-64

TAO/tao/PortableServer/LifespanPolicy.cpp (1)

24-24: Good modernization of pointer initialization!

The change from 0 to {} for pointer initialization aligns with modern C++ practices. Consider also marking the copy method as const since it doesn't modify the object's state.

-    CORBA::Policy_ptr
-    LifespanPolicy::copy ()
+    CORBA::Policy_ptr
+    LifespanPolicy::copy () const
TAO/tao/PortableServer/IdAssignmentPolicy.cpp (1)

23-23: Good modernization of pointer initialization!

The change from 0 to {} for pointer initialization aligns with modern C++ practices. Consider also marking the copy method as const since it doesn't modify the object's state.

-    CORBA::Policy_ptr
-    IdAssignmentPolicy::copy ()
+    CORBA::Policy_ptr
+    IdAssignmentPolicy::copy () const
TAO/tao/PortableServer/ImplicitActivationPolicy.cpp (2)

22-22: Good modernization of pointer initialization!

The change from 0 to {} for pointer initialization aligns with modern C++ practices. Consider also marking the copy method as const since it doesn't modify the object's state.

-    CORBA::Policy_ptr
-    ImplicitActivationPolicy::copy ()
+    CORBA::Policy_ptr
+    ImplicitActivationPolicy::copy () const

1-64: Consider applying consistent improvements across all Policy classes.

The systematic modernization of pointer initialization is good. Consider creating a follow-up PR to:

  1. Mark all Policy class copy methods as const
  2. Consider using std::make_unique or similar smart pointer patterns if memory management modernization is within scope
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d56284 and 4506e73.

📒 Files selected for processing (17)
  • TAO/tao/PortableServer/Active_Object_Map.cpp (16 hunks)
  • TAO/tao/PortableServer/Active_Object_Map.inl (8 hunks)
  • TAO/tao/PortableServer/Collocated_Object_Proxy_Broker.cpp (2 hunks)
  • TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp (1 hunks)
  • TAO/tao/PortableServer/IdAssignmentPolicy.cpp (1 hunks)
  • TAO/tao/PortableServer/ImplicitActivationPolicy.cpp (1 hunks)
  • TAO/tao/PortableServer/LifespanPolicy.cpp (1 hunks)
  • TAO/tao/PortableServer/LifespanStrategyPersistent.cpp (2 hunks)
  • TAO/tao/PortableServer/Object_Adapter.cpp (10 hunks)
  • TAO/tao/PortableServer/Operation_Table_Binary_Search.cpp (2 hunks)
  • TAO/tao/PortableServer/Operation_Table_Linear_Search.cpp (2 hunks)
  • TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp (2 hunks)
  • TAO/tao/PortableServer/POA_Current.cpp (4 hunks)
  • TAO/tao/PortableServer/PortableServer_Functions.cpp (1 hunks)
  • TAO/tao/PortableServer/Regular_POA.cpp (1 hunks)
  • TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp (2 hunks)
  • TAO/tao/PortableServer/Servant_Base.cpp (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • TAO/tao/PortableServer/POA_Current.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
  • TAO/tao/PortableServer/RequestProcessingStrategyServantLocator.cpp
  • TAO/tao/PortableServer/Object_Adapter.cpp
  • TAO/tao/PortableServer/Active_Object_Map.cpp
  • TAO/tao/PortableServer/Active_Object_Map.inl
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: ubuntu-20.04 g++-10 ACE for TAO
  • GitHub Check: macos-13-C++
  • GitHub Check: ubuntu-20.04 clang++-13
  • GitHub Check: ubuntu-20.04 clang++-11
  • GitHub Check: ubuntu-20.04 clang++-10
  • GitHub Check: ubuntu-24.04 g++-13
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2019Debug64Cxx20
  • GitHub Check: VS2019Debug64Cxx17
  • GitHub Check: VS2019Release32
  • GitHub Check: VS2019Debug32
  • GitHub Check: VS2019Release64
  • GitHub Check: VS2019Debug64
  • GitHub Check: VS2019WChar
  • GitHub Check: MINGW64-gcc
  • GitHub Check: alpine-3.18
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: windows-2019 vs2019
  • GitHub Check: ubuntu-20.04 g++-10
🔇 Additional comments (8)
TAO/tao/PortableServer/Regular_POA.cpp (1)

48-48: LGTM! Good use of nullptr.

The change from 0 to nullptr improves code clarity by using modern C++ null pointer semantics.

TAO/tao/PortableServer/LifespanStrategyPersistent.cpp (1)

75-75: LGTM! Good modernization of pointer checks.

The changes to use nullptr instead of 0 for pointer comparisons improve type safety and readability.

Also applies to: 150-150

TAO/tao/PortableServer/PortableServer_Functions.cpp (1)

15-15: LGTM! Good modernization of null pointer check.

The change from 0 to nullptr improves type safety and readability, aligning with modern C++ practices.

TAO/tao/PortableServer/Servant_Base.cpp (1)

392-392: LGTM! Good modernization of null pointer check.

The change from 0 to nullptr improves type safety and readability, aligning with modern C++ best practices.

TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp (1)

21-21: LGTM! Modern pointer initialization.

The use of brace initialization for the pointer is a good modernization that improves clarity and safety.

TAO/tao/PortableServer/Operation_Table_Binary_Search.cpp (1)

38-38: LGTM! Good modernization of null pointer checks.

The changes from 0 to nullptr align with modern C++ practices and improve code clarity.

Also applies to: 58-58

TAO/tao/PortableServer/Operation_Table_Linear_Search.cpp (1)

45-45: LGTM! Consistent modernization across operation table implementations.

The null pointer check updates maintain consistency with the binary search implementation.

Also applies to: 66-66

TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp (1)

37-37: LGTM! Consistent modernization of null pointer checks.

The changes align with modern C++ practices and maintain consistency across all operation table implementations.

Also applies to: 62-62

    * TAO/tao/PortableServer/LifespanStrategyPersistent.cpp:
    * TAO/tao/PortableServer/Root_POA.cpp:
    * TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp:
    * TAO/tao/PortableServer/Default_Servant_Dispatcher.h:
    * TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp:
    * TAO/tao/PortableServer/PortableServer_Functions.cpp:
    * TAO/tao/PortableServer/PortableServer_WFunctions.cpp:
    * TAO/tao/PortableServer/Regular_POA.cpp:
    * TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp:
    * TAO/tao/PortableServer/Servant_Base.cpp:
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
TAO/tao/PortableServer/PortableServer_WFunctions.cpp (1)

9-37: Consider adding safety checks for memory operations.

The function could benefit from additional safety measures:

  1. Add bounds checking for string_length to prevent overflow
  2. Add error handling for allocbuf to handle allocation failures
  3. Consider using RAII or smart pointers to manage memory

Example improvement:

PortableServer::ObjectId *
wstring_to_ObjectId(const CORBA::WChar *string)
{
    if (!string) {
        throw CORBA::BAD_PARAM();
    }

    // Check for overflow
    u_int string_length = ACE_OS::wslen(string);
    if (string_length > std::numeric_limits<CORBA::ULong>::max() / sizeof(CORBA::WChar)) {
        throw CORBA::BAD_PARAM();
    }

    CORBA::ULong buffer_size = string_length * sizeof(CORBA::WChar);

    // Use try/catch or error checking for allocation
    CORBA::Octet *buffer = nullptr;
    try {
        buffer = PortableServer::ObjectId::allocbuf(buffer_size);
        if (!buffer) {
            throw CORBA::NO_MEMORY();
        }
    }
    catch (...) {
        throw CORBA::NO_MEMORY();
    }

    ACE_OS::memcpy(buffer, string, buffer_size);

    PortableServer::ObjectId *id{};
    ACE_NEW_RETURN(id,
                   PortableServer::ObjectId(buffer_size,
                                          buffer_size,
                                          buffer,
                                          1),
                   nullptr);
    return id;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 875250a and 1c69ba9.

📒 Files selected for processing (8)
  • TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp (1 hunks)
  • TAO/tao/PortableServer/Default_Servant_Dispatcher.h (1 hunks)
  • TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp (2 hunks)
  • TAO/tao/PortableServer/PortableServer_Functions.cpp (2 hunks)
  • TAO/tao/PortableServer/PortableServer_WFunctions.cpp (1 hunks)
  • TAO/tao/PortableServer/Regular_POA.cpp (2 hunks)
  • TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp (2 hunks)
  • TAO/tao/PortableServer/Servant_Base.cpp (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • TAO/tao/PortableServer/Default_Servant_Dispatcher.h
🚧 Files skipped from review as they are similar to previous changes (6)
  • TAO/tao/PortableServer/Regular_POA.cpp
  • TAO/tao/PortableServer/Servant_Base.cpp
  • TAO/tao/PortableServer/PortableServer_Functions.cpp
  • TAO/tao/PortableServer/RequestProcessingStrategyDefaultServant.cpp
  • TAO/tao/PortableServer/Operation_Table_Perfect_Hash.cpp
  • TAO/tao/PortableServer/Default_Servant_Dispatcher.cpp
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: ubuntu-20.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-20.04 clang++-11
  • GitHub Check: ubuntu-20.04 clang++-10
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2019Debug64Cxx20
  • GitHub Check: VS2019Debug64Cxx17
  • GitHub Check: VS2019Release32
  • GitHub Check: VS2019Debug32
  • GitHub Check: VS2019Release64
  • GitHub Check: ubuntu-20.04 g++-10
  • GitHub Check: VS2019Debug64
  • GitHub Check: VS2019WChar
  • GitHub Check: MINGW64-gcc
  • GitHub Check: alpine-3.18
  • GitHub Check: windows-2019 vs2019
  • GitHub Check: macos-14-C++
  • GitHub Check: macos-13-C++
🔇 Additional comments (2)
TAO/tao/PortableServer/PortableServer_WFunctions.cpp (2)

28-28: LGTM! Good use of modern C++ initialization.

Using {} for pointer initialization is a modern C++ practice that provides more consistent initialization syntax and prevents narrowing conversions.


34-34: LGTM! Good use of nullptr.

Using nullptr instead of 0 for pointer values improves type safety and makes the code's intent more explicit.

    * TAO/tao/PortableServer/Network_Priority_Hook.h:
    * TAO/tao/PortableServer/Object_Adapter.cpp:
    * TAO/tao/PortableServer/Object_Adapter.h:
    * TAO/tao/PortableServer/POA_Cached_Policies.cpp:
    * TAO/tao/PortableServer/POA_Cached_Policies.h:
    * TAO/tao/PortableServer/POA_Policy_Set.cpp:
    * TAO/tao/PortableServer/POA_Policy_Set.h:
    * TAO/tao/PortableServer/Servant_Base.cpp:
    * TAO/tao/PortableServer/Servant_Base.h:
    * TAO/tao/PortableServer/Object_Adapter.h:
    * TAO/tao/PortableServer/Network_Priority_Hook.h:
    * TAO/tao/DiffServPolicy/DiffServ_Network_Priority_Hook.cpp:
    * TAO/tao/DiffServPolicy/DiffServ_Network_Priority_Hook.h:
    * TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.cpp:
    * TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h:
    * TAO/tao/EndpointPolicy/EndpointPolicy_i.cpp:
    * TAO/tao/EndpointPolicy/EndpointPolicy_i.h:
    * TAO/tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.cpp:
    * TAO/tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.h:
    * TAO/tao/EndpointPolicy/IIOPEndpointValue_i.cpp:
    * TAO/tao/EndpointPolicy/IIOPEndpointValue_i.h:
    * TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h:
    * TAO/tao/PortableServer/Network_Priority_Hook.cpp:
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
TAO/tao/EndpointPolicy/EndpointPolicy_i.cpp (2)

20-24: Add const qualifier to policy_type method.

This method doesn't modify any class state and should be marked as const.

-CORBA::PolicyType
-TAO_EndpointPolicy_i::policy_type ()
+CORBA::PolicyType
+TAO_EndpointPolicy_i::policy_type () const

50-56: Consider using nullptr in ACE_NEW_THROW_EX.

While the initialization with {} is good, consider using nullptr consistently across all memory allocation macros.

-  ACE_NEW_THROW_EX (servant,
-                    TAO_EndpointPolicy_i (*this),
-                    CORBA::NO_MEMORY ());
+  ACE_NEW_THROW_EX (servant,
+                    TAO_EndpointPolicy_i (*this),
+                    CORBA::NO_MEMORY (nullptr));
TAO/tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.cpp (3)

16-16: Consider using nullptr for pointer initialization.

Replace 0 with nullptr for pointer initialization to follow modern C++ practices.

-  TAO_Acceptor_Filter* filter = 0;
+  TAO_Acceptor_Filter* filter = nullptr;

23-24: Use nullptr for return value.

Replace 0 with nullptr when returning a pointer type.

-            return 0;
+            return nullptr;

39-48: Use nullptr in ACE_NEW_RETURN calls.

Replace 0 with nullptr in error handling of memory allocation.

   if (endpoints.length () > 0)
     ACE_NEW_RETURN (filter,
                     TAO_Endpoint_Acceptor_Filter (endpoints),
-                    0);
+                    nullptr);
   else
     // no policy was in force, just return a default filter
     ACE_NEW_RETURN (filter,
                     TAO_Default_Acceptor_Filter (),
-                    0);
+                    nullptr);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e6aac1 and f35a205.

📒 Files selected for processing (8)
  • TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h (2 hunks)
  • TAO/tao/EndpointPolicy/EndpointPolicy_i.cpp (1 hunks)
  • TAO/tao/EndpointPolicy/EndpointPolicy_i.h (1 hunks)
  • TAO/tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.cpp (1 hunks)
  • TAO/tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.h (1 hunks)
  • TAO/tao/EndpointPolicy/IIOPEndpointValue_i.cpp (2 hunks)
  • TAO/tao/EndpointPolicy/IIOPEndpointValue_i.h (1 hunks)
  • TAO/tao/PortableServer/Network_Priority_Hook.cpp (0 hunks)
💤 Files with no reviewable changes (1)
  • TAO/tao/PortableServer/Network_Priority_Hook.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: ubuntu-20.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-20.04 clang++-11
  • GitHub Check: ubuntu-20.04 clang++-10
  • GitHub Check: ubuntu-24.04 g++-13
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2019Debug64Cxx20
  • GitHub Check: VS2019Debug64Cxx17
  • GitHub Check: VS2019Release32
  • GitHub Check: VS2019Debug32
  • GitHub Check: VS2019Release64
  • GitHub Check: VS2019Debug64
  • GitHub Check: VS2019WChar
  • GitHub Check: MINGW64-gcc
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: macos-14-C++
  • GitHub Check: windows-2019 vs2019
  • GitHub Check: macos-13-C++
  • GitHub Check: alpine-3.18
  • GitHub Check: ubuntu-20.04 g++-10
🔇 Additional comments (6)
TAO/tao/EndpointPolicy/EndpointPolicy_i.cpp (1)

29-33: LGTM! Good use of modern C++ initialization.

The use of {} for pointer initialization and nullptr for error handling is a good modernization practice.

TAO/tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.h (1)

40-40: LGTM! Good use of default destructor.

Using = default for the destructor is a good modern C++ practice when no custom cleanup is needed.

TAO/tao/EndpointPolicy/EndpointPolicy_i.h (1)

53-53: LGTM! Good use of default destructor.

Using = default for the destructor is a good modern C++ practice when no custom cleanup is needed.

TAO/tao/EndpointPolicy/IIOPEndpointValue_i.cpp (2)

31-32: LGTM! Good modernization of pointer check and boolean return.

The changes improve code clarity by using nullptr for pointer comparison and false for boolean return, which is more idiomatic in modern C++.


53-53: LGTM! Good modernization of pointer check.

The change improves code clarity by using nullptr for pointer comparison, which is more idiomatic in modern C++.

TAO/tao/EndpointPolicy/IIOPEndpointValue_i.h (1)

69-69: LGTM! Good use of default destructor.

The change to use = default is appropriate as the class doesn't need custom cleanup. The virtual destructor is correctly maintained for the virtual inheritance hierarchy, and all member variables have proper destructors.

@jwillemsen jwillemsen merged commit e727b7e into DOCGroup:master Feb 7, 2025
46 checks passed
@jwillemsen jwillemsen deleted the jwi-nullptrmove branch February 7, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant