Skip to content

All uses of %llu gen warnings in clang, replace with PRIu64 #379

@alecazam

Description

@alecazam

uint64_t is "unsigned long long" on 32-bit, and "unsigned long" on 64-bit, and sometimes "unsigned long int". So the assumption that uint64_t sizes are printed with %llu generates formatting errors when a VMA_DEBUG_LOG is defined to be used with printflike parameter testing. I'm building various platforms in Xcode and VS.

I also split off VMA_DEBUG_LOG which is overly verbose into VMA_DEBUG_LOG_LEAK. And I defined VMA_ASSERT to a non aborting assert that we have so that shutdown doesn't kill the app on leaks which are non-critical then. Otherwise, or code was originally skipping destroying non-empty pools and the allocator to avoid those asserts. So then leaks were never shown.

static inline void VmaUint64ToStr(char* VMA_NOT_NULL outStr, size_t strLen, uint64_t num)
{
        snprintf(outStr, strLen, "%" PRIu64, num);
}
    
void VmaBlockMetadata::DebugLogAllocation(VkDeviceSize offset, VkDeviceSize size, void* userData) const
{
    if (IsVirtual())
    {
        VMA_DEBUG_LOG_LEAK("UNFREED VIRTUAL ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p", offset, size, userData);
    }
    else
    {
        VMA_ASSERT(userData != VMA_NULL);
        VmaAllocation allocation = reinterpret_cast<VmaAllocation>(userData);

        userData = allocation->GetUserData();
        const char* name = allocation->GetName();

#if VMA_STATS_STRING_ENABLED
        VMA_DEBUG_LOG_LEAK("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %s; Usage: %u",
            offset, size, userData, name ? name : "vma_empty",
            VMA_SUBALLOCATION_TYPE_NAMES[allocation->GetSuballocationType()],
            allocation->GetBufferImageUsage());
#else
        VMA_DEBUG_LOG_LEAK("UNFREED ALLOCATION; Offset: % " PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %u",
            offset, size, userData, name ? name : "vma_empty",
            (uint32_t)allocation->GetSuballocationType());
#endif // VMA_STATS_STRING_ENABLED
    }
    
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions