From c157b7def3e951787cf8f57a382cfbe2c1208d6b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 15 Apr 2023 02:44:43 +0300 Subject: [PATCH] filesystem: tests: interface: various fixes * correctly check success variable value in CreateInterface * get rid of C language quirks because this file is C++ * check that globals were filled --- filesystem/tests/interface.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/filesystem/tests/interface.cpp b/filesystem/tests/interface.cpp index 3a221fe7..d215bbbb 100644 --- a/filesystem/tests/interface.cpp +++ b/filesystem/tests/interface.cpp @@ -22,7 +22,7 @@ pfnCreateInterface_t g_pfnCreateInterface; fs_api_t g_fs; fs_globals_t *g_nullglobals; -static qboolean LoadFilesystem( void ) +static bool LoadFilesystem() { int temp = -1; @@ -31,28 +31,34 @@ static qboolean LoadFilesystem( void ) return false; // check our C-style interface existence - g_pfnGetFSAPI = (FSAPI)GetProcAddress( g_hModule, GET_FS_API ); + g_pfnGetFSAPI = reinterpret_cast( GetProcAddress( g_hModule, GET_FS_API )); if( !g_pfnGetFSAPI ) return false; + g_nullglobals = NULL; if( !g_pfnGetFSAPI( FS_API_VERSION, &g_fs, &g_nullglobals, NULL )) return false; + if( !g_nullglobals ) + return false; + // check Valve-style interface existence - g_pfnCreateInterface = (pfnCreateInterface_t)GetProcAddress( g_hModule, "CreateInterface" ); + g_pfnCreateInterface = reinterpret_cast( GetProcAddress( g_hModule, "CreateInterface" )); if( !g_pfnCreateInterface ) return false; if( !g_pfnCreateInterface( "VFileSystem009", &temp ) || temp != 0 ) return false; + temp = -1; + if( !g_pfnCreateInterface( FS_API_CREATEINTERFACE_TAG, &temp ) || temp != 0 ) return false; return true; } -int main( void ) +int main() { if( !LoadFilesystem() ) return EXIT_FAILURE;