diff --git a/src/EventHandler.h b/src/EventHandler.h index 2acd2569a6..6006f2e48e 100644 --- a/src/EventHandler.h +++ b/src/EventHandler.h @@ -102,7 +102,7 @@ public: EventHandler* Ptr() { return handler; } - operator bool() const { return handler && *handler; } + explicit operator bool() const { return handler && *handler; } EventHandler* operator->() { return handler; } const EventHandler* operator->() const { return handler; } diff --git a/src/UID.h b/src/UID.h index 2cda02811f..3a32b843f0 100644 --- a/src/UID.h +++ b/src/UID.h @@ -61,7 +61,7 @@ public: * and not yet initialized w/ Set(). * TODO: this would be better as an "explicit" conversion operator (C++11) */ - operator bool() const + explicit operator bool() const { return initialized; } /** diff --git a/src/analyzer/Tag.h b/src/analyzer/Tag.h index 9ba04b2ef8..35dc3b2ac5 100644 --- a/src/analyzer/Tag.h +++ b/src/analyzer/Tag.h @@ -46,7 +46,7 @@ public: * "safe bool" idiom (not necessary if "explicit" is available), * otherwise this may allow nonsense/undesired comparison operations. */ - operator bool() const { return *this != Tag(); } + explicit operator bool() const { return *this != Tag(); } /** * Assignment operator. diff --git a/src/analyzer/protocol/sip/sip-analyzer.pac b/src/analyzer/protocol/sip/sip-analyzer.pac index 829904aa3a..3174e6a977 100644 --- a/src/analyzer/protocol/sip/sip-analyzer.pac +++ b/src/analyzer/protocol/sip/sip-analyzer.pac @@ -8,7 +8,7 @@ refine flow SIP_Flow += { %init{ content_length = 0; - build_headers = (sip_all_headers != 0); + build_headers = bool(sip_all_headers); %} function get_content_length(): int diff --git a/src/file_analysis/Manager.cc b/src/file_analysis/Manager.cc index 41528e2ceb..177f5446dd 100644 --- a/src/file_analysis/Manager.cc +++ b/src/file_analysis/Manager.cc @@ -448,7 +448,7 @@ bool Manager::IsDisabled(analyzer::Tag tag) if ( ! disabled ) disabled = internal_const_val("Files::disable")->AsTableVal(); - Val* index = new Val(tag, TYPE_COUNT); + Val* index = new Val(bool(tag), TYPE_COUNT); Val* yield = disabled->Lookup(index); Unref(index); diff --git a/src/file_analysis/Tag.h b/src/file_analysis/Tag.h index c28183a07f..afa1a22ec0 100644 --- a/src/file_analysis/Tag.h +++ b/src/file_analysis/Tag.h @@ -46,7 +46,7 @@ public: * otherwise this may allow nonsense/undesired comparison operations. * */ - operator bool() const { return *this != Tag(); } + explicit operator bool() const { return *this != Tag(); } /** * Assignment operator. diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index 2cec7cf453..9c5416230b 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -78,7 +78,7 @@ struct VersionNumber { /** * Returns true if the version is set to a non-negative value. */ - operator bool() const { return major >= 0 && minor >= 0; } + explicit operator bool() const { return major >= 0 && minor >= 0; } }; /**