Fix clang-tidy modernize-return-braced-init-list findings

This commit is contained in:
Tim Wojtulewicz 2025-05-15 09:52:10 -07:00
parent 8c3eee7a87
commit 17c14a3ce1
9 changed files with 26 additions and 29 deletions

View file

@ -7,6 +7,7 @@ Checks: [-*,
modernize-min-max-use-initializer-list, modernize-min-max-use-initializer-list,
modernize-pass-by-value, modernize-pass-by-value,
modernize-redundant-void-arg, modernize-redundant-void-arg,
modernize-return-braced-init-list,
# Enable a very limited number of the cppcoreguidelines checkers. # Enable a very limited number of the cppcoreguidelines checkers.
# See the notes for some of the rest of them below. # See the notes for some of the rest of them below.

View file

@ -19,8 +19,8 @@ prefix_t* PrefixTable::MakePrefix(const IPAddr& addr, int width) {
} }
IPPrefix PrefixTable::PrefixToIPPrefix(prefix_t* prefix) { IPPrefix PrefixTable::PrefixToIPPrefix(prefix_t* prefix) {
return IPPrefix(IPAddr(IPv6, reinterpret_cast<const uint32_t*>(&prefix->add.sin6), IPAddr::Network), prefix->bitlen, return {IPAddr(IPv6, reinterpret_cast<const uint32_t*>(&prefix->add.sin6), IPAddr::Network),
true); static_cast<uint8_t>(prefix->bitlen), true};
} }
void* PrefixTable::Insert(const IPAddr& addr, int width, void* data) { void* PrefixTable::Insert(const IPAddr& addr, int width, void* data) {

View file

@ -902,7 +902,7 @@ public:
auto v = init_expr->Eval(nullptr); auto v = init_expr->Eval(nullptr);
if ( ! v ) { if ( ! v ) {
reporter->Error("failed &default in record creation"); reporter->Error("failed &default in record creation");
return ZVal(); return {};
} }
if ( coerce_type ) if ( coerce_type )
@ -911,7 +911,7 @@ public:
else if ( init_type->Tag() == TYPE_VECTOR ) else if ( init_type->Tag() == TYPE_VECTOR )
concretize_if_unspecified(cast_intrusive<VectorVal>(v), init_type->Yield()); concretize_if_unspecified(cast_intrusive<VectorVal>(v), init_type->Yield());
return ZVal(v, init_type); return {v, init_type};
} }
bool IsDeferrable() const override { return false; } bool IsDeferrable() const override { return false; }
@ -930,7 +930,7 @@ class RecordFieldInit final : public FieldInit {
public: public:
RecordFieldInit(RecordTypePtr _init_type) : init_type(std::move(_init_type)) {} RecordFieldInit(RecordTypePtr _init_type) : init_type(std::move(_init_type)) {}
ZVal Generate() const override { return ZVal(new RecordVal(init_type)); } ZVal Generate() const override { return {new RecordVal(init_type)}; }
bool IsDeferrable() const override { bool IsDeferrable() const override {
assert(! run_state::is_parsing); assert(! run_state::is_parsing);
@ -948,7 +948,7 @@ public:
TableFieldInit(TableTypePtr _init_type, detail::AttributesPtr _attrs) TableFieldInit(TableTypePtr _init_type, detail::AttributesPtr _attrs)
: init_type(std::move(_init_type)), attrs(std::move(_attrs)) {} : init_type(std::move(_init_type)), attrs(std::move(_attrs)) {}
ZVal Generate() const override { return ZVal(new TableVal(init_type, attrs)); } ZVal Generate() const override { return {new TableVal(init_type, attrs)}; }
private: private:
TableTypePtr init_type; TableTypePtr init_type;
@ -961,7 +961,7 @@ class VectorFieldInit final : public FieldInit {
public: public:
VectorFieldInit(VectorTypePtr _init_type) : init_type(std::move(_init_type)) {} VectorFieldInit(VectorTypePtr _init_type) : init_type(std::move(_init_type)) {}
ZVal Generate() const override { return ZVal(new VectorVal(init_type)); } ZVal Generate() const override { return {new VectorVal(init_type)}; }
private: private:
VectorTypePtr init_type; VectorTypePtr init_type;

View file

@ -22,6 +22,6 @@ void Plugin::InitPreScript() {}
void Plugin::Done() {} void Plugin::Done() {}
std::unique_lock<std::mutex> Plugin::ForkMutex() { return std::unique_lock<std::mutex>(fork_mutex, std::defer_lock); } std::unique_lock<std::mutex> Plugin::ForkMutex() { return {fork_mutex, std::defer_lock}; }
} // namespace zeek::plugin::detail::Zeek_RawReader } // namespace zeek::plugin::detail::Zeek_RawReader

View file

@ -350,7 +350,7 @@ bool BitVector::operator[](size_type i) const {
BitVector::Reference BitVector::operator[](size_type i) { BitVector::Reference BitVector::operator[](size_type i) {
assert(i < num_bits); assert(i < num_bits);
return Reference(bits[block_index(i)], bit_index(i)); return {bits[block_index(i)], bit_index(i)};
} }
BitVector::size_type BitVector::Count() const { BitVector::size_type BitVector::Count() const {

View file

@ -141,7 +141,7 @@ string CPPCompile::GenExpr(const Expr* e, GenType gt, bool top_level) {
default: default:
// Intended to catch errors in overlooking the possible // Intended to catch errors in overlooking the possible
// expressions that might appear. // expressions that might appear.
return string("EXPR"); return "EXPR";
} }
} }
@ -825,7 +825,7 @@ string CPPCompile::GenVal(const ValPtr& v) {
auto it = t->InternalType(); auto it = t->InternalType();
if ( tag == TYPE_BOOL ) if ( tag == TYPE_BOOL )
return string(v->IsZero() ? "false" : "true"); return v->IsZero() ? "false" : "true";
if ( tag == TYPE_ENUM ) if ( tag == TYPE_ENUM )
return GenEnum(t, v); return GenEnum(t, v);

View file

@ -6,9 +6,9 @@
namespace zeek::detail { namespace zeek::detail {
ZInstI ZAMCompiler::GenInst(ZOp op) { return ZInstI(op); } ZInstI ZAMCompiler::GenInst(ZOp op) { return {op}; }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1) { return ZInstI(op, Frame1Slot(v1, op)); } ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1) { return {op, Frame1Slot(v1, op)}; }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, int i) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, int i) {
auto z = ZInstI(op, Frame1Slot(v1, op), i); auto z = ZInstI(op, Frame1Slot(v1, op), i);
@ -24,46 +24,42 @@ ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* c, const NameExpr* v1, int
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2) {
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
return ZInstI(op, Frame1Slot(v1, op), nv2); return {op, Frame1Slot(v1, op), nv2};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const NameExpr* v3) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const NameExpr* v3) {
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
int nv3 = FrameSlot(v3); int nv3 = FrameSlot(v3);
return ZInstI(op, Frame1Slot(v1, op), nv2, nv3); return {op, Frame1Slot(v1, op), nv2, nv3};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const NameExpr* v3, const NameExpr* v4) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const NameExpr* v3, const NameExpr* v4) {
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
int nv3 = FrameSlot(v3); int nv3 = FrameSlot(v3);
int nv4 = FrameSlot(v4); int nv4 = FrameSlot(v4);
return ZInstI(op, Frame1Slot(v1, op), nv2, nv3, nv4); return {op, Frame1Slot(v1, op), nv2, nv3, nv4};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* ce) { return ZInstI(op, ce); } ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* ce) { return {op, ce}; }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* ce) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* ce) { return {op, Frame1Slot(v1, op), ce}; }
return ZInstI(op, Frame1Slot(v1, op), ce);
}
ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* ce, const NameExpr* v1) { ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* ce, const NameExpr* v1) { return {op, Frame1Slot(v1, op), ce}; }
return ZInstI(op, Frame1Slot(v1, op), ce);
}
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* ce, const NameExpr* v2) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* ce, const NameExpr* v2) {
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
return ZInstI(op, Frame1Slot(v1, op), nv2, ce); return {op, Frame1Slot(v1, op), nv2, ce};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const ConstExpr* ce) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const ConstExpr* ce) {
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
return ZInstI(op, Frame1Slot(v1, op), nv2, ce); return {op, Frame1Slot(v1, op), nv2, ce};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const NameExpr* v3, const ConstExpr* ce) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const NameExpr* v3, const ConstExpr* ce) {
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
int nv3 = FrameSlot(v3); int nv3 = FrameSlot(v3);
return ZInstI(op, Frame1Slot(v1, op), nv2, nv3, ce); return {op, Frame1Slot(v1, op), nv2, nv3, ce};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const ConstExpr* ce, const NameExpr* v3) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, const ConstExpr* ce, const NameExpr* v3) {
@ -71,7 +67,7 @@ ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, cons
// us from needing to implement a redundant constructor. // us from needing to implement a redundant constructor.
int nv2 = FrameSlot(v2); int nv2 = FrameSlot(v2);
int nv3 = FrameSlot(v3); int nv3 = FrameSlot(v3);
return ZInstI(op, Frame1Slot(v1, op), nv2, nv3, ce); return {op, Frame1Slot(v1, op), nv2, nv3, ce};
} }
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* c, int i) { ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* c, int i) {

View file

@ -861,7 +861,7 @@ void Manager::searchModules(const std::string& paths) {
detail::Location Manager::makeLocation(const std::string& fname) { detail::Location Manager::makeLocation(const std::string& fname) {
auto x = _locations.insert(fname); auto x = _locations.insert(fname);
return detail::Location(x.first->c_str(), 0, 0, 0, 0); return {x.first->c_str(), 0, 0, 0, 0};
} }
void Manager::autoDiscoverModules() { void Manager::autoDiscoverModules() {

View file

@ -1170,7 +1170,7 @@ std::optional<SupervisorStemHandle> Supervisor::CreateStem(bool supervisor_mode)
sh.pid = pid; sh.pid = pid;
sh.stdout_pipe = std::move(fork_res.stdout_pipe); sh.stdout_pipe = std::move(fork_res.stdout_pipe);
sh.stderr_pipe = std::move(fork_res.stderr_pipe); sh.stderr_pipe = std::move(fork_res.stderr_pipe);
return std::optional<SupervisorStemHandle>(std::move(sh)); return {std::move(sh)};
} }
static BifEnum::Supervisor::ClusterRole role_str_to_enum(std::string_view r) { static BifEnum::Supervisor::ClusterRole role_str_to_enum(std::string_view r) {