diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 19ec7f1573..2cc9b91eaa 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -17,9 +17,9 @@ jobs: matrix: include: - cmake_options: all-options-abiv1-preview - warning_limit: 389 + warning_limit: 385 - cmake_options: all-options-abiv2-preview - warning_limit: 395 + warning_limit: 391 env: CC: /usr/bin/clang-22 CXX: /usr/bin/clang++-22 diff --git a/CHANGELOG.md b/CHANGELOG.md index e57d7fa70b..d953ee278b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ Increment the: * [CODE HEALTH] Fix IWYU Clang22 warnings [#4083](https://github.com/open-telemetry/opentelemetry-cpp/pull/4083) +* [CODE HEALTH] Fix clang-tidy narrowing-conversions warnings in otlp_populate_attribute_utils + [#4090](https://github.com/open-telemetry/opentelemetry-cpp/pull/4090) + * [CODE HEALTH] Remove unused alias declarations [#4091](https://github.com/open-telemetry/opentelemetry-cpp/pull/4091) diff --git a/exporters/otlp/src/otlp_populate_attribute_utils.cc b/exporters/otlp/src/otlp_populate_attribute_utils.cc index 75e47998ab..1fa384553a 100644 --- a/exporters/otlp/src/otlp_populate_attribute_utils.cc +++ b/exporters/otlp/src/otlp_populate_attribute_utils.cc @@ -75,8 +75,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( } else if (nostd::holds_alternative(value)) { - proto_value->set_int_value( - nostd::get(value)); // NOLINT(cppcoreguidelines-narrowing-conversions) + // uint64_t narrowed to int64_t; OTLP int_value is signed, behavior intentional. + proto_value->set_int_value(static_cast(nostd::get(value))); } else if (nostd::holds_alternative(value)) { @@ -166,10 +166,10 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( else if (nostd::holds_alternative>(value)) { auto array_value = proto_value->mutable_array_value(); + // uint64_t narrowed to int64_t; OTLP int_value is signed, behavior intentional. for (const auto &val : nostd::get>(value)) { - array_value->add_values()->set_int_value( - val); // NOLINT(cppcoreguidelines-narrowing-conversions) + array_value->add_values()->set_int_value(static_cast(val)); } } else if (nostd::holds_alternative>(value)) @@ -235,8 +235,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( } else if (nostd::holds_alternative(value)) { - proto_value->set_int_value( - nostd::get(value)); // NOLINT(cppcoreguidelines-narrowing-conversions) + // uint64_t narrowed to int64_t; OTLP int_value is signed, behavior intentional. + proto_value->set_int_value(static_cast(nostd::get(value))); } else if (nostd::holds_alternative(value)) { @@ -311,10 +311,10 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( else if (nostd::holds_alternative>(value)) { auto array_value = proto_value->mutable_array_value(); + // uint64_t narrowed to int64_t; OTLP int_value is signed, behavior intentional. for (const auto &val : nostd::get>(value)) { - array_value->add_values()->set_int_value( - val); // NOLINT(cppcoreguidelines-narrowing-conversions) + array_value->add_values()->set_int_value(static_cast(val)); } } else if (nostd::holds_alternative>(value))