Fixes Clang warning on 32-bit platforms.
Clang is more strict about `-Wformat` than GCC. For `%I`, it expects the exact `size_t` type, which is `int` on 32-bit targets, while `SIZE_T` is `long`. For that reason, we currently disable those warnings by not using format attribute on MSVC targets. This is not enough for printf, which is a builtin and has the attribute applied anyway. Using trace, like we do in all other cases, "fixes" it.
I plan to make clang less strict about those cases, which would also fix this problem and allow us to enable format attribute in all relevant functions. However, on current versions of clang, this is one of the last few blockers to support `-Werror`, so it would be nice to have it fixed one way or another. If `printf` is preferred here for some reason, we could also just add an explicit `size_t` cast when printing the size.
-- v2: d3dx9/tests: Remove xfile dumping functionality.
From: Jacek Caban jacek@codeweavers.com
--- dlls/d3dx9_36/tests/xfile.c | 138 ------------------------------------ 1 file changed, 138 deletions(-)
diff --git a/dlls/d3dx9_36/tests/xfile.c b/dlls/d3dx9_36/tests/xfile.c index 0a40e4fbb60..0a04544a4bf 100644 --- a/dlls/d3dx9_36/tests/xfile.c +++ b/dlls/d3dx9_36/tests/xfile.c @@ -16,8 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include <stdio.h> - #include "wine/test.h" #include "d3dx9.h" #include "d3dx9xof.h" @@ -244,146 +242,10 @@ static void test_type_index_color(void) d3dxfile->lpVtbl->Release(d3dxfile); }
-static void process_data(ID3DXFileData *xfile_data, int level) -{ - HRESULT ret; - char name[100]; - GUID clsid; - GUID clsid_type; - SIZE_T len = sizeof(name); - int i; - const BYTE *data; - SIZE_T size; - SIZE_T children; - - ret = xfile_data->lpVtbl->GetId(xfile_data, &clsid); - ok(ret == S_OK, "ID3DXFileData_GetId failed with %#lx\n", ret); - ret = xfile_data->lpVtbl->GetName(xfile_data, name, &len); - ok(ret == S_OK, "ID3DXFileData_GetName failed with %#lx\n", ret); - ret = xfile_data->lpVtbl->GetType(xfile_data, &clsid_type); - ok(ret == S_OK, "IDirectXFileData_GetType failed with %#lx\n", ret); - ret = xfile_data->lpVtbl->Lock(xfile_data, &size, (const void**)&data); - ok(ret == S_OK, "IDirectXFileData_Lock failed with %#lx\n", ret); - - for (i = 0; i < level; i++) - printf(" "); - - printf("Found object '%s' - %s - %s - %Iu\n", - len ? name : "", wine_dbgstr_guid(&clsid), wine_dbgstr_guid(&clsid_type), size); - - if (size) - { - int j; - for (j = 0; j < size; j++) - { - if (j && !(j%16)) - printf("\n"); - printf("%02x ", data[j]); - } - printf("\n"); - } - - ret = xfile_data->lpVtbl->Unlock(xfile_data); - ok(ret == S_OK, "ID3DXFileData_Unlock failed with %#lx\n", ret); - - ret = xfile_data->lpVtbl->GetChildren(xfile_data, &children); - ok(ret == S_OK, "ID3DXFileData_GetChildren failed with %#lx\n", ret); - - level++; - - for (i = 0; i < children; i++) - { - ID3DXFileData *child; - int j; - - ret = xfile_data->lpVtbl->GetChild(xfile_data, i, &child); - ok(ret == S_OK, "ID3DXFileData_GetChild failed with %#lx\n", ret); - for (j = 0; j < level; j++) - printf(" "); - if (child->lpVtbl->IsReference(child)) - printf("Found Data Reference (%d)\n", i + 1); - else - printf("Found Data (%d)\n", i + 1); - - process_data(child, level); - - child->lpVtbl->Release(child); - } -} - -/* Dump an X file 'objects.x' and its related templates file 'templates.x' if they are both presents - * Useful for debug by comparing outputs from native and builtin dlls */ -static void test_dump(void) -{ - HRESULT ret; - ULONG ref; - ID3DXFile *xfile = NULL; - ID3DXFileEnumObject *xfile_enum_object = NULL; - HANDLE file; - void *data; - DWORD size; - SIZE_T children; - int i; - - /* Dump data only if there is an object and a template */ - file = CreateFileA("objects.x", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (file == INVALID_HANDLE_VALUE) - return; - CloseHandle(file); - - file = CreateFileA("templates.x", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (file == INVALID_HANDLE_VALUE) - return; - - data = calloc(1, 10000); - - if (!ReadFile(file, data, 10000, &size, NULL)) - { - skip("Templates file is too big\n"); - goto exit; - } - - printf("Load templates file (%lu bytes)\n", size); - - ret = D3DXFileCreate(&xfile); - ok(ret == S_OK, "D3DXCreateFile failed with %#lx\n", ret); - - ret = xfile->lpVtbl->RegisterTemplates(xfile, data, size); - ok(ret == S_OK, "ID3DXFileImpl_RegisterTemplates failed with %#lx\n", ret); - - ret = xfile->lpVtbl->CreateEnumObject(xfile, (void*)"objects.x", D3DXF_FILELOAD_FROMFILE, &xfile_enum_object); - ok(ret == S_OK, "ID3DXFile_CreateEnumObject failed with %#lx\n", ret); - - ret = xfile_enum_object->lpVtbl->GetChildren(xfile_enum_object, &children); - ok(ret == S_OK, "ID3DXFileEnumObject_GetChildren failed with %#lx\n", ret); - - for (i = 0; i < children; i++) - { - ID3DXFileData *child; - ret = xfile_enum_object->lpVtbl->GetChild(xfile_enum_object, i, &child); - ok(ret == S_OK, "ID3DXFileEnumObject_GetChild failed with %#lx\n", ret); - printf("\n"); - process_data(child, 0); - child->lpVtbl->Release(child); - } - - ref = xfile_enum_object->lpVtbl->Release(xfile_enum_object); - ok(ref == 0, "Got refcount %lu, expected 0\n", ref); - - ref = xfile->lpVtbl->Release(xfile); - ok(ref == 0, "Got refcount %lu, expected 0\n", ref); - - -exit: - CloseHandle(file); - free(data); -} - START_TEST(xfile) { test_templates(); test_lock_unlock(); test_getname(); test_type_index_color(); - test_dump(); }
On Mon May 13 15:56:03 2024 +0000, Nikolay Sivov wrote:
Right, if we ever need it back, winedump is probably a better place for it. Unless it needs some d3dx9 API support to dump it.
It does use D3DXFileCreate and related stuff (I guess the point was to compare ours and MS's implementation and see output differences with an arbitrary .x file), so maybe winedump isn't a great fit, but we can always create our own program if it ever becomes useful. Or even just restore it locally from git history.
On Mon May 13 15:56:03 2024 +0000, Matteo Bruni wrote:
It does use D3DXFileCreate and related stuff (I guess the point was to compare ours and MS's implementation and see output differences with an arbitrary .x file), so maybe winedump isn't a great fit, but we can always create our own program if it ever becomes useful. Or even just restore it locally from git history.
Sounds good to me, I pushed v2 removing the function. Thanks.
This merge request was approved by Matteo Bruni.