Skip to content

Use null, override, default#2473

Merged
jwillemsen merged 1 commit intoDOCGroup:masterfrom
jwillemsen:jwi-overridenull
Oct 21, 2025
Merged

Use null, override, default#2473
jwillemsen merged 1 commit intoDOCGroup:masterfrom
jwillemsen:jwi-overridenull

Conversation

@jwillemsen
Copy link
Copy Markdown
Member

@jwillemsen jwillemsen commented Oct 21, 2025

* TAO/docs/releasenotes/orbcore.html:
* TAO/tao/Acceptor_Impl.cpp:
* TAO/tao/Connection_Purging_Strategy.cpp:
* TAO/tao/Connection_Purging_Strategy.h:
* TAO/tao/LRU_Connection_Purging_Strategy.cpp:
* TAO/tao/LRU_Connection_Purging_Strategy.h:
* TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h:
* TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h:
* TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h:
* TAO/tao/Transport_Cache_Manager_T.cpp:
* TAO/tao/Transport_Cache_Manager_T.h:
* TAO/tao/Transport_Timer.h:
* TAO/tao/default_resource.cpp:
* TAO/tao/orbconf.h:

Summary by CodeRabbit

  • Documentation

    • Fixed spelling errors in release notes and code comments.
  • Style

    • Modernized code to use contemporary C++ standards (nullptr, override specifiers, explicit constructors, default destructors).
    • Minor formatting improvements.

    * TAO/docs/releasenotes/orbcore.html:
    * TAO/tao/Acceptor_Impl.cpp:
    * TAO/tao/Connection_Purging_Strategy.cpp:
    * TAO/tao/Connection_Purging_Strategy.h:
    * TAO/tao/LRU_Connection_Purging_Strategy.cpp:
    * TAO/tao/LRU_Connection_Purging_Strategy.h:
    * TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h:
    * TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h:
    * TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h:
    * TAO/tao/Transport_Cache_Manager_T.cpp:
    * TAO/tao/Transport_Cache_Manager_T.h:
    * TAO/tao/Transport_Timer.h:
    * TAO/tao/default_resource.cpp:
    * TAO/tao/orbconf.h:
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

This pull request modernizes C++ coding patterns across TAO by replacing integer null pointer literals (0) with nullptr, adding override specifiers to virtual function implementations, making destructors defaulted, and adding const/in-class initialization to member variables. Minor textual and formatting corrections are also included.

Changes

Cohort / File(s) Summary
Documentation & Comment Fixes
TAO/docs/releasenotes/orbcore.html, TAO/tao/Transport_Cache_Manager_T.h, TAO/tao/orbconf.h
Corrected typos: "prt" → "part", "compeling" → "compelling", and removed extraneous "Service" in comments. No functional changes.
Nullptr Modernization
TAO/tao/Acceptor_Impl.cpp, TAO/tao/Transport_Cache_Manager_T.cpp
Replaced null pointer comparisons with 0 to use modern C++ nullptr literal throughout pointer checks and assignments.
Connection_Purging_Strategy Base Class
TAO/tao/Connection_Purging_Strategy.h, TAO/tao/Connection_Purging_Strategy.cpp
Changed destructor from non-defaulted virtual to = default, and removed the empty destructor implementation. Made cache_maximum_ member const.
LRU_Connection_Purging_Strategy
TAO/tao/LRU_Connection_Purging_Strategy.h, TAO/tao/LRU_Connection_Purging_Strategy.cpp
Added override specifiers to destructor and update_item; added in-class initialization {} to order_ member; removed explicit destructor definition and constructor initialization of order_.
Other Purging Strategy Subclasses
TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h, TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h, TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h
Added override specifiers to update_item and cache_maximum methods, replacing explicit virtual declarations with override.
Transport_Timer & Default Resource Factory
TAO/tao/Transport_Timer.h, TAO/tao/default_resource.cpp
Made Transport_Timer constructor explicit; updated handle_timeout to use override specifier; reformatted TAO_LRU_Connection_Purging_Strategy instantiation to single line.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Rationale: While most changes are mechanical (nullptr replacement, override specifiers, formatting), the modifications to member variable initialization in LRU_Connection_Purging_Strategy (removal of explicit initialization in constructor coupled with in-class {} initialization) warrant careful verification of initialization semantics across multiple related files. The changes are relatively homogeneous but span 13+ files requiring consistent verification of nullptr safety and virtual function override correctness.

