diff --git a/api/include/opentelemetry/baggage/baggage.h b/api/include/opentelemetry/baggage/baggage.h index e3e08ff225..6e2354366c 100644 --- a/api/include/opentelemetry/baggage/baggage.h +++ b/api/include/opentelemetry/baggage/baggage.h @@ -121,7 +121,7 @@ class OPENTELEMETRY_EXPORT Baggage } nostd::shared_ptr baggage(new Baggage(cnt)); - bool kv_valid; + bool kv_valid{false}; nostd::string_view key, value; while (kv_str_tokenizer.next(kv_valid, key, value) && baggage->kv_properties_->Size() < cnt) diff --git a/api/include/opentelemetry/trace/propagation/http_trace_context.h b/api/include/opentelemetry/trace/propagation/http_trace_context.h index 81d4c308ec..76b94284ef 100644 --- a/api/include/opentelemetry/trace/propagation/http_trace_context.h +++ b/api/include/opentelemetry/trace/propagation/http_trace_context.h @@ -80,7 +80,7 @@ class HttpTraceContext : public context::propagation::TextMapPropagator static TraceFlags TraceFlagsFromHex(nostd::string_view trace_flags) { - uint8_t flags; + uint8_t flags{0}; detail::HexToBinary(trace_flags, &flags, sizeof(flags)); return TraceFlags(flags); } @@ -140,7 +140,7 @@ class HttpTraceContext : public context::propagation::TextMapPropagator } // hex is valid, convert it to binary - uint8_t version_binary; + uint8_t version_binary{kInvalidVersion}; detail::HexToBinary(version_hex, &version_binary, sizeof(version_binary)); if (version_binary == kInvalidVersion) { diff --git a/api/include/opentelemetry/trace/propagation/jaeger.h b/api/include/opentelemetry/trace/propagation/jaeger.h index 45a9370919..ac843f97b6 100644 --- a/api/include/opentelemetry/trace/propagation/jaeger.h +++ b/api/include/opentelemetry/trace/propagation/jaeger.h @@ -112,7 +112,7 @@ class JaegerPropagator : public context::propagation::TextMapPropagator return SpanContext::GetInvalid(); } - uint8_t flags; + uint8_t flags{0}; if (!detail::HexToBinary(flags_hex, &flags, sizeof(flags))) { return SpanContext::GetInvalid(); diff --git a/api/include/opentelemetry/trace/trace_state.h b/api/include/opentelemetry/trace/trace_state.h index df7a0e0fe9..7ed83284cb 100644 --- a/api/include/opentelemetry/trace/trace_state.h +++ b/api/include/opentelemetry/trace/trace_state.h @@ -64,7 +64,7 @@ class OPENTELEMETRY_EXPORT TraceState } nostd::shared_ptr ts(new TraceState(cnt)); - bool kv_valid; + bool kv_valid{false}; nostd::string_view key, value; while (kv_str_tokenizer.next(kv_valid, key, value) && ts->kv_properties_->Size() < cnt) { diff --git a/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h b/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h index e4d25ec3e7..4cc8711323 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h @@ -68,7 +68,7 @@ class ViewRegistry if (aggregation_type == AggregationType::kDefault) { - bool is_monotonic; + bool is_monotonic{false}; aggregation_type = DefaultAggregation::GetDefaultAggregationType( instrument_selector->GetInstrumentType(), is_monotonic); } diff --git a/sdk/test/configuration/yaml_distribution_test.cc b/sdk/test/configuration/yaml_distribution_test.cc index 4b1e7ebf86..9ba73c43dc 100644 --- a/sdk/test/configuration/yaml_distribution_test.cc +++ b/sdk/test/configuration/yaml_distribution_test.cc @@ -67,7 +67,7 @@ file_format: "1.0-distribution" auto *distribution = config->distribution.get(); ASSERT_NE(distribution, nullptr); ASSERT_EQ(distribution->entries.size(), 2); - opentelemetry::sdk::configuration::DocumentNode *node; + opentelemetry::sdk::configuration::DocumentNode *node{nullptr}; std::unique_ptr property; std::string name;