Merge remote-tracking branch 'origin/topic/jsiwek/fix-coverity-build'

* origin/topic/jsiwek/fix-coverity-build:
  Remove inline from some static KeyedHash members
  Improve Func.h inclusion
This commit is contained in:
Jon Siwek 2020-06-08 11:22:45 -07:00
commit 02476453bc
17 changed files with 97 additions and 42 deletions

21
CHANGES
View file

@ -1,4 +1,25 @@
3.2.0-dev.749 | 2020-06-08 11:22:45 -0700
* Remove inline from some static KeyedHash members (Jon Siwek, Corelight)
Coverity Scan builds currently encounter catastrophic error, claiming
alignas requires use on both declaration and definition, so appears to
actually not understand "static inline" in combo with alignas.
* Improve Func.h inclusion (Jon Siwek, Corelight)
Now forward declares some Broker types since Broker/CAF headers
generally slow things down and also Coverity Scan currently has a
catastrophic error on some CAF headers.
Also a few other changes to EventHandler/BifReturnVal to reduce number
of places that depend on Func.h.
* Rename aux/ to auxil/ (Jon Siwek, Corelight)
Since "aux" is not an allowed file/dir name on Windows.
3.2.0-dev.744 | 2020-06-04 15:11:56 -0700 3.2.0-dev.744 | 2020-06-04 15:11:56 -0700
* Fix use-after-move of proc_status_file breaking -U flag (Jon Siwek, Corelight) * Fix use-after-move of proc_status_file breaking -U flag (Jon Siwek, Corelight)

View file

@ -1 +1 @@
3.2.0-dev.744 3.2.0-dev.749

11
src/BifReturnVal.cc Normal file
View file

@ -0,0 +1,11 @@
// See the file "COPYING" in the main distribution directory for copyright.
#include "BifReturnVal.h"
#include "Val.h"
BifReturnVal::BifReturnVal(std::nullptr_t) noexcept
{}
BifReturnVal::BifReturnVal(Val* v) noexcept
: rval(AdoptRef{}, v)
{}

28
src/BifReturnVal.h Normal file
View file

@ -0,0 +1,28 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "IntrusivePtr.h"
class Val;
/**
* A simple wrapper class to use for the return value of BIFs so that
* they may return either a Val* or IntrusivePtr<Val> (the former could
* potentially be deprecated).
*/
class BifReturnVal {
public:
template <typename T>
BifReturnVal(IntrusivePtr<T> v) noexcept
: rval(AdoptRef{}, v.release())
{ }
BifReturnVal(std::nullptr_t) noexcept;
[[deprecated("Remove in v4.1. Return an IntrusivePtr instead.")]]
BifReturnVal(Val* v) noexcept;
IntrusivePtr<Val> rval;
};

View file

