Fix clang-tidy modernize-return-braced-init-list warnings in headers

This commit is contained in:
Tim Wojtulewicz 2025-06-09 19:54:42 -07:00
parent 157c488b9d
commit ed202b36b2
4 changed files with 7 additions and 7 deletions

View file

@ -96,7 +96,7 @@ public:
// For the current iteration, returns the corresponding value. // For the current iteration, returns the corresponding value.
ZVal IterValue() { ZVal IterValue() {
auto tev = (*tbl_iter)->value; auto tev = (*tbl_iter)->value;
return ZVal(tev->GetVal(), value_var_type); return {tev->GetVal(), value_var_type};
} }
// Called upon finishing the iteration. // Called upon finishing the iteration.

View file

@ -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 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 } // namespace zeek::spicy::rt

View file

@ -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. */ /** Converts a Zeek `bool` value to its Spicy equivalent. Throws on error. */
inline ::hilti::rt::Bool as_bool(const ValPtr& v) { inline ::hilti::rt::Bool as_bool(const ValPtr& v) {
detail::check_type(v, TYPE_BOOL, "bool"); 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. */ /** 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(); auto p = v->AsPortVal();
// Wrap port number into safe integer to catch any overflows (Zeek returns // Wrap port number into safe integer to catch any overflows (Zeek returns
// an uint32, while HILTI wants an uint16). // an uint32, while HILTI wants an uint16).
return ::hilti::rt::Port(hilti::rt::integer::safe<uint16_t>(p->Port()), p->PortType()); return {hilti::rt::integer::safe<uint16_t>(p->Port()), p->PortType()};
} }
/** Converts a Zeek `record` value to its Spicy equivalent. Throws on error. */ /** 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) { inline hilti::rt::Bytes as_string(const ValPtr& v) {
detail::check_type(v, TYPE_STRING, "string"); detail::check_type(v, TYPE_STRING, "string");
auto str = v->AsString(); auto str = v->AsString();
return hilti::rt::Bytes(reinterpret_cast<const char*>(str->Bytes()), str->Len()); return {reinterpret_cast<const char*>(str->Bytes()), static_cast<size_t>(str->Len())};
} }
/** Converts a Zeek `subnet` value to its Spicy equivalent. Throws on error. */ /** Converts a Zeek `subnet` value to its Spicy equivalent. Throws on error. */
inline ::hilti::rt::Network as_subnet(const ValPtr& v) { inline ::hilti::rt::Network as_subnet(const ValPtr& v) {
detail::check_type(v, TYPE_SUBNET, "subnet"); detail::check_type(v, TYPE_SUBNET, "subnet");
auto subnet = v->AsSubNet(); 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. */ /** Converts a Zeek `table` value to its Spicy equivalent. Throws on error. */

View file

@ -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_) { static path get_env_path_or(const char* name, const char* default_) {
assert(std::strlen(default_) != 0); assert(std::strlen(default_) != 0);
if ( auto p = hilti::rt::getenv(name); p && ! p->empty() ) if ( auto p = hilti::rt::getenv(name); p && ! p->empty() )
return path(*p); return {*p};
else else
return default_; return default_;
} }