Fix conformance test warnings on Windows

Francois Gouget fgouget at codeweavers.com
Fri Feb 11 16:16:59 CST 2005


MSVC issues a lot of signed/unsigned comparison warnings. I only fixed 
the simplest and only where I did not have to introduce casts. Well, I 
did have to introduce two casts because of nasty sizeof()s that caused 
the entire expression to become unsigned :-(


Changelog:

  * dlls/advapi32/tests/security.c
    dlls/gdi/tests/metafile.c
    dlls/mlang/tests/mlang.c
    dlls/msvcrt/tests/file.c
    dlls/ntdll/tests/path.c

    Francois Gouget <fgouget at codeweavers.com>
    Cast the GetProcAddress() return value to avoid warnings about the 
function pointer being of the wrong type.
    Fix assorted signed/unsigned comparison warnings.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/advapi32/tests/security.c
===================================================================
RCS file: /var/cvs/wine/dlls/advapi32/tests/security.c,v
retrieving revision 1.7
diff -u -p -r1.7 security.c
--- dlls/advapi32/tests/security.c	27 Dec 2004 17:46:36 -0000	1.7
+++ dlls/advapi32/tests/security.c	11 Feb 2005 17:52:08 -0000
@@ -213,7 +213,7 @@ static void test_allocateLuid(void)
     LUID luid1, luid2;
     BOOL ret;
 
-    pAllocateLocallyUniqueId = GetProcAddress(hmod, "AllocateLocallyUniqueId");
+    pAllocateLocallyUniqueId = (void*)GetProcAddress(hmod, "AllocateLocallyUniqueId");
     if (!pAllocateLocallyUniqueId) return;
 
     ret = pAllocateLocallyUniqueId(&luid1);
@@ -245,7 +245,7 @@ static void test_lookupPrivilegeName(voi
     BOOL ret;
 
     /* check whether it's available first */
-    pLookupPrivilegeNameA = GetProcAddress(hmod, "LookupPrivilegeNameA");
+    pLookupPrivilegeNameA = (void*)GetProcAddress(hmod, "LookupPrivilegeNameA");
     if (!pLookupPrivilegeNameA) return;
     luid.LowPart = SE_CREATE_TOKEN_PRIVILEGE;
     ret = pLookupPrivilegeNameA(NULL, &luid, buf, &cchName);
@@ -298,7 +298,7 @@ static void test_lookupPrivilegeName(voi
 struct NameToLUID
 {
     const char *name;
-    LONG lowPart;
+    DWORD lowPart;
 };
 
 static void test_lookupPrivilegeValue(void)
@@ -340,7 +340,7 @@ static void test_lookupPrivilegeValue(vo
     BOOL ret;
 
     /* check whether it's available first */
-    pLookupPrivilegeValueA = GetProcAddress(hmod, "LookupPrivilegeValueA");
+    pLookupPrivilegeValueA = (void*)GetProcAddress(hmod, "LookupPrivilegeValueA");
     if (!pLookupPrivilegeValueA) return;
     ret = pLookupPrivilegeValueA(NULL, "SeCreateTokenPrivilege", &luid);
     if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
Index: dlls/gdi/tests/metafile.c
===================================================================
RCS file: /var/cvs/wine/dlls/gdi/tests/metafile.c,v
retrieving revision 1.5
diff -u -p -r1.5 metafile.c
--- dlls/gdi/tests/metafile.c	14 Jan 2005 15:12:59 -0000	1.5
+++ dlls/gdi/tests/metafile.c	11 Feb 2005 17:54:44 -0000
@@ -259,8 +259,7 @@ static const unsigned char MF_PATTERN_BR
 static void dump_mf_bits (const HMETAFILE mf, const char *desc)
 {
     char buf[MF_BUFSIZE];
-    UINT mfsize;
-    int i;
+    UINT mfsize, i;
 
     mfsize = GetMetaFileBitsEx (mf, MF_BUFSIZE, buf);
     ok (mfsize > 0, "%s: GetMetaFileBitsEx failed.\n", desc);
@@ -286,12 +285,12 @@ static void dump_mf_bits (const HMETAFIL
  * otherwise returns the number of non-matching bytes.
  */
 
-static int compare_mf_bits (const HMETAFILE mf, const char *bits, int bsize,
+static int compare_mf_bits (const HMETAFILE mf, const char *bits, UINT bsize,
     const char *desc)
 {
     char buf[MF_BUFSIZE];
-    UINT mfsize;
-    int i, diff;
+    UINT mfsize, i;
+    int diff;
 
     mfsize = GetMetaFileBitsEx (mf, MF_BUFSIZE, buf);
     ok (mfsize > 0, "%s: GetMetaFileBitsEx failed.\n", desc);
Index: dlls/mlang/tests/mlang.c
===================================================================
RCS file: /var/cvs/wine/dlls/mlang/tests/mlang.c,v
retrieving revision 1.6
diff -u -p -r1.6 mlang.c
--- dlls/mlang/tests/mlang.c	2 Sep 2004 20:09:37 -0000	1.6
+++ dlls/mlang/tests/mlang.c	11 Feb 2005 18:36:03 -0000
@@ -51,7 +51,7 @@ static void test_multibyte_to_unicode_tr
     WCHAR stringW[] = {'J','u','s','t',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
     char bufA[256];
     WCHAR bufW[256];
-    UINT lenA, lenW, expected_len;
+    int lenA, lenW, expected_len;
     HRESULT ret;
     HMODULE hMlang;
     FARPROC pConvertINetMultiByteToUnicode;
@@ -105,7 +105,7 @@ static void test_multibyte_to_unicode_tr
     ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, CP_UNICODE, stringA, &lenA, bufW, &lenW);
     ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
-    ok(lenW == lstrlenW(stringW)/sizeof(WCHAR), "expected lenW %u, got %u\n", lstrlenW(stringW)/sizeof(WCHAR), lenW);
+    ok(lenW == lstrlenW(stringW)/(int)sizeof(WCHAR), "expected lenW %u, got %u\n", lstrlenW(stringW)/sizeof(WCHAR), lenW);
     ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
     bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
     ok(!lstrcmpA((LPCSTR)bufW, stringA), "bufW/stringA mismatch\n");
@@ -176,7 +176,7 @@ static void test_multibyte_to_unicode_tr
     TRACE_2("Call IMultiLanguage2_ConvertStringFromUnicode\n");
     ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, CP_UNICODE, stringW, &lenW, bufA, &lenA);
     ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
-    ok(lenA == lstrlenA(stringA) * sizeof(WCHAR), "expected lenA %u, got %u\n", lstrlenA(stringA) * sizeof(WCHAR), lenA);
+    ok(lenA == lstrlenA(stringA) * (int)sizeof(WCHAR), "expected lenA %u, got %u\n", lstrlenA(stringA) * sizeof(WCHAR), lenA);
     ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
     ok(bufA[lenA] != 0 && bufA[lenA+1] != 0, "buf should not be 0 terminated\n");
     bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
Index: dlls/msvcrt/tests/file.c
===================================================================
RCS file: /var/cvs/wine/dlls/msvcrt/tests/file.c,v
retrieving revision 1.12
diff -u -p -r1.12 file.c
--- dlls/msvcrt/tests/file.c	27 Dec 2004 17:46:36 -0000	1.12
+++ dlls/msvcrt/tests/file.c	11 Feb 2005 18:00:18 -0000
@@ -71,7 +71,7 @@ static void test_fileops( void )
     ok(feof(file) !=0,"feof doesn't signal EOF\n");
     rewind(file);
     ok(fgets(buffer,strlen(outbuffer),file) !=0,"fgets failed unexpected\n");
-    ok(lstrlenA(buffer) == strlen(outbuffer) -1,"fgets didn't read right size\n");
+    ok(lstrlenA(buffer) == lstrlenA(outbuffer) -1,"fgets didn't read right size\n");
     ok(fgets(buffer,sizeof(outbuffer),file) !=0,"fgets failed unexpected\n");
     ok(strlen(buffer) == 1,"fgets dropped chars\n");
     ok(buffer[0] == outbuffer[strlen(outbuffer)-1],"fgets exchanged chars\n");
@@ -83,7 +83,7 @@ static void test_fileops( void )
     ok(feof(file) !=0,"feof doesn't signal EOF\n");
     rewind(file);
     ok(fgetws(wbuffer,strlen(outbuffer),file) !=0,"fgetws failed unexpected\n");
-    ok(lstrlenW(wbuffer) == (strlen(outbuffer) -1),"fgetws didn't read right size\n");
+    ok(lstrlenW(wbuffer) == (lstrlenA(outbuffer) -1),"fgetws didn't read right size\n");
     ok(fgetws(wbuffer,sizeof(outbuffer),file) !=0,"fgets failed unexpected\n");
     ok(lstrlenW(wbuffer) == 1,"fgets dropped chars\n");
     fclose (file);
Index: dlls/ntdll/tests/path.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/tests/path.c,v
retrieving revision 1.11
diff -u -p -r1.11 path.c
--- dlls/ntdll/tests/path.c	14 Aug 2004 00:42:12 -0000	1.11
+++ dlls/ntdll/tests/path.c	11 Feb 2005 18:38:39 -0000
@@ -35,7 +35,7 @@ static void test_RtlDetermineDosPathName
     struct test
     {
         const char *path;
-        int ret;
+        UINT ret;
     };
 
     static const struct test tests[] =
@@ -255,7 +255,7 @@ static void test_RtlGetFullPathName_U()
     ULONG ret;
     WCHAR *file_part;
     DWORD reslen;
-    int len;
+    UINT len;
 
     for (test = tests; test->path; test++)
     {


More information about the wine-patches mailing list