diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-09-08 15:14:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-09-08 15:16:32 +0100 |
commit | 0835db27a1bd8b61e9ca2fda14072e6f924e248f (patch) | |
tree | d644e2647f439bcc426e663722ef3db6a709fabd /src/libserver/symcache | |
parent | 558e1039418c192f281cbde65f51d21b0ed51a73 (diff) | |
download | rspamd-0835db27a1bd8b61e9ca2fda14072e6f924e248f.tar.gz rspamd-0835db27a1bd8b61e9ca2fda14072e6f924e248f.zip |
[Minor] Fix some warnings
Diffstat (limited to 'src/libserver/symcache')
-rw-r--r-- | src/libserver/symcache/symcache_impl.cxx | 23 | ||||
-rw-r--r-- | src/libserver/symcache/symcache_item.cxx | 11 | ||||
-rw-r--r-- | src/libserver/symcache/symcache_item.hxx | 6 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx index 6fd705be1..93675ac16 100644 --- a/src/libserver/symcache/symcache_impl.cxx +++ b/src/libserver/symcache/symcache_impl.cxx @@ -81,19 +81,26 @@ auto symcache::init() -> bool if (real_elt) { disabled_ids.insert(real_elt->id); - for (const auto &cld: real_elt->get_children().value().get()) { - msg_debug_cache("symbol %s is a virtual sibling of the disabled symbol %s", - cld->get_name().c_str(), it->get_name().c_str()); - disabled_ids.insert(cld->id); + const auto *children = real_elt->get_children(); + if (children != nullptr) { + for (const auto &cld: *children) { + msg_debug_cache("symbol %s is a virtual sibling of the disabled symbol %s", + cld->get_name().c_str(), it->get_name().c_str()); + disabled_ids.insert(cld->id); + } } } } else { /* Also disable all virtual children of this element */ - for (const auto &cld: it->get_children().value().get()) { - msg_debug_cache("symbol %s is a virtual child of the disabled symbol %s", - cld->get_name().c_str(), it->get_name().c_str()); - disabled_ids.insert(cld->id); + const auto *children = it->get_children(); + + if (children != nullptr) { + for (const auto &cld: *children) { + msg_debug_cache("symbol %s is a virtual child of the disabled symbol %s", + cld->get_name().c_str(), it->get_name().c_str()); + disabled_ids.insert(cld->id); + } } } } diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx index 24e198dd3..ac901f5cf 100644 --- a/src/libserver/symcache/symcache_item.cxx +++ b/src/libserver/symcache/symcache_item.cxx @@ -263,10 +263,13 @@ auto cache_item::inc_frequency(const char *sym_name, symcache &cache) -> void { if (sym_name && symbol != sym_name) { if (is_filter()) { - /* Likely a callback symbol with some virtual symbol that needs to be adjusted */ - for (const auto &cld: get_children().value().get()) { - if (cld->get_name() == sym_name) { - cld->inc_frequency(sym_name, cache); + const auto *children = get_children(); + if (children) { + /* Likely a callback symbol with some virtual symbol that needs to be adjusted */ + for (const auto &cld: *children) { + if (cld->get_name() == sym_name) { + cld->inc_frequency(sym_name, cache); + } } } } diff --git a/src/libserver/symcache/symcache_item.hxx b/src/libserver/symcache/symcache_item.hxx index c159e7c47..a60213a61 100644 --- a/src/libserver/symcache/symcache_item.hxx +++ b/src/libserver/symcache/symcache_item.hxx @@ -483,15 +483,15 @@ public: * @param ptr * @return */ - auto get_children() const -> std::optional<std::reference_wrapper<const std::vector<cache_item *>>> + auto get_children() const -> const std::vector<cache_item *> * { if (std::holds_alternative<normal_item>(specific)) { const auto &filter_data = std::get<normal_item>(specific); - return std::cref(filter_data.get_childen()); + return &filter_data.get_childen(); } - return std::nullopt; + return nullptr; } private: |