Andrew Nguyen : msvcr90/tests: Avoid casting away const in comparison functions.

Alexandre Julliard julliard at winehq.org
Tue Feb 1 12:24:58 CST 2011


Module: wine
Branch: master
Commit: 39eb51f978042e209d78f962e280018f876cb3b5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=39eb51f978042e209d78f962e280018f876cb3b5

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Tue Feb  1 04:40:14 2011 -0600

msvcr90/tests: Avoid casting away const in comparison functions.

---

 dlls/msvcr90/tests/msvcr90.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index d4a7262..67b00fc 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -462,25 +462,35 @@ static void test_wcsncat_s(void)
 }
 
 /* Based on dlls/ntdll/tests/string.c */
-static __cdecl int intcomparefunc(void *context, const void *a, const void*b)
+static __cdecl int intcomparefunc(void *context, const void *a, const void *b)
 {
+    const int *p = a, *q = b;
+
     ok (a != b, "must never get the same pointer\n");
     ++*(int *) context;
-    return (*(int*)a) - (*(int*)b);
+
+    return *p - *q;
 }
 
-static __cdecl int charcomparefunc(void *context, const void *a, const void*b)
+static __cdecl int charcomparefunc(void *context, const void *a, const void *b)
 {
+    const char *p = a, *q = b;
+
     ok (a != b, "must never get the same pointer\n");
     ++*(int *) context;
-    return (*(char*)a) - (*(char*)b);
+
+    return *p - *q;
 }
 
-static __cdecl int strcomparefunc(void *context, const void *a, const void*b)
+static __cdecl int strcomparefunc(void *context, const void *a, const void *b)
 {
+    const char * const *p = a;
+    const char * const *q = b;
+
     ok (a != b, "must never get the same pointer\n");
     ++*(int *) context;
-    return lstrcmpA(*(char**)a,*(char**)b);
+
+    return lstrcmpA(*p, *q);
 }
 
 static void test_qsort_s(void)




More information about the wine-cvs mailing list