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.
From: Jacek Caban jacek@codeweavers.com
Fixes Clang warning on 32-bit platforms. --- dlls/d3dx9_36/tests/xfile.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dx9_36/tests/xfile.c b/dlls/d3dx9_36/tests/xfile.c index 0a40e4fbb60..8ce2c17f875 100644 --- a/dlls/d3dx9_36/tests/xfile.c +++ b/dlls/d3dx9_36/tests/xfile.c @@ -266,10 +266,10 @@ static void process_data(ID3DXFileData *xfile_data, int level) ok(ret == S_OK, "IDirectXFileData_Lock failed with %#lx\n", ret);
for (i = 0; i < level; i++) - printf(" "); + trace(" ");
- printf("Found object '%s' - %s - %s - %Iu\n", - len ? name : "", wine_dbgstr_guid(&clsid), wine_dbgstr_guid(&clsid_type), size); + trace("Found object '%s' - %s - %s - %Iu\n", + len ? name : "", wine_dbgstr_guid(&clsid), wine_dbgstr_guid(&clsid_type), size);
if (size) { @@ -277,10 +277,10 @@ static void process_data(ID3DXFileData *xfile_data, int level) for (j = 0; j < size; j++) { if (j && !(j%16)) - printf("\n"); - printf("%02x ", data[j]); + trace("\n"); + trace("%02x ", data[j]); } - printf("\n"); + trace("\n"); }
ret = xfile_data->lpVtbl->Unlock(xfile_data); @@ -299,11 +299,11 @@ static void process_data(ID3DXFileData *xfile_data, int level) 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(" "); + trace(" "); if (child->lpVtbl->IsReference(child)) - printf("Found Data Reference (%d)\n", i + 1); + trace("Found Data Reference (%d)\n", i + 1); else - printf("Found Data (%d)\n", i + 1); + trace("Found Data (%d)\n", i + 1);
process_data(child, level);
@@ -343,7 +343,7 @@ static void test_dump(void) goto exit; }
- printf("Load templates file (%lu bytes)\n", size); + trace("Load templates file (%lu bytes)\n", size);
ret = D3DXFileCreate(&xfile); ok(ret == S_OK, "D3DXCreateFile failed with %#lx\n", ret); @@ -362,7 +362,7 @@ static void test_dump(void) 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"); + trace("\n"); process_data(child, 0); child->lpVtbl->Release(child); }
I think we can also get rid of the #include <stdio.h>
FWIW, I don't think there was any good reason for using printf here. Also FWIW, that part of the tests doesn't normally run (it tries to open a couple of files but nothing in the tests puts them there): it's kind of a hack for dumping generic .x files. I'd also be okay with just getting rid of the whole thing.
On Mon May 13 15:56:03 2024 +0000, Matteo Bruni wrote:
I think we can also get rid of the #include <stdio.h> FWIW, I don't think there was any good reason for using printf here. Also FWIW, that part of the tests doesn't normally run (it tries to open a couple of files but nothing in the tests puts them there): it's kind of a hack for dumping generic .x files. I'd also be okay with just getting rid of the whole thing.
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.