Suggested reviewers

  • sonndinh
  • jrw972

Poem

🐰 With nullptr replacing zero, and override on display,
The code hops toward modern C++ in every single way,
Defaults dance through destructors, fresh and clean,
While typos fade away—the best we've ever seen!
TAO leaps ahead with grace and style today! 🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Use null, override, default" directly corresponds to the three primary categories of changes in the changeset. The PR modernizes C++ code across multiple transport and connection purging strategy files by: (1) replacing null pointer comparisons with nullptr, (2) adding override specifiers to virtual functions in derived classes, and (3) using defaulted functions (= default) for constructors and destructors. The title is concise, specific, and clearly communicates the main modernization objectives without attempting to detail every change (such as minor textual corrections and formatting adjustments, which are appropriately excluded).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@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: 2

🧹 Nitpick comments (5)
TAO/tao/Acceptor_Impl.cpp (1)

33-37: Prefer nullptr over 0 in base ctor init.

Minor consistency nit: replace literal 0 with nullptr in ACE_Creation_Strategy base init.

Apply this diff:

-  : ACE_Creation_Strategy<SVC_HANDLER> (0, orb_core->reactor()),
+  : ACE_Creation_Strategy<SVC_HANDLER> (nullptr, orb_core->reactor()),
TAO/tao/Transport_Cache_Manager_T.cpp (2)

387-388: Early return on nullptr is correct; drop redundant (void)

Guard is good. The subsequent call uses a void-returning method; the (void) cast is unnecessary.

-    purging_strategy *st = this->purging_strategy_;
-    (void) st->update_item (*(entry->item ().transport ()));
+    purging_strategy *st = this->purging_strategy_;
+    st->update_item (*(entry->item ().transport ()));

98-98: Consider completing the nullptr migration

Line 98 correctly uses nullptr for pointer initialization. The file contains many remaining instances where 0 is used for pointer initialization and comparison that could be converted to nullptr for consistency with modern C++ practices, including:

  • Member initializations: lines 35, 38–39
  • Pointer variable declarations: lines 125, 283, 286
  • Pointer assignments: lines 232, 292, 413, 568, 631, 712
  • Pointer comparisons: lines 356, 467, 517, 574

This is an optional refactoring to improve consistency across the file.

TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h (1)

44-49: override looks good; align init/dtor with LRU for consistency

Recommend default-initializing order_ and defaulting the virtual destructor (if present in impl) for parity with LRU.

 class TAO_Strategies_Export TAO_FIFO_Connection_Purging_Strategy:
                             public TAO_Connection_Purging_Strategy
 {
 public:
   /// The constructor
   TAO_FIFO_Connection_Purging_Strategy (int cache_maximum);
 
   /// Called when accessing an item from the cache
   void update_item (TAO_Transport& transport) override;
 
 private:
   /// The ordering information for each transport in the cache
-  unsigned long order_;
+  unsigned long order_ {};
 };

If a custom destructor exists out-of-line, consider:

-  // existing dtor (if any)
+  ~TAO_FIFO_Connection_Purging_Strategy () override = default;
TAO/tao/LRU_Connection_Purging_Strategy.h (1)

43-52: Nice modernization: defaulted dtor, override, in-class init

All three improve clarity and safety. Optionally mark the single-arg ctor explicit (see cpp comment) for uniformity.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be28451 and 2bc86f2.

📒 Files selected for processing (14)
  • TAO/docs/releasenotes/orbcore.html (1 hunks)
  • TAO/tao/Acceptor_Impl.cpp (1 hunks)
  • TAO/tao/Connection_Purging_Strategy.cpp (0 hunks)
  • TAO/tao/Connection_Purging_Strategy.h (2 hunks)
  • TAO/tao/LRU_Connection_Purging_Strategy.cpp (1 hunks)
  • TAO/tao/LRU_Connection_Purging_Strategy.h (1 hunks)
  • TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h (1 hunks)
  • TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h (1 hunks)
  • TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h (1 hunks)
  • TAO/tao/Transport_Cache_Manager_T.cpp (4 hunks)
  • TAO/tao/Transport_Cache_Manager_T.h (1 hunks)
  • TAO/tao/Transport_Timer.h (1 hunks)
  • TAO/tao/default_resource.cpp (1 hunks)
  • TAO/tao/orbconf.h (1 hunks)
