Module: wine Branch: master Commit: f7385699a9aa26125eabc4143a50254a289cda49 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f7385699a9aa26125eabc4143a...
Author: Andrew Nguyen anguyen@codeweavers.com Date: Tue Feb 1 04:40:44 2011 -0600
ntdll/tests: Avoid casting away const in comparison functions.
---
dlls/ntdll/tests/string.c | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/tests/string.c b/dlls/ntdll/tests/string.c index 03fc436..14464d9 100644 --- a/dlls/ntdll/tests/string.c +++ b/dlls/ntdll/tests/string.c @@ -1143,22 +1143,32 @@ static void test_wcsrchr(void) "wcsrchr should have returned NULL\n"); }
-static __cdecl int intcomparefunc(const void *a, const void*b) +static __cdecl int intcomparefunc(const void *a, const void *b) { - ok (a != b, "must never get the same pointer\n"); - return (*(int*)a) - (*(int*)b); + const int *p = a, *q = b; + + ok (a != b, "must never get the same pointer\n"); + + return *p - *q; }
-static __cdecl int charcomparefunc(const void *a, const void*b) +static __cdecl int charcomparefunc(const void *a, const void *b) { - ok (a != b, "must never get the same pointer\n"); - return (*(char*)a) - (*(char*)b); + const char *p = a, *q = b; + + ok (a != b, "must never get the same pointer\n"); + + return *p - *q; }
-static __cdecl int strcomparefunc(const void *a, const void*b) +static __cdecl int strcomparefunc(const void *a, const void *b) { - ok (a != b, "must never get the same pointer\n"); - return lstrcmpA(*(char**)a,*(char**)b); + const char * const *p = a; + const char * const *q = b; + + ok (a != b, "must never get the same pointer\n"); + + return lstrcmpA(*p, *q); }
static void test_qsort(void)