localspl/tests: Use BOOL type where appropriate
Frédéric Delanoy
frederic.delanoy at gmail.com
Sat Nov 16 04:00:09 CST 2013
---
dlls/localspl/tests/localmon.c | 111 +++++++++++++++++++++--------------------
1 file changed, 56 insertions(+), 55 deletions(-)
diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c
index 4e913c0..66bd1c5 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -149,7 +149,8 @@ static void find_installed_ports(void)
WCHAR nameW[PORTNAME_MAXSIZE];
DWORD needed;
DWORD returned;
- DWORD res;
+ BOOL res;
+ INT len;
DWORD id;
have_com[0] = '\0';
@@ -172,23 +173,22 @@ static void find_installed_ports(void)
id = 0;
while (id < returned) {
- res = lstrlenW(pi[id].pName);
- if ((res >= PORTNAME_MINSIZE) && (res < PORTNAME_MAXSIZE) &&
- (pi[id].pName[res-1] == ':')) {
+ len = lstrlenW(pi[id].pName);
+ if (len >= PORTNAME_MINSIZE && len < PORTNAME_MAXSIZE && pi[id].pName[len-1] == ':') {
/* copy only the prefix ("LPT" or "COM") */
memcpy(&nameW, pi[id].pName, PORTNAME_PREFIX * sizeof(WCHAR));
nameW[PORTNAME_PREFIX] = '\0';
if (!have_com[0] && (lstrcmpiW(nameW, portname_comW) == 0)) {
- memcpy(&have_com, pi[id].pName, (res+1) * sizeof(WCHAR));
+ memcpy(&have_com, pi[id].pName, (len+1) * sizeof(WCHAR));
}
if (!have_lpt[0] && (lstrcmpiW(nameW, portname_lptW) == 0)) {
- memcpy(&have_lpt, pi[id].pName, (res+1) * sizeof(WCHAR));
+ memcpy(&have_lpt, pi[id].pName, (len+1) * sizeof(WCHAR));
}
if (!have_file[0] && (lstrcmpiW(pi[id].pName, portname_fileW) == 0)) {
- memcpy(&have_file, pi[id].pName, (res+1) * sizeof(WCHAR));
+ memcpy(&have_file, pi[id].pName, (len+1) * sizeof(WCHAR));
}
}
id++;
@@ -201,7 +201,7 @@ static void find_installed_ports(void)
static void test_AddPort(void)
{
- DWORD res;
+ BOOL res;
/* moved to localui.dll since w2k */
if (!pAddPort) return;
@@ -232,7 +232,7 @@ static void test_AddPort(void)
static void test_AddPortEx(void)
{
PORT_INFO_2W pi;
- DWORD res;
+ BOOL res;
if (!pAddPortEx) {
skip("AddPortEx\n");
@@ -252,15 +252,15 @@ static void test_AddPortEx(void)
but works with native localspl.dll in wine */
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 1, (LPBYTE) &pi, LocalPortW);
- trace("returned %u with %u\n", res, GetLastError() );
- ok( res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
+ trace("returned %d with %u\n", res, GetLastError() );
+ ok( res, "got %d with %u (expected '!= 0')\n", res, GetLastError());
/* port already exists: */
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 1, (LPBYTE) &pi, LocalPortW);
- trace("returned %u with %u\n", res, GetLastError() );
+ trace("returned %d with %u\n", res, GetLastError() );
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
- "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
res, GetLastError());
delete_port(tempfileW);
@@ -269,27 +269,27 @@ static void test_AddPortEx(void)
localspl.dll fails always with ERROR_INVALID_PARAMETER */
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 1, (LPBYTE) &pi, NULL);
- trace("returned %u with %u\n", res, GetLastError() );
+ trace("returned %d with %u\n", res, GetLastError() );
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
- "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
res, GetLastError());
if (res) delete_port(tempfileW);
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 1, (LPBYTE) &pi, emptyW);
- trace("returned %u with %u\n", res, GetLastError() );
+ trace("returned %d with %u\n", res, GetLastError() );
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
- "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
res, GetLastError());
if (res) delete_port(tempfileW);
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 1, (LPBYTE) &pi, does_not_existW);
- trace("returned %u with %u\n", res, GetLastError() );
+ trace("returned %d with %u\n", res, GetLastError() );
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
- "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
res, GetLastError());
if (res) delete_port(tempfileW);
}
@@ -298,7 +298,7 @@ static void test_AddPortEx(void)
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 1, (LPBYTE) &pi, LocalPortW);
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
- "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
res, GetLastError());
/* level 2 is documented as supported for Printmonitors,
@@ -312,7 +312,7 @@ static void test_AddPortEx(void)
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 2, (LPBYTE) &pi, LocalPortW);
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
- "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
if (res) delete_port(tempfileW);
@@ -321,7 +321,7 @@ static void test_AddPortEx(void)
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 0, (LPBYTE) &pi, LocalPortW);
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
- "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
if (res) delete_port(tempfileW);
@@ -329,7 +329,7 @@ static void test_AddPortEx(void)
SetLastError(0xdeadbeef);
res = pAddPortEx(NULL, 3, (LPBYTE) &pi, LocalPortW);
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
- "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
+ "got %d with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
if (res) delete_port(tempfileW);
@@ -344,8 +344,8 @@ static void test_ClosePort(void)
HANDLE hPort;
HANDLE hPort2;
LPWSTR nameW = NULL;
- DWORD res;
- DWORD res2;
+ BOOL res;
+ BOOL res2;
if (!pOpenPort || !pClosePort) return;
@@ -361,13 +361,13 @@ static void test_ClosePort(void)
if (res2 && (hPort2 != hPort)) {
SetLastError(0xdeadbeef);
res2 = pClosePort(hPort2);
- ok(res2, "got %u with %u (expected '!= 0')\n", res2, GetLastError());
+ ok(res2, "got %d with %u (expected '!= 0')\n", res2, GetLastError());
}
if (res) {
SetLastError(0xdeadbeef);
res = pClosePort(hPort);
- ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
+ ok(res, "got %d with %u (expected '!= 0')\n", res, GetLastError());
}
}
@@ -383,13 +383,13 @@ static void test_ClosePort(void)
if (res2 && (hPort2 != hPort)) {
SetLastError(0xdeadbeef);
res2 = pClosePort(hPort2);
- ok(res2, "got %u with %u (expected '!= 0')\n", res2, GetLastError());
+ ok(res2, "got %d with %u (expected '!= 0')\n", res2, GetLastError());
}
if (res) {
SetLastError(0xdeadbeef);
res = pClosePort(hPort);
- ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
+ ok(res, "got %d with %u (expected '!= 0')\n", res, GetLastError());
}
}
@@ -405,13 +405,13 @@ static void test_ClosePort(void)
if (res2 && (hPort2 != hPort)) {
SetLastError(0xdeadbeef);
res2 = pClosePort(hPort2);
- ok(res2, "got %u with %u (expected '!= 0')\n", res2, GetLastError());
+ ok(res2, "got %d with %u (expected '!= 0')\n", res2, GetLastError());
}
if (res) {
SetLastError(0xdeadbeef);
res = pClosePort(hPort);
- ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
+ ok(res, "got %d with %u (expected '!= 0')\n", res, GetLastError());
}
}
@@ -421,15 +421,15 @@ static void test_ClosePort(void)
SetLastError(0xdeadbeef);
res = pClosePort(NULL);
- trace("got %u with %u\n", res, GetLastError());
+ trace("got %d with %u\n", res, GetLastError());
SetLastError(0xdeadbeef);
res = pClosePort( (HANDLE) 0xdeadbeef);
- trace("got %u with %u\n", res, GetLastError());
+ trace("got %d with %u\n", res, GetLastError());
SetLastError(0xdeadbeef);
res = pClosePort(INVALID_HANDLE_VALUE);
- trace("got %u with %u\n", res, GetLastError());
+ trace("got %d with %u\n", res, GetLastError());
}
}
@@ -438,7 +438,7 @@ static void test_ClosePort(void)
static void test_ConfigurePort(void)
{
- DWORD res;
+ BOOL res;
/* moved to localui.dll since w2k */
if (!pConfigurePort) return;
@@ -479,7 +479,7 @@ static void test_ConfigurePort(void)
static void test_DeletePort(void)
{
- DWORD res;
+ BOOL res;
/* moved to localui.dll since w2k */
if (!pDeletePort) return;
@@ -512,7 +512,7 @@ static void test_DeletePort(void)
static void test_EnumPorts(void)
{
- DWORD res;
+ BOOL res;
DWORD level;
LPBYTE buffer;
DWORD cbBuf;
@@ -634,8 +634,8 @@ static void test_OpenPort(void)
HANDLE hPort;
HANDLE hPort2;
LPWSTR nameW = NULL;
- DWORD res;
- DWORD res2;
+ BOOL res;
+ BOOL res2;
if (!pOpenPort || !pClosePort) return;
@@ -645,14 +645,14 @@ static void test_OpenPort(void)
hPort = (HANDLE) 0xdeadbeef;
SetLastError(0xdeadbeef);
res = pOpenPort(nameW, &hPort);
- ok( res, "got %u with %u and %p (expected '!= 0')\n",
+ ok( res, "got %d with %u and %p (expected '!= 0')\n",
res, GetLastError(), hPort);
/* the same HANDLE is returned for a second OpenPort in native localspl */
hPort2 = (HANDLE) 0xdeadbeef;
SetLastError(0xdeadbeef);
res2 = pOpenPort(nameW, &hPort2);
- ok( res2, "got %u with %u and %p (expected '!= 0')\n",
+ ok( res2, "got %d with %u and %p (expected '!= 0')\n",
res2, GetLastError(), hPort2);
if (res) pClosePort(hPort);
@@ -666,7 +666,7 @@ static void test_OpenPort(void)
SetLastError(0xdeadbeef);
res = pOpenPort(nameW, &hPort);
ok( res || (GetLastError() == ERROR_ACCESS_DENIED),
- "got %u with %u and %p (expected '!= 0' or '0' with ERROR_ACCESS_DENIED)\n",
+ "got %d with %u and %p (expected '!= 0' or '0' with ERROR_ACCESS_DENIED)\n",
res, GetLastError(), hPort);
/* the same HANDLE is returned for a second OpenPort in native localspl */
@@ -674,7 +674,7 @@ static void test_OpenPort(void)
SetLastError(0xdeadbeef);
res2 = pOpenPort(nameW, &hPort2);
ok( res2 || (GetLastError() == ERROR_ACCESS_DENIED),
- "got %u with %u and %p (expected '!= 0' or '0' with ERROR_ACCESS_DENIED)\n",
+ "got %d with %u and %p (expected '!= 0' or '0' with ERROR_ACCESS_DENIED)\n",
res2, GetLastError(), hPort2);
if (res) pClosePort(hPort);
@@ -687,7 +687,7 @@ static void test_OpenPort(void)
hPort = (HANDLE) 0xdeadbeef;
SetLastError(0xdeadbeef);
res = pOpenPort(nameW, &hPort);
- ok( res, "got %u with %u and %p (expected '!= 0')\n",
+ ok( res, "got %d with %u and %p (expected '!= 0')\n",
res, GetLastError(), hPort);
/* a different HANDLE is returned for a second OpenPort */
@@ -695,7 +695,7 @@ static void test_OpenPort(void)
SetLastError(0xdeadbeef);
res2 = pOpenPort(nameW, &hPort2);
ok( res2 && (hPort2 != hPort),
- "got %u with %u and %p (expected '!= 0' and '!= %p')\n",
+ "got %d with %u and %p (expected '!= 0' and '!= %p')\n",
res2, GetLastError(), hPort2, hPort);
if (res) pClosePort(hPort);
@@ -708,7 +708,7 @@ static void test_OpenPort(void)
hPort = (HANDLE) 0xdeadbeef;
SetLastError(0xdeadbeef);
res = pOpenPort(nameW, NULL);
- trace("got %u with %u and %p\n", res, GetLastError(), hPort);
+ trace("got %d with %u and %p\n", res, GetLastError(), hPort);
}
}
@@ -716,14 +716,14 @@ static void test_OpenPort(void)
SetLastError(0xdeadbeef);
res = pOpenPort(does_not_existW, &hPort);
ok (!res && (hPort == (HANDLE) 0xdeadbeef),
- "got %u with 0x%x and %p (expected '0' and 0xdeadbeef)\n", res, GetLastError(), hPort);
+ "got %d with 0x%x and %p (expected '0' and 0xdeadbeef)\n", res, GetLastError(), hPort);
if (res) pClosePort(hPort);
hPort = (HANDLE) 0xdeadbeef;
SetLastError(0xdeadbeef);
res = pOpenPort(emptyW, &hPort);
ok (!res && (hPort == (HANDLE) 0xdeadbeef),
- "got %u with 0x%x and %p (expected '0' and 0xdeadbeef)\n", res, GetLastError(), hPort);
+ "got %d with 0x%x and %p (expected '0' and 0xdeadbeef)\n", res, GetLastError(), hPort);
if (res) pClosePort(hPort);
@@ -732,7 +732,7 @@ static void test_OpenPort(void)
hPort = (HANDLE) 0xdeadbeef;
SetLastError(0xdeadbeef);
res = pOpenPort(NULL, &hPort);
- trace("got %u with %u and %p\n", res, GetLastError(), hPort);
+ trace("got %d with %u and %p\n", res, GetLastError(), hPort);
}
}
@@ -741,7 +741,7 @@ static void test_OpenPort(void)
static void test_XcvClosePort(void)
{
- DWORD res;
+ BOOL res;
HANDLE hXcv2;
@@ -1303,7 +1303,7 @@ static void test_XcvDataPort_PortIsValid(void)
static void test_XcvOpenPort(void)
{
- DWORD res;
+ BOOL res;
HANDLE hXcv2;
@@ -1359,6 +1359,7 @@ START_TEST(localmon)
{
DWORD numentries;
DWORD res;
+ BOOL res2;
LoadLibraryA("winspool.drv");
/* This DLL does not exist on Win9x */
@@ -1417,12 +1418,12 @@ START_TEST(localmon)
if ((pXcvOpenPort) && (pXcvDataPort) && (pXcvClosePort)) {
SetLastError(0xdeadbeef);
- res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
- ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
+ res2 = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
+ ok(res2, "hXcv: %d with %u and %p (expected '!= 0')\n", res2, GetLastError(), hXcv);
SetLastError(0xdeadbeef);
- res = pXcvOpenPort(emptyW, 0, &hXcv_noaccess);
- ok(res, "hXcv_noaccess: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv_noaccess);
+ res2 = pXcvOpenPort(emptyW, 0, &hXcv_noaccess);
+ ok(res2, "hXcv_noaccess: %d with %u and %p (expected '!= 0')\n", res2, GetLastError(), hXcv_noaccess);
}
}
--
1.8.4.2
More information about the wine-patches
mailing list