From 29f4620826d4a937d756b019ce62df93b90ab846 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 4 Jul 2022 16:19:28 -0700 Subject: [PATCH] ircd::m: Ensure signed integer subtractions are defined. --- matrix/acquire.cc | 8 ++++---- matrix/room_head_fetch.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/matrix/acquire.cc b/matrix/acquire.cc index 52b3b1d9b..cb5caa141 100644 --- a/matrix/acquire.cc +++ b/matrix/acquire.cc @@ -218,7 +218,7 @@ ircd::m::acquire::fetch_history(event::idx &ref_min) // Fortunately in practice the majority of estimates are close enough. // XXX /get_missing_events should be considered if there's low // confidence in a gap estimate. - const auto &limit + const auto limit { std::clamp(gap, 1UL, 48UL) }; @@ -557,12 +557,12 @@ ircd::m::acquire::fetch_head(const m::event &result, const auto gap { - json::get<"depth"_>(result) - top_depth + uint64_t(json::get<"depth"_>(result)) - top_depth }; - const auto &limit + const auto limit { - std::clamp(gap, 1L, 48L) + std::clamp(int64_t(gap), 1L, 48L) }; const auto &hint diff --git a/matrix/room_head_fetch.cc b/matrix/room_head_fetch.cc index 2c4c51535..1c0fcaeed 100644 --- a/matrix/room_head_fetch.cc +++ b/matrix/room_head_fetch.cc @@ -211,9 +211,9 @@ ircd::m::room::head::fetch::fetch(const opts &opts, // The depth comes back as one greater than any existing // depth so we subtract one. - const auto &depth + const auto depth { - std::max(json::get<"depth"_>(event) - 1L, 0L) + int64_t(std::max(uint64_t(json::get<"depth"_>(event)) - 1, 0UL)) }; const auto &ots