diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-21 15:37:04 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-21 15:37:04 +0100 |
commit | a8e0f75aa6df80fd27ea25f40307f3892a991c8f (patch) | |
tree | 710eeb440961d72c8ffe9c261088f1ce7120e28d /src | |
parent | 923f93fb6bad21c3a6edadca15e516daa05d1e5f (diff) | |
download | rspamd-a8e0f75aa6df80fd27ea25f40307f3892a991c8f.tar.gz rspamd-a8e0f75aa6df80fd27ea25f40307f3892a991c8f.zip |
[Minor] Agree on types between dump and backend
Diffstat (limited to 'src')
-rw-r--r-- | src/libstat/backends/cdb_backend.cxx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx index 5e1ec243b..15c3d3035 100644 --- a/src/libstat/backends/cdb_backend.cxx +++ b/src/libstat/backends/cdb_backend.cxx @@ -145,7 +145,7 @@ private: template<typename T> static inline auto -cdb_get_key_as_double(struct cdb *cdb, T key) -> std::optional<double> +cdb_get_key_as_int64(struct cdb *cdb, T key) -> std::optional<std::int64_t> { auto pos = cdb_find(cdb, (void *)&key, sizeof(key)); @@ -153,8 +153,8 @@ cdb_get_key_as_double(struct cdb *cdb, T key) -> std::optional<double> auto vpos = cdb_datapos(cdb); auto vlen = cdb_datalen(cdb); - if (vlen == sizeof(double)) { - double ret; + if (vlen == sizeof(std::int64_t)) { + std::int64_t ret; cdb_read(cdb, (void *)&ret, vlen, vpos); return ret; @@ -206,13 +206,12 @@ ro_backend::load_cdb() -> tl::expected<bool, std::string> auto check_key = [&](const char *key, std::uint64_t &target) -> tl::expected<bool, std::string> { memcpy((void *)&cdb_key, key, sizeof(cdb_key)); - auto maybe_value = cdb_get_key_as_double(db.get(), cdb_key); + auto maybe_value = cdb_get_key_as_int64(db.get(), cdb_key); if (!maybe_value) { return tl::make_unexpected(fmt::format("missing {} key", key)); } - // Convert from double to int target = (std::uint64_t)maybe_value.value(); return true; |