mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix clang-tidy modernize-return-braced-init-list findings
This commit is contained in:
parent
8c3eee7a87
commit
17c14a3ce1
9 changed files with 26 additions and 29 deletions
|
@ -7,6 +7,7 @@ Checks: [-*,
|
|||
modernize-min-max-use-initializer-list,
|
||||
modernize-pass-by-value,
|
||||
modernize-redundant-void-arg,
|
||||
modernize-return-braced-init-list,
|
||||
|
||||
# Enable a very limited number of the cppcoreguidelines checkers.
|
||||
# See the notes for some of the rest of them below.
|
||||
|
|
|
@ -19,8 +19,8 @@ prefix_t* PrefixTable::MakePrefix(const IPAddr& addr, int width) {
|
|||
}
|
||||
|
||||
IPPrefix PrefixTable::PrefixToIPPrefix(prefix_t* prefix) {
|
||||
return IPPrefix(IPAddr(IPv6, reinterpret_cast<const uint32_t*>(&prefix->add.sin6), IPAddr::Network), prefix->bitlen,
|
||||
true);
|
||||
return {IPAddr(IPv6, reinterpret_cast<const uint32_t*>(&prefix->add.sin6), IPAddr::Network),
|
||||
static_cast<uint8_t>(prefix->bitlen), true};
|
||||
}
|
||||
|
||||
void* PrefixTable::Insert(const IPAddr& addr, int width, void* data) {
|
||||
|
|
10
src/Type.cc
10
src/Type.cc
|
@ -902,7 +902,7 @@ public:
|
|||
auto v = init_expr->Eval(nullptr);
|
||||
if ( ! v ) {
|
||||
reporter->Error("failed &default in record creation");
|
||||
return ZVal();
|
||||
return {};
|
||||
}
|
||||
|
||||
if ( coerce_type )
|
||||
|
@ -911,7 +911,7 @@ public:
|
|||
else if ( init_type->Tag() == TYPE_VECTOR )
|
||||
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; }
|
||||
|
@ -930,7 +930,7 @@ class RecordFieldInit final : public FieldInit {
|
|||
public:
|
||||
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 {
|
||||
assert(! run_state::is_parsing);
|
||||
|
@ -948,7 +948,7 @@ public:
|
|||
TableFieldInit(TableTypePtr _init_type, detail::AttributesPtr _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:
|
||||
TableTypePtr init_type;
|
||||
|
@ -961,7 +961,7 @@ class VectorFieldInit final : public FieldInit {
|
|||
public:
|
||||
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:
|
||||
VectorTypePtr init_type;
|
||||
|
|
|
@ -22,6 +22,6 @@ void Plugin::InitPreScript() {}
|
|||
|
||||
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
|
||||
|
|
|
@ -350,7 +350,7 @@ bool BitVector::operator[](size_type i) const {
|
|||
|
||||
BitVector::Reference BitVector::operator[](size_type i) {
|
||||
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 {
|
||||
|
|
|
@ -141,7 +141,7 @@ string CPPCompile::GenExpr(const Expr* e, GenType gt, bool top_level) {
|
|||
default:
|
||||
// Intended to catch errors in overlooking the possible
|
||||
// expressions that might appear.
|
||||
return string("EXPR");
|
||||
return "EXPR";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ string CPPCompile::GenVal(const ValPtr& v) {
|
|||
auto it = t->InternalType();
|
||||
|
||||
if ( tag == TYPE_BOOL )
|
||||
return string(v->IsZero() ? "false" : "true");
|
||||
return v->IsZero() ? "false" : "true";
|
||||
|
||||
if ( tag == TYPE_ENUM )
|
||||
return GenEnum(t, v);
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
int nv2 = FrameSlot(v2);
|
||||
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) {
|
||||
int nv2 = FrameSlot(v2);
|
||||
int nv3 = FrameSlot(v3);
|
||||
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) {
|
||||
return ZInstI(op, Frame1Slot(v1, op), ce);
|
||||
}
|
||||
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* ce) { return {op, Frame1Slot(v1, op), ce}; }
|
||||
|
||||
ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* ce, const NameExpr* v1) {
|
||||
return ZInstI(op, Frame1Slot(v1, op), ce);
|
||||
}
|
||||
ZInstI ZAMCompiler::GenInst(ZOp op, const ConstExpr* ce, const NameExpr* v1) { return {op, Frame1Slot(v1, op), ce}; }
|
||||
|
||||
ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const ConstExpr* ce, const NameExpr* 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) {
|
||||
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) {
|
||||
int nv2 = FrameSlot(v2);
|
||||
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) {
|
||||
|
@ -71,7 +67,7 @@ ZInstI ZAMCompiler::GenInst(ZOp op, const NameExpr* v1, const NameExpr* v2, cons
|
|||
// us from needing to implement a redundant constructor.
|
||||
int nv2 = FrameSlot(v2);
|
||||
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) {
|
||||
|
|
|
@ -861,7 +861,7 @@ void Manager::searchModules(const std::string& paths) {
|
|||
|
||||
detail::Location Manager::makeLocation(const std::string& 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() {
|
||||
|
|
|
@ -1170,7 +1170,7 @@ std::optional<SupervisorStemHandle> Supervisor::CreateStem(bool supervisor_mode)
|
|||
sh.pid = pid;
|
||||
sh.stdout_pipe = std::move(fork_res.stdout_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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue