From 1d4595a349be70364d12157d0496bcde298eae61 Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 13 Dec 2019 04:00:31 +0200 Subject: [PATCH] Idm: Minor assert fix --- rpcs3/Emu/IdManager.cpp | 10 +++------- rpcs3/Emu/IdManager.h | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/IdManager.cpp b/rpcs3/Emu/IdManager.cpp index 2ac24c2fd7..cf5d0bee14 100644 --- a/rpcs3/Emu/IdManager.cpp +++ b/rpcs3/Emu/IdManager.cpp @@ -19,13 +19,9 @@ id_manager::id_map::pointer idm::allocate_id(const id_manager::id_key& info, u32 { // Try to emplace back const u32 _next = base + step * ::size32(vec); - - if (_next >= base && _next < base + step * count) - { - g_id = _next; - vec.emplace_back(id_manager::id_key(_next, info.type()), nullptr); - return &vec.back(); - } + g_id = _next; + vec.emplace_back(id_manager::id_key(_next, info.type()), nullptr); + return &vec.back(); } // Check all IDs starting from "next id" (TODO) diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index e8db37535a..f8c5088ffa 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -33,7 +33,7 @@ namespace id_manager static const u32 invalid = -+!base; // Note: full 32 bits range cannot be used at current implementation - static_assert(count > 0 && step > 0 && u64{step} * count + base < u64{UINT32_MAX} + (base != 0 ? 1 : 0), "ID traits: invalid object range"); + static_assert(count && step && u64{step} * (count - 1) + base < u64{UINT32_MAX} + (base != 0 ? 1 : 0), "ID traits: invalid object range"); }; // Correct usage testing