]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix autotools build and avoid a few g++ warnings by initing all members explicitly
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 12 Jun 2025 13:42:41 +0000 (15:42 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 13 Jun 2025 08:50:50 +0000 (10:50 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/Makefile.am
pdns/protozero-trace.hh
pdns/recursordist/Makefile.am
pdns/recursordist/rec-eventtrace.cc
pdns/recursordist/rec-eventtrace.hh

index 8d3cdf78187759deecb385db6deb904565f53ab5..7c1945db2bc9418d3058c906649323e7ad8d7a2c 100644 (file)
@@ -547,6 +547,7 @@ sdig_SOURCES = \
        logger.cc \
        misc.cc misc.hh \
        nsecrecords.cc \
+       protozero-trace.hh \
        proxy-protocol.cc proxy-protocol.hh \
        qtype.cc \
        rcpgenerator.cc rcpgenerator.hh \
index 632879fd9929b505a7e0a7b86e60a8aeed264b12..42b06c30c1851e07bb30cc06d161d1873709de7d 100644 (file)
@@ -137,7 +137,7 @@ T decode(protozero::pbf_reader& reader)
 
 struct ArrayValue
 {
-  std::vector<AnyValue> values; // = 1
+  std::vector<AnyValue> values{}; // = 1
 
   void encode(protozero::pbf_writer& writer) const
   {
@@ -154,7 +154,7 @@ struct ArrayValue
 
 struct KeyValueList
 {
-  std::vector<KeyValue> values; // = 1
+  std::vector<KeyValue> values{}; // = 1
 
   void encode(protozero::pbf_writer& writer) const
   {
@@ -177,10 +177,10 @@ struct AnyValue : public std::variant<char, std::string, bool, int64_t, double,
 
 struct EntityRef
 {
-  std::string schema_url; // == 1
-  std::string type; // == 2
-  std::vector<std::string> id_keys; // == 3
-  std::vector<std::string> description_keys; // == 4
+  std::string schema_url{}; // == 1
+  std::string type{}; // == 2
+  std::vector<std::string> id_keys{}; // == 3
+  std::vector<std::string> description_keys{}; // == 4
 
   void encode(protozero::pbf_writer& writer) const;
   static EntityRef decode(protozero::pbf_reader& reader);
@@ -188,8 +188,8 @@ struct EntityRef
 
 struct KeyValue
 {
-  std::string key; // = 1
-  AnyValue value; // = 2
+  std::string key{}; // = 1
+  AnyValue value{}; // = 2
   void encode(protozero::pbf_writer& writer) const;
   static KeyValue decode(protozero::pbf_reader& reader);
 
@@ -201,9 +201,9 @@ struct KeyValue
 
 struct Resource
 {
-  std::vector<KeyValue> attributes; // = 1
+  std::vector<KeyValue> attributes{}; // = 1
   uint32_t dropped_attributes_count{0}; // = 2;
-  std::vector<EntityRef> entity_refs; // = 3
+  std::vector<EntityRef> entity_refs{}; // = 3
 
   void encode(protozero::pbf_writer& writer) const;
   static Resource decode(protozero::pbf_reader& reader);
@@ -211,9 +211,9 @@ struct Resource
 
 struct InstrumentationScope
 {
-  std::string name; // = 1
-  std::string version; // = 2
-  std::vector<KeyValue> attributes; // = 3
+  std::string name{}; // = 1
+  std::string version{}; // = 2
+  std::vector<KeyValue> attributes{}; // = 3
   uint32_t dropped_attributes_count{0}; // = 4
 
   void encode(protozero::pbf_writer& writer) const;
@@ -300,7 +300,7 @@ inline SpanID decodeSpanID(protozero::pbf_reader& reader)
 struct Status
 {
   // A developer-facing human readable error message.
-  std::string message; // = 2;
+  std::string message{}; // = 2;
 
   // For the semantics of status codes see
   // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
@@ -342,21 +342,21 @@ struct Span
   // is zero-length and thus is also invalid).
   //
   // This field is required.
-  TraceID trace_id; // = 1
+  TraceID trace_id{}; // = 1
   // A unique identifier for a span within a trace, assigned when the span
   // is created. The ID is an 8-byte array. An ID with all zeroes OR of length
   // other than 8 bytes is considered invalid (empty string in OTLP/JSON
   // is zero-length and thus is also invalid).
   //
   // This field is required.
-  SpanID span_id; // = 2
+  SpanID span_id{}; // = 2
   // trace_state conveys information about request position in multiple distributed tracing graphs.
   // It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
   // See also https://github.com/w3c/distributed-tracing for more details about this field.
-  std::string trace_state; // = 3
+  std::string trace_state{}; // = 3
   // The `span_id` of this span's parent span. If this is a root span, then this
   // field must be empty. The ID is an 8-byte array.
-  SpanID parent_span_id; // = 4
+  SpanID parent_span_id{}; // = 4
   // A description of the span's operation.
   //
   // For example, the name can be a qualified method name or a file name
@@ -368,7 +368,7 @@ struct Span
   // Empty value is equivalent to an unknown span name.
   //
   // This field is required.
-  std::string name; // = 5
+  std::string name{}; // = 5
 
   // SpanKind is the type of span. Can be used to specify additional relationships between spans
   // in addition to a parent/child relationship.
@@ -425,7 +425,7 @@ struct Span
   // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
   // Attribute keys MUST be unique (it is not allowed to have more than one
   // attribute with the same key).
-  std::vector<KeyValue> attributes; // = 9
+  std::vector<KeyValue> attributes{}; // = 9
   // dropped_attributes_count is the number of attributes that were discarded. Attributes
   // can be discarded because their keys are too long or because there are too many
   // attributes. If this value is 0, then no attributes were dropped.
@@ -452,7 +452,7 @@ struct Span
     static Event decode(protozero::pbf_reader& reader);
   };
   // events is a collection of Event items.
-  std::vector<Event> events; // = 11
+  std::vector<Event> events{}; // = 11
   // dropped_events_count is the number of dropped events. If the value is 0, then no
   // events were dropped.
   uint32_t dropped_events_count{0}; // = 12
@@ -499,9 +499,9 @@ struct Span
     void encode(protozero::pbf_writer& writer) const;
     static Link decode(protozero::pbf_reader& reader);
   };
-  std::vector<Link> links; // = 13
+  std::vector<Link> links{}; // = 13
   uint32_t dropped_links_count{0}; // = 14
-  Status status; // = 15
+  Status status{}; // = 15
 
   // Flags, a bit field.
   //
@@ -589,15 +589,15 @@ struct ScopeSpans
   // The instrumentation scope information for the spans in this message.
   // Semantically when InstrumentationScope isn't set, it is equivalent with
   // an empty instrumentation scope name (unknown).
-  InstrumentationScope scope; // = 1
+  InstrumentationScope scope{}; // = 1
   // A list of Spans that originate from an instrumentation scope.
-  std::vector<Span> spans; // = 2
+  std::vector<Span> spans{}; // = 2
   // The Schema URL, if known. This is the identifier of the Schema that the span data
   // is recorded in. Notably, the last part of the URL path is the version number of the
   // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
   // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
   // This schema_url applies to all spans and span events in the "spans" field.
-  std::string schema_url; // = 3
+  std::string schema_url{}; // = 3
 
   void close()
   {
@@ -623,7 +623,7 @@ struct ResourceSpans
   // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
   // This schema_url applies to the data in the "resource" field. It does not apply
   // to the data in the "scope_spans" field which have their own schema_url field.
-  std::string schema_url; // = 3
+  std::string schema_url{}; // = 3
 
   void close()
   {
@@ -673,7 +673,7 @@ struct TracesData
 
   static TracesData boilerPlate(std::string&& service, std::string&& req, std::vector<Span>&& spans)
   {
-    spans.at(0).attributes.push_back({"value", {req}});
+    spans.at(0).attributes.push_back({"value", {std::move(req)}});
     return TracesData{
       .resource_spans = {pdns::trace::ResourceSpans{.resource = {.attributes = {{"service.name", {{std::move(service)}}}}}, .scope_spans = {{.spans = std::move(spans)}}}}};
   }
index e2c2ed1f2d52559e824bb1d823fb005fe38b0870..aa579d6a30b839837ccdf6cf2d3ef9c8de206850 100644 (file)
@@ -175,6 +175,7 @@ pdns_recursor_SOURCES = \
        pdns_recursor.cc \
        pdnsexception.hh \
        pollmplexer.cc \
+       protozero-trace.cc protozero-trace.hh \
        protozero.cc protozero.hh \
        proxy-protocol.cc proxy-protocol.hh \
        pubsuffix.hh pubsuffix.cc \
index 7b5797bfbb5373780768d45aababe2146ee8b3bc..779bb626ee241babc25818e910bb92c98d5ea3fe 100644 (file)
@@ -90,8 +90,8 @@ std::vector<pdns::trace::Span> RecEventTrace::convertToOT(const Span& span) cons
     if (event.d_start) {
       // It's an open event
       Span work{
-        .name = RecEventTrace::toString(event.d_event),
         .trace_id = span.trace_id,
+        .name = RecEventTrace::toString(event.d_event),
         .start_time_unix_nano = static_cast<uint64_t>(event.d_ts + diff),
         .end_time_unix_nano = static_cast<uint64_t>(event.d_ts + diff), // will be updated when we process the close event
       };
index e0451795c00f5740725f97ad0c299780cb21f99b..dcea195d3846f25562f9d645b7db8467d779ff5d 100644 (file)
@@ -310,8 +310,8 @@ public:
   private:
     RecEventTrace& d_eventTrace;
     size_t d_oldParent;
-    size_t d_match;
-    EventType d_event;
+    size_t d_match{0};
+    EventType d_event{EventType::CustomEvent};
     bool d_closed{false};
   };