Improve BufferManager assertion context args (#3223)

* Improve BufferManager assertion context args

Previously, in some cases, no information or context was provided when
this assertion tripped, which made it harder to identify the cause.
Include more information in several cases.

* Fix assertion argument cast to be generic

* Adding casts for explicit conversion

---------

Co-authored-by: M Starch <LeStarch@googlemail.com>
This commit is contained in:
Cel Skeggs 2025-02-24 14:51:45 -08:00 committed by GitHub
parent 172c7a0643
commit df260a2d1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -192,9 +192,10 @@ namespace Svc {
// allocate memory
void *memory = allocator.allocate(memId,allocatedSize,recoverable);
// make sure the memory returns was non-zero and the size requested
FW_ASSERT(memory);
FW_ASSERT(
memorySize == allocatedSize,
FW_ASSERT(memory != nullptr && memorySize == allocatedSize,
static_cast<FwAssertArgType>(mgrId),
static_cast<FwAssertArgType>(memId),
static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(memory)),
static_cast<FwAssertArgType>(memorySize),
static_cast<FwAssertArgType>(allocatedSize));
// structs will be at beginning of memory
@ -225,11 +226,15 @@ namespace Svc {
U8* const CURR_PTR = bufferMem;
U8* const END_PTR = static_cast<U8*>(memory) + memorySize;
FW_ASSERT(CURR_PTR == END_PTR,
static_cast<FwAssertArgType>(mgrId),
static_cast<FwAssertArgType>(memId),
static_cast<FwAssertArgType>(reinterpret_cast<POINTER_CAST>(CURR_PTR)),
static_cast<FwAssertArgType>(reinterpret_cast<POINTER_CAST>(END_PTR)));
// secondary init verification
FW_ASSERT(
currStruct == this->m_numStructs,
static_cast<FwAssertArgType>(mgrId),
static_cast<FwAssertArgType>(memId),
static_cast<FwAssertArgType>(currStruct),
static_cast<FwAssertArgType>(this->m_numStructs));
// indicate setup is done