From 37cdb06dce4248997fc60a7538c1a621ffad827b Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 17 May 2022 03:16:21 +0200 Subject: [PATCH] From dhewm3: Fix most (according to warnings) remaining 64bit issues in tool code only the TypeInfo changes are applicable to the SDK --- d3xp/gamesys/TypeInfo.cpp | 10 +++++++++- game/gamesys/TypeInfo.cpp | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/d3xp/gamesys/TypeInfo.cpp b/d3xp/gamesys/TypeInfo.cpp index 2742c68..aab6c46 100644 --- a/d3xp/gamesys/TypeInfo.cpp +++ b/d3xp/gamesys/TypeInfo.cpp @@ -569,10 +569,18 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c return typeSize; } +#if D3_SIZEOFPTR == 4 + const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdUL; +#elif D3_SIZEOFPTR == 8 + const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdcdcdcdcdULL; +#else +#error "Unexpected pointer size" +#endif + // if this is a pointer isPointer = 0; for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) { - if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) { + if ( varPtr == (void*)uninitPtr || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) { common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" ); return typeSize; } diff --git a/game/gamesys/TypeInfo.cpp b/game/gamesys/TypeInfo.cpp index 2742c68..40f55e8 100644 --- a/game/gamesys/TypeInfo.cpp +++ b/game/gamesys/TypeInfo.cpp @@ -570,9 +570,18 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c } // if this is a pointer + +#if D3_SIZEOFPTR == 4 + const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdUL; +#elif D3_SIZEOFPTR == 8 + const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdcdcdcdcdULL; +#else + #error "Unexpected pointer size" +#endif + isPointer = 0; for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) { - if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) { + if ( varPtr == (void*)uninitPtr || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) { common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" ); return typeSize; }