@ -218,6 +218,7 @@ set(MAIN_SRCS
Anon.cc Anon.cc
Attr.cc Attr.cc
Base64.cc Base64.cc
BifReturnVal.cc
Brofiler.cc Brofiler.cc
BroString.cc BroString.cc
CCL.cc CCL.cc

View file

@ -2,6 +2,7 @@
#include "zeek-config.h" #include "zeek-config.h"
#include <cstring>
#include <vector> #include <vector>
#include <map> #include <map>

View file

@ -44,6 +44,12 @@ const IntrusivePtr<FuncType>& EventHandler::GetType(bool check_export)
return type; return type;
} }
void EventHandler::SetFunc(IntrusivePtr<Func> f)
{ local = std::move(f); }
void EventHandler::SetLocalHandler(Func* f)
{ SetFunc({NewRef{}, f}); }
void EventHandler::Call(zeek::Args* vl, bool no_remote) void EventHandler::Call(zeek::Args* vl, bool no_remote)
{ {
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS

View file

@ -5,11 +5,12 @@
#include "BroList.h" #include "BroList.h"
#include "ZeekArgs.h" #include "ZeekArgs.h"
#include "Type.h" #include "Type.h"
#include "Func.h"
#include <unordered_set> #include <unordered_set>
#include <string> #include <string>
class Func;
class EventHandler { class EventHandler {
public: public:
explicit EventHandler(std::string name); explicit EventHandler(std::string name);
@ -28,12 +29,10 @@ public:
FuncType* FType(bool check_export = true) FuncType* FType(bool check_export = true)
{ return GetType().get(); } { return GetType().get(); }
void SetFunc(IntrusivePtr<Func> f) void SetFunc(IntrusivePtr<Func> f);
{ local = std::move(f); }
[[deprecated("Remove in v4.1. Use SetFunc().")]] [[deprecated("Remove in v4.1. Use SetFunc().")]]
void SetLocalHandler(Func* f) void SetLocalHandler(Func* f);
{ SetFunc({NewRef{}, f}); }
void AutoPublish(std::string topic) void AutoPublish(std::string topic)
{ {

View file

@ -1,5 +1,6 @@
#include "EventRegistry.h" #include "EventRegistry.h"
#include "EventHandler.h" #include "EventHandler.h"
#include "Func.h"
#include "RE.h" #include "RE.h"
#include "Reporter.h" #include "Reporter.h"

View file

@ -892,10 +892,3 @@ function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusiveP
priority = (attrs ? get_func_priority(*attrs) : 0); priority = (attrs ? get_func_priority(*attrs) : 0);
this->body = std::move(body); this->body = std::move(body);
} }
BifReturnVal::BifReturnVal(std::nullptr_t) noexcept
{ }
BifReturnVal::BifReturnVal(Val* v) noexcept
: rval(AdoptRef{}, v)
{ }

View file

@ -9,15 +9,13 @@
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <broker/data.hh>
#include <broker/expected.hh>
#include "BroList.h" #include "BroList.h"
#include "Obj.h" #include "Obj.h"
#include "IntrusivePtr.h" #include "IntrusivePtr.h"
#include "Type.h" /* for function_flavor */ #include "Type.h" /* for function_flavor */
#include "TraverseTypes.h" #include "TraverseTypes.h"
#include "ZeekArgs.h" #include "ZeekArgs.h"
#include "BifReturnVal.h"
class Val; class Val;
class ListExpr; class ListExpr;
@ -28,6 +26,16 @@ class ID;
class CallExpr; class CallExpr;
class Scope; class Scope;
namespace caf {
template <class> class expected;
}
namespace broker {
class data;
using vector = std::vector<data>;
using caf::expected;
}
class Func : public BroObj { class Func : public BroObj {
public: public:
static inline const IntrusivePtr<Func> nil; static inline const IntrusivePtr<Func> nil;
@ -205,27 +213,6 @@ private:
bool weak_closure_ref = false; bool weak_closure_ref = false;
}; };
/**
* A simple wrapper class to use for the return value of BIFs so that
* they may return either a Val* or IntrusivePtr<Val> (the former could
* potentially be deprecated).
*/
class BifReturnVal {
public:
template <typename T>
BifReturnVal(IntrusivePtr<T> v) noexcept
: rval(AdoptRef{}, v.release())
{ }
BifReturnVal(std::nullptr_t) noexcept;
[[deprecated("Remove in v4.1. Return an IntrusivePtr instead.")]]
BifReturnVal(Val* v) noexcept;
IntrusivePtr<Val> rval;
};
using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args); using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args);
class BuiltinFunc final : public Func { class BuiltinFunc final : public Func {

View file

@ -13,6 +13,10 @@
#include "highwayhash/highwayhash_target.h" #include "highwayhash/highwayhash_target.h"
#include "highwayhash/instruction_sets.h" #include "highwayhash/instruction_sets.h"
alignas(32) uint64_t KeyedHash::shared_highwayhash_key[4];
alignas(32) uint64_t KeyedHash::cluster_highwayhash_key[4];
alignas(16) unsigned long long KeyedHash::shared_siphash_key[2];
// we use the following lines to not pull in the highwayhash headers in Hash.h - but to check the types did not change underneath us. // we use the following lines to not pull in the highwayhash headers in Hash.h - but to check the types did not change underneath us.
static_assert(std::is_same<hash64_t, highwayhash::HHResult64>::value, "Highwayhash return values must match hash_x_t"); static_assert(std::is_same<hash64_t, highwayhash::HHResult64>::value, "Highwayhash return values must match hash_x_t");
static_assert(std::is_same<hash128_t, highwayhash::HHResult128>::value, "Highwayhash return values must match hash_x_t"); static_assert(std::is_same<hash128_t, highwayhash::HHResult128>::value, "Highwayhash return values must match hash_x_t");

View file

@ -186,11 +186,11 @@ public:
private: private:
// actually HHKey. This key changes each start (unless a seed is specified) // actually HHKey. This key changes each start (unless a seed is specified)
alignas(32) inline static uint64_t shared_highwayhash_key[4]; alignas(32) static uint64_t shared_highwayhash_key[4];
// actually HHKey. This key is installation specific and sourced from the digest_salt script-level const. // actually HHKey. This key is installation specific and sourced from the digest_salt script-level const.
alignas(32) inline static uint64_t cluster_highwayhash_key[4]; alignas(32) static uint64_t cluster_highwayhash_key[4];
// actually HH_U64, which has the same type. This key changes each start (unless a seed is specified) // actually HH_U64, which has the same type. This key changes each start (unless a seed is specified)
alignas(16) inline static unsigned long long shared_siphash_key[2]; alignas(16) static unsigned long long shared_siphash_key[2];
// This key changes each start (unless a seed is specified) // This key changes each start (unless a seed is specified)
inline static uint8_t shared_hmac_md5_key[16]; inline static uint8_t shared_hmac_md5_key[16];
inline static bool seeds_initialized = false; inline static bool seeds_initialized = false;

View file

@ -7,3 +7,4 @@
#include "Reporter.h" #include "Reporter.h"
#include "ID.h" #include "ID.h"
#include "EventRegistry.h" #include "EventRegistry.h"
#include "BifReturnVal.h"

View file

@ -12,6 +12,8 @@
#include "file_analysis/Manager.h" #include "file_analysis/Manager.h"
#include <broker/error.hh> #include <broker/error.hh>
#include <broker/expected.hh>
#include <broker/data.hh>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>

View file

@ -1 +1 @@
d242bb7e8a231f01fa2af5027e938bbd4fe6ecba 807dce8fd94d59e571994c033e333691f7ef27ba

View file

@ -1 +1 @@
b77a24eb48231f0ca34ca06465e22a4e5053d8a2 fa5c4dc4ea3481c7b273f0cfcc77497c0d32aa7c