Skip to content

Commit c19932d

Browse files
committed
[CODE HEALTH] Fix clang-tidy misc-use-internal-linkage warnings
Mark list_test_cases in func_grpc_main as static, and make the thread_local RNG in circular_buffer_benchmark explicitly static. The foo_library functions in the common example libraries are exported via headers and linked into multiple example binaries, so internal linkage is not possible; suppress those two with NOLINTNEXTLINE instead. Decrement clang-tidy warning limits by 4 to match the fewer unique warnings. Fixes #3977 Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
1 parent 37a57da commit c19932d

File tree

6 files changed

+9
-4
lines changed

6 files changed

+9
-4
lines changed

.github/workflows/clang-tidy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
matrix:
1818
include:
1919
- cmake_options: all-options-abiv1-preview
20-
warning_limit: 57
20+
warning_limit: 53
2121
- cmake_options: all-options-abiv2-preview
22-
warning_limit: 59
22+
warning_limit: 55
2323
env:
2424
CC: /usr/bin/clang-18
2525
CXX: /usr/bin/clang++-18

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Increment the:
3737
* [CODE HEALTH] Cleanup nostd variant access in API and SDK
3838
[#3965](https://github.com/open-telemetry/opentelemetry-cpp/pull/3965)
3939

40+
* [CODE HEALTH] Fix clang-tidy misc-use-internal-linkage warnings
41+
[#3977](https://github.com/open-telemetry/opentelemetry-cpp/issues/3977)
42+
4043
* Enable WITH_OTLP_RETRY_PREVIEW by default
4144
[#3953](https://github.com/open-telemetry/opentelemetry-cpp/pull/3953)
4245

examples/common/foo_library/foo_library.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void f2()
3333
}
3434
} // namespace
3535

36+
// NOLINTNEXTLINE(misc-use-internal-linkage)
3637
void foo_library()
3738
{
3839
auto scoped_span = trace::Scope(get_tracer()->StartSpan("library"));

examples/common/logs_foo_library/foo_library.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ opentelemetry::nostd::shared_ptr<logs::Logger> get_logger()
3131
}
3232
} // namespace
3333

34+
// NOLINTNEXTLINE(misc-use-internal-linkage)
3435
void foo_library()
3536
{
3637
auto span = get_tracer()->StartSpan("span 1");

functional/otlp/func_grpc_main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static const test_case all_tests[] = {{"basic", test_basic},
353353
#endif // ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW
354354
{"", nullptr}};
355355

356-
void list_test_cases()
356+
static void list_test_cases()
357357
{
358358
const test_case *current = all_tests;
359359

sdk/test/common/circular_buffer_benchmark.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static uint64_t ConsumeBufferNumbers(CircularBuffer<uint64_t> &buffer) noexcept
5555
template <class Buffer>
5656
static void GenerateNumbersForThread(Buffer &buffer, int n, std::atomic<uint64_t> &sum) noexcept
5757
{
58-
thread_local std::mt19937_64 random_number_generator{std::random_device{}()};
58+
static thread_local std::mt19937_64 random_number_generator{std::random_device{}()};
5959
for (int i = 0; i < n; ++i)
6060
{
6161
auto x = random_number_generator();

0 commit comments

Comments
 (0)