From ed202b36b2a8e253fe89b3adae4c72506d0747e5 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 9 Jun 2025 19:54:42 -0700 Subject: [PATCH] Fix clang-tidy modernize-return-braced-init-list warnings in headers --- src/script_opt/ZAM/IterInfo.h | 2 +- src/spicy/port-range.h | 2 +- src/spicy/runtime-support.h | 8 ++++---- src/spicy/spicyz/config.h.in | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/script_opt/ZAM/IterInfo.h b/src/script_opt/ZAM/IterInfo.h index 69d6f45ac0..36b63c8c61 100644 --- a/src/script_opt/ZAM/IterInfo.h +++ b/src/script_opt/ZAM/IterInfo.h @@ -96,7 +96,7 @@ public: // For the current iteration, returns the corresponding value. ZVal IterValue() { auto tev = (*tbl_iter)->value; - return ZVal(tev->GetVal(), value_var_type); + return {tev->GetVal(), value_var_type}; } // Called upon finishing the iteration. diff --git a/src/spicy/port-range.h b/src/spicy/port-range.h index 7e71d433f8..914165159e 100644 --- a/src/spicy/port-range.h +++ b/src/spicy/port-range.h @@ -32,6 +32,6 @@ inline bool operator==(const PortRange& a, const PortRange& b) { inline bool operator!=(const PortRange& a, const PortRange& b) { return ! (a == b); } -inline PortRange make_port_range(hilti::rt::Port begin, hilti::rt::Port end) { return PortRange(begin, end); } +inline PortRange make_port_range(hilti::rt::Port begin, hilti::rt::Port end) { return {begin, end}; } } // namespace zeek::spicy::rt diff --git a/src/spicy/runtime-support.h b/src/spicy/runtime-support.h index 706cdfd866..fef0957824 100644 --- a/src/spicy/runtime-support.h +++ b/src/spicy/runtime-support.h @@ -549,7 +549,7 @@ inline ::hilti::rt::Address as_address(const ValPtr& v) { /** Converts a Zeek `bool` value to its Spicy equivalent. Throws on error. */ inline ::hilti::rt::Bool as_bool(const ValPtr& v) { detail::check_type(v, TYPE_BOOL, "bool"); - return ::hilti::rt::Bool(v->AsBool()); + return {v->AsBool()}; } /** Converts a Zeek `count` value to its Spicy equivalent. Throws on error. */ @@ -592,7 +592,7 @@ inline ::hilti::rt::Port as_port(const ValPtr& v) { auto p = v->AsPortVal(); // Wrap port number into safe integer to catch any overflows (Zeek returns // an uint32, while HILTI wants an uint16). - return ::hilti::rt::Port(hilti::rt::integer::safe(p->Port()), p->PortType()); + return {hilti::rt::integer::safe(p->Port()), p->PortType()}; } /** Converts a Zeek `record` value to its Spicy equivalent. Throws on error. */ @@ -615,14 +615,14 @@ inline ValSetPtr as_set(const ValPtr& v) { inline hilti::rt::Bytes as_string(const ValPtr& v) { detail::check_type(v, TYPE_STRING, "string"); auto str = v->AsString(); - return hilti::rt::Bytes(reinterpret_cast(str->Bytes()), str->Len()); + return {reinterpret_cast(str->Bytes()), static_cast(str->Len())}; } /** Converts a Zeek `subnet` value to its Spicy equivalent. Throws on error. */ inline ::hilti::rt::Network as_subnet(const ValPtr& v) { detail::check_type(v, TYPE_SUBNET, "subnet"); auto subnet = v->AsSubNet(); - return ::hilti::rt::Network(subnet.Prefix(), subnet.Length()); + return {subnet.Prefix(), subnet.Length()}; } /** Converts a Zeek `table` value to its Spicy equivalent. Throws on error. */ diff --git a/src/spicy/spicyz/config.h.in b/src/spicy/spicyz/config.h.in index 6737049809..1b6fb5847e 100644 --- a/src/spicy/spicyz/config.h.in +++ b/src/spicy/spicyz/config.h.in @@ -29,7 +29,7 @@ static inline void add_path(std::string& old_path, const path& new_path) { static path get_env_path_or(const char* name, const char* default_) { assert(std::strlen(default_) != 0); if ( auto p = hilti::rt::getenv(name); p && ! p->empty() ) - return path(*p); + return {*p}; else return default_; }