From: Otto Moerbeek Date: Mon, 10 Nov 2025 09:46:46 +0000 (+0100) Subject: Take @rgacogne's suggestion and provide ct for initializer list X-Git-Tag: rec-5.4.0-alpha1~105^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a59cc7f63383f7f3e4dc97d91ec7f985bc2a5a7;p=thirdparty%2Fpdns.git Take @rgacogne's suggestion and provide ct for initializer list Signed-off-by: Otto Moerbeek --- diff --git a/pdns/protozero-trace.hh b/pdns/protozero-trace.hh index 34c5c489ce..1b2fc2b9fe 100644 --- a/pdns/protozero-trace.hh +++ b/pdns/protozero-trace.hh @@ -229,11 +229,15 @@ struct InstrumentationScope static InstrumentationScope decode(protozero::pbf_reader& reader); }; -constexpr std::array s_emptyTraceID{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; struct TraceID : public std::array { TraceID() : - array{s_emptyTraceID} {}; + array{} {}; + TraceID(const std::initializer_list& arg) : + array{} + { + std::copy(arg.begin(), arg.end(), begin()); + } [[nodiscard]] std::string toLogString() const; friend std::ostream& operator<<(std::ostream& ostrm, const TraceID& val) @@ -244,7 +248,7 @@ struct TraceID : public std::array static TraceID getRandomTraceID() { TraceID ret; - dns_random(ret.data(), ret.size()); + ret.makeRandom(); return ret; } @@ -258,12 +262,17 @@ struct TraceID : public std::array this->fill(0); } }; +const TraceID s_emptyTraceID = {}; -constexpr std::array s_emptySpanID{0, 0, 0, 0, 0, 0, 0, 0}; struct SpanID : public std::array { SpanID() : - array{s_emptySpanID} {}; + array{} {}; + SpanID(const std::initializer_list& arg) : + array{} + { + std::copy(arg.begin(), arg.end(), begin()); + } [[nodiscard]] std::string toLogString() const; friend std::ostream& operator<<(std::ostream& ostrm, const SpanID& val) @@ -274,7 +283,7 @@ struct SpanID : public std::array static SpanID getRandomSpanID() { SpanID ret; - dns_random(ret.data(), ret.size()); + ret.makeRandom(); return ret; } @@ -288,6 +297,7 @@ struct SpanID : public std::array this->fill(0); } }; +const SpanID s_emptySpanID = {}; inline void fill(TraceID& trace, const std::string& data) {