From 3572e38ec29cea0d28d2032291bfe611a0dce1dc Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 3 Feb 2020 17:57:22 -0500 Subject: [PATCH] Mark a few clang-tidy findings as false-positive --- src/CompHash.cc | 4 ++++ src/RE.cc | 2 +- src/broker/Data.cc | 2 ++ src/zeekygen/Manager.cc | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/CompHash.cc b/src/CompHash.cc index 107eeefde8..ba640d50f8 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -918,6 +918,10 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, kp = RecoverOneVal(k, kp, k_end, rt->FieldType(i), v, optional); + + // An earlier call to reporter->InternalError would have called abort() and broken the + // call tree that clang-tidy is relying on to get the error described. + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch) if ( ! (v || optional) ) { reporter->InternalError("didn't recover expected number of fields from HashKey"); diff --git a/src/RE.cc b/src/RE.cc index 7ed075a0be..083356b5c4 100644 --- a/src/RE.cc +++ b/src/RE.cc @@ -436,7 +436,7 @@ unsigned int Specific_RE_Matcher::MemoryAllocation() const + equiv_class.Size() - padded_sizeof(EquivClass) + (dfa ? dfa->MemoryAllocation() : 0) // this is ref counted; consider the bytes here? + padded_sizeof(*any_ccl) - + padded_sizeof(*accepted) + + padded_sizeof(*accepted) // NOLINT(bugprone-sizeof-container) + accepted->size() * padded_sizeof(AcceptingSet::key_type); } diff --git a/src/broker/Data.cc b/src/broker/Data.cc index 0447ec882e..a659c1c938 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -1148,6 +1148,8 @@ broker::data& bro_broker::opaque_field_to_data(RecordVal* v, Frame* f) reporter->RuntimeError(f->GetCall()->GetLocationInfo(), "Broker::Data's opaque field is not set"); + // RuntimeError throws an exception which causes this line to never exceute. + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) return static_cast(d)->data; } diff --git a/src/zeekygen/Manager.cc b/src/zeekygen/Manager.cc index 8650238c74..3029d1640f 100644 --- a/src/zeekygen/Manager.cc +++ b/src/zeekygen/Manager.cc @@ -90,6 +90,8 @@ Manager::Manager(const string& arg_config, const string& bro_command) reporter->InternalError("Zeekygen can't get mtime of zeek binary %s (try again by specifying the absolute or relative path to Zeek): %s", path_to_bro.c_str(), strerror(errno)); + // Internal error will abort above in the case that stat isn't initialized + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) bro_mtime = s.st_mtime; }