💤 Files with no reviewable changes (1)
  • TAO/tao/Connection_Purging_Strategy.cpp
🧰 Additional context used
🧬 Code graph analysis (6)
TAO/tao/LRU_Connection_Purging_Strategy.h (1)
TAO/tao/LRU_Connection_Purging_Strategy.cpp (4)
  • TAO_LRU_Connection_Purging_Strategy (4-9)
  • TAO_LRU_Connection_Purging_Strategy (6-7)
  • update_item (11-15)
  • update_item (12-12)
TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h (1)
TAO/tao/LRU_Connection_Purging_Strategy.cpp (2)
  • update_item (11-15)
  • update_item (12-12)
TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h (3)
TAO/tao/LRU_Connection_Purging_Strategy.cpp (2)
  • update_item (11-15)
  • update_item (12-12)
TAO/tao/default_resource.cpp (2)
  • cache_maximum (1006-1010)
  • cache_maximum (1007-1007)
TAO/tao/Connection_Purging_Strategy.cpp (1)
  • cache_maximum (10-10)
TAO/tao/default_resource.cpp (2)
TAO/tao/LRU_Connection_Purging_Strategy.cpp (2)
  • TAO_LRU_Connection_Purging_Strategy (4-9)
  • TAO_LRU_Connection_Purging_Strategy (6-7)
TAO/tao/LRU_Connection_Purging_Strategy.h (1)
  • TAO_LRU_Connection_Purging_Strategy (36-52)
TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h (1)
TAO/tao/LRU_Connection_Purging_Strategy.cpp (2)
  • update_item (11-15)
  • update_item (12-12)
TAO/tao/LRU_Connection_Purging_Strategy.cpp (1)
TAO/tao/LRU_Connection_Purging_Strategy.h (1)
  • TAO_LRU_Connection_Purging_Strategy (36-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: macos-13-C++
  • GitHub Check: macos-14-C++
  • GitHub Check: ubuntu-24.04 g++-10 CORBA/e micro
  • GitHub Check: ubuntu-24.04 g++-10 wchar
  • GitHub Check: ubuntu-24.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-22.04 clang++-12
  • GitHub Check: ubuntu-24.04 g++-10 CodeQL
  • GitHub Check: ubuntu-24.04 g++-14
  • GitHub Check: ubuntu-24.04 clang++-14
  • GitHub Check: ubuntu-22.04 g++-10
  • GitHub Check: ubuntu-24.04 clang++-16
  • GitHub Check: ubuntu-22.04 clang++-13
  • GitHub Check: ubuntu-24.04 clang++-20
  • GitHub Check: ubuntu-24.04 g++-13
  • GitHub Check: ubuntu-24.04 clang++-15
  • GitHub Check: ubuntu-24.04 clang++-20 c++23
  • GitHub Check: ubuntu-24.04 g++-10 CORBA/e compact
  • GitHub Check: ubuntu-24.04 g++-11
  • GitHub Check: ubuntu-24.04 g++-12
  • GitHub Check: ubuntu-22.04 g++-9
🔇 Additional comments (12)
TAO/docs/releasenotes/orbcore.html (1)

147-147: Typo fix LGTM.

“part of the TAO_Messaging” reads correctly now.

TAO/tao/orbconf.h (1)

154-156: Comment tweak LGTM.

No functional change; clearer wording.

TAO/tao/Acceptor_Impl.cpp (1)

43-51: nullptr check LGTM.

Matches the PR’s modernization goal and is semantically correct.

TAO/tao/Transport_Cache_Manager_T.h (1)

54-56: Spelling fix LGTM.

Documentation clarity improved; no code impact.

TAO/tao/Transport_Timer.h (1)

43-43: explicit constructor LGTM.

Prevents unintended implicit conversions.

TAO/tao/default_resource.cpp (1)

1075-1080: LRU strategy construction cleanup LGTM.

Behavior unchanged; reads clearer.

TAO/tao/Connection_Purging_Strategy.h (2)

45-45: Defaulted virtual destructor verified—no ODR concerns.

Verification confirms no out-of-line destructor definition exists in implementation files (Connection_Purging_Strategy.inl or .cpp). The defaulted inline declaration at line 45 is the only definition, so the change is safe from an ODR perspective.


55-56: Verified: cache_maximum_ const is safe; no reassignments found.

The member cache_maximum_ is already declared as const in the header. Verification found only one assignment to cache_maximum_ at line 321 in default_resource.cpp, which occurs during constructor initialization of a different class (TAO_Default_Resource_Factory). No writes to cache_maximum_ exist within Connection_Purging_Strategy itself post-construction. The const qualifier is correctly applied and safe.

TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h (1)

43-43: override addition is correct

Clearer intent; no behavioral change.

TAO/tao/Transport_Cache_Manager_T.cpp (2)

79-83: Post-delete nullptr assignment is harmless

Sets deleted pointers to nullptr; safe though not strictly necessary in a destructor. Consistent with the file’s nullptr shift.


435-435: Minor style tidy is fine

Local const bool improves readability; no behavior change.

TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h (1)

41-44: LGTM! Good modernization with the override specifier.

Adding the override keyword to both update_item and cache_maximum is an excellent C++11 modernization that provides compile-time verification that these methods correctly override base class virtuals. This enhances type safety and makes the code more maintainable.

Comment on lines +6 to 8
TAO_LRU_Connection_Purging_Strategy::TAO_LRU_Connection_Purging_Strategy (int cache_maximum)
: TAO_Connection_Purging_Strategy (cache_maximum)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Ctor cleanup aligned with in-class init; LGTM

Relying on header’s order_ {} is fine. Consider making the ctor explicit to avoid accidental implicit conversions from int.

Diff (header):

-  TAO_LRU_Connection_Purging_Strategy (int cache_maximum);
+  explicit TAO_LRU_Connection_Purging_Strategy (int cache_maximum);

Run to confirm a key out-of-line virtual exists (vtable anchor):


🏁 Script executed:

#!/bin/bash
rg -nP '^\s*void\s+TAO_LRU_Connection_Purging_Strategy::update_item\s*\(' tao -g '!**/test/**'

Length of output: 43


I need to explore the repository structure since the previous path didn't work. Let me search for the relevant files:


---

🏁 Script executed:

```shell
#!/bin/bash
# Find the LRU_Connection_Purging_Strategy files
fd 'LRU_Connection_Purging_Strategy' --type f

Length of output: 85


🏁 Script executed:

#!/bin/bash
# List repository structure at root
ls -la | head -20

Length of output: 584


🏁 Script executed:

#!/bin/bash
# Search for update_item method in the codebase
rg -nP 'update_item' --type cpp --type h -C 2

Length of output: 5005


Now let me examine the header file to verify the in-class initialization and check the current state of the constructor:


---

🏁 Script executed:

```shell
#!/bin/bash
# View the header file to check order_ in-class init and explicit keyword
cat TAO/tao/LRU_Connection_Purging_Strategy.h

Length of output: 1502


🏁 Script executed:

#!/bin/bash
# View the constructor implementation
cat TAO/tao/LRU_Connection_Purging_Strategy.cpp

Length of output: 424


Add explicit keyword to constructor to prevent implicit conversions

The verification confirms all core aspects are sound:

  • The vtable anchor update_item() exists out-of-line (line 12 of .cpp)
  • Header has order_ {} in-class initialization (line 49)
  • Constructor implementation (lines 6-8) correctly relies on the header's in-class init

However, the suggested explicit keyword has not yet been applied. Without it, the constructor allows implicit conversion from int to TAO_LRU_Connection_Purging_Strategy, which should be prevented.

Diff (header, line 39):

-  TAO_LRU_Connection_Purging_Strategy (int cache_maximum);
+  explicit TAO_LRU_Connection_Purging_Strategy (int cache_maximum);

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
TAO/tao/LRU_Connection_Purging_Strategy.cpp lines 6-8: the constructor allows
implicit conversion from int to TAO_LRU_Connection_Purging_Strategy; to fix,
modify the constructor declaration in the header at line 39 to be explicit (i.e.
add the explicit keyword before the constructor declaration) so implicit
conversions are prevented while leaving the .cpp implementation unchanged.

Comment thread TAO/tao/Transport_Timer.h
/// TAO_Transport
virtual int handle_timeout (const ACE_Time_Value &current_time,
const void *act);
int handle_timeout (const ACE_Time_Value &current_time, const void *act) override;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Keep default parameter to avoid source breaks.

ACE_Event_Handler::handle_timeout typically provides a default for the second arg. Dropping the default here may break code that calls handle_timeout(current_time) via TAO_Transport_Timer static type. Keep override but retain the default.

Apply this diff:

-  int handle_timeout (const ACE_Time_Value &current_time, const void *act) override;
+  int handle_timeout (const ACE_Time_Value &current_time,
+                      const void *act = nullptr) override;

Please confirm the base signature in your ACE version includes a default for act and that no calls in TAO rely on the derived default. To check:


🏁 Script executed:

#!/bin/bash
# Locate ACE base declaration (adjust path if needed)
fd -a Event_Handler.h | xargs rg -n "handle_timeout\s*\(.*const\s+void\s*\*\s*\w*\s*=\s*0"
# Find potential 1-arg calls on TAO_Transport_Timer
rg -nP --type=cpp -C2 '\bTAO_Transport_Timer\b.*\bhandle_timeout\s*\(\s*[^,()]+\s*\)\s*;' -g '!**/generated/**'

Length of output: 0


I'll verify this in multiple ways since the initial script didn't find results (likely because ACE is external). Let me inspect the Transport_Timer.h file directly and search for handle_timeout calls.

Good news—the ACE base signature does include a default parameter: const void *act = 0. Now let me verify the Transport_Timer.h file and search for any single-argument calls to handle_timeout in the TAO codebase.


---

🏁 Script executed:

```shell
#!/bin/bash
# Find and inspect Transport_Timer.h
fd Transport_Timer.h -x cat {}

# Search for all handle_timeout calls in TAO
echo "=== Searching for handle_timeout calls ==="
rg -nP "handle_timeout\s*\(" --type=cpp -g '!**/generated/**' -A1

Length of output: 73568


Now let me verify if there are any direct calls to TAO_Transport_Timer::handle_timeout with a single argument in the codebase to be thorough:Perfect. The web search confirms that ACE_Event_Handler::handle_timeout has const void *act = 0 as the default parameter. The review comment is accurate and the recommendation is sound.

Add default parameter to handle_timeout to maintain compatibility with base class contract.

The ACE_Event_Handler base class declares handle_timeout with a default parameter const void *act = 0. Removing this default in the derived TAO_Transport_Timer class breaks source compatibility—code that calls handle_timeout(current_time) via the derived type will fail to compile. This is inconsistent with other connection handler classes in TAO that retain the default.

Apply this diff:

-  int handle_timeout (const ACE_Time_Value &current_time, const void *act) override;
+  int handle_timeout (const ACE_Time_Value &current_time,
+                      const void *act = nullptr) override;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
int handle_timeout (const ACE_Time_Value &current_time, const void *act) override;
int handle_timeout (const ACE_Time_Value &current_time,
const void *act = nullptr) override;
🤖 Prompt for AI Agents
In TAO/tao/Transport_Timer.h around line 47, the derived declaration of int
handle_timeout(const ACE_Time_Value &current_time, const void *act) override is
missing the default value for the second parameter; update the declaration to
include the default argument (const void *act = 0) so it matches the
ACE_Event_Handler base signature and preserves source compatibility, keeping the
override specifier intact.

@jwillemsen jwillemsen merged commit 4aeab85 into DOCGroup:master Oct 21, 2025
39 checks passed
@jwillemsen jwillemsen deleted the jwi-overridenull branch October 21, 2025 12:03
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