[CODE HEALTH] Move func_grpc_main classes into anonymous namespace#4129
Merged
marcalff merged 1 commit intoJun 6, 2026
Merged
Conversation
Wraps the 3 file-scope class and struct declarations in functional/otlp/func_grpc_main.cc within an anonymous namespace to give them internal linkage and clear the misc-use-internal-linkage warnings clang-tidy reports on this file. The wrap covers TestResult (line 63), TestLogHandler (line 128), and test_case (line 316). It deliberately ends BEFORE the static int test_*() forward declarations at line 322+. This boundary follows the same pattern as open-telemetry#4128 (func_http_main): the test_*() declarations are matched by definitions in the lower half of the file (after main()). Wrapping the declarations alone would create (anonymous namespace)::test_* symbols that fail to link against the file-scope static test_*() definitions. Local verification: build of func_otlp_grpc target with WITH_OTLP_HTTP=ON + WITH_OTLP_GRPC=ON succeeded 122/122 ninja steps; --help smoke test prints usage as expected. main() and all test_*() infrastructure (declarations, the all_tests[] table, list_test_cases, run_test_case, and definitions) remain at file scope with their existing static linkage. Ratchet: * abiv1-preview warning_limit lowered from 349 to 346 * abiv2-preview warning_limit lowered from 353 to 350 Part of open-telemetry#2053 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
f710a4e to
5cb0ddf
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4129 +/- ##
=======================================
Coverage 81.94% 81.94%
=======================================
Files 385 385
Lines 16067 16067
=======================================
Hits 13164 13164
Misses 2903 2903 🚀 New features to boost your workflow:
|
marcalff
approved these changes
Jun 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps the 3 file-scope class/struct declarations in
functional/otlp/func_grpc_main.ccwithin an anonymous namespace,clearing the misc-use-internal-linkage warnings.
7th PR of the misc-use-internal-linkage campaign and the twin of
#4128 (func_http_main, merged). Same wrap pattern, same boundary
rationale, same +3 site clearance.
Changes
functional/otlp/func_grpc_main.cc: insertnamespace {afterthe command-line
opt_*variables and} // namespaceafter thetest_casestruct closing brace. Wrap coversTestResult(line63),
TestLogHandler(line 128), andtest_case(line 316)..github/workflows/clang-tidy.yaml: abiv1 349 -> 346 (-3),abiv2 353 -> 350 (-3).
CHANGELOG.md: one bullet under [Unreleased].Why the wrap ends before line 322
Same rationale as #4128: the
static int test_*()forwarddeclarations are matched by definitions in the lower half of the
file (after
main()). Wrapping declarations alone would produce(anonymous namespace)::test_*symbols that fail to link.main(), thestatic const test_case all_tests[]table,list_test_cases,run_test_case, and the test definitions remainat file scope.
Test plan
func_otlp_grpc: 122/122 ninja steps(
-DWITH_OTLP_HTTP=ON -DWITH_OTLP_GRPC=ONper the CMake quirkthat the outer
functional/CMakeLists.txtonly addsotlpsubdirwhen
WITH_OTLP_HTTP=ON)func_otlp_grpc --helpsmoke test prints usageclang-format --dry-run --Werrorclean on the modified filePart of #2053