Commit c6b342d8 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32/tests: Don't use sizeof in ok() to avoid printf format warnings.

parent e19f31b6
...@@ -142,7 +142,7 @@ static void test_overlapped_buffers(void) ...@@ -142,7 +142,7 @@ static void test_overlapped_buffers(void)
lstrcpyW((WCHAR *)(buf + 1), strW); lstrcpyW((WCHAR *)(buf + 1), strW);
ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(buf + 1), -1, buf, sizeof(buf), NULL, NULL); ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(buf + 1), -1, buf, sizeof(buf), NULL, NULL);
ok(ret == sizeof(strA), "unexpected ret %d != %d\n", ret, sizeof(strA)); ok(ret == sizeof(strA), "unexpected ret %d\n", ret);
ok(!memcmp(buf, strA, sizeof(strA)), "conversion failed: %s\n", buf); ok(!memcmp(buf, strA, sizeof(strA)), "conversion failed: %s\n", buf);
} }
......
...@@ -765,10 +765,10 @@ static void test_waittxempty(HANDLE hcom) ...@@ -765,10 +765,10 @@ static void test_waittxempty(HANDLE hcom)
after = GetTickCount(); after = GetTickCount();
ok(res_write == TRUE, "WriteFile failed\n"); ok(res_write == TRUE, "WriteFile failed\n");
ok(written == sizeof(tbuf), ok(written == sizeof(tbuf),
"WriteFile: Unexpected write_size %ld , expected %d\n", written, sizeof(tbuf)); "WriteFile: Unexpected write_size %ld\n", written);
trace("WriteFile succeeded, took %ld ms to write %d Bytes at %ld Baud\n", trace("WriteFile succeeded, took %ld ms to write %ld Bytes at %ld Baud\n",
after - before, sizeof(tbuf), baud); after - before, written, baud);
before = GetTickCount(); before = GetTickCount();
res = WaitCommEvent(hcom, &evtmask, NULL); res = WaitCommEvent(hcom, &evtmask, NULL);
...@@ -845,8 +845,7 @@ static void test_LoopbackRead(HANDLE hcom) ...@@ -845,8 +845,7 @@ static void test_LoopbackRead(HANDLE hcom)
before = GetTickCount(); before = GetTickCount();
ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n"); ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
after = GetTickCount(); after = GetTickCount();
ok(written == sizeof(tbuf),"WriteFile %ld bytes written, expected %d\n", ok(written == sizeof(tbuf),"WriteFile %ld bytes written\n", written);
written, sizeof(tbuf));
diff = after -before; diff = after -before;
/* make sure all bytes are written, so Readfile will succeed in one call*/ /* make sure all bytes are written, so Readfile will succeed in one call*/
...@@ -859,7 +858,7 @@ static void test_LoopbackRead(HANDLE hcom) ...@@ -859,7 +858,7 @@ static void test_LoopbackRead(HANDLE hcom)
read=0; read=0;
ok(ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL), "Readfile failed\n"); ok(ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL), "Readfile failed\n");
ok(read == sizeof(tbuf),"ReadFile read %ld bytes, expected %d \"%s\"\n", read, sizeof(tbuf),rbuf); ok(read == sizeof(tbuf),"ReadFile read %ld bytes, expected \"%s\"\n", read,rbuf);
/* Now do the same withe a slower Baud rate. /* Now do the same withe a slower Baud rate.
As we request more characters then written, we will hit the timeout As we request more characters then written, we will hit the timeout
...@@ -876,8 +875,7 @@ static void test_LoopbackRead(HANDLE hcom) ...@@ -876,8 +875,7 @@ static void test_LoopbackRead(HANDLE hcom)
ok(SetCommMask(hcom, EV_RXCHAR), "SetCommMask failed\n"); ok(SetCommMask(hcom, EV_RXCHAR), "SetCommMask failed\n");
ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n"); ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
ok(written == sizeof(tbuf),"WriteFile %ld bytes written, expected %d\n", ok(written == sizeof(tbuf),"WriteFile %ld bytes written\n", written);
written, sizeof(tbuf));
trace("WaitCommEventEV_RXCHAR\n"); trace("WaitCommEventEV_RXCHAR\n");
ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n"); ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n");
...@@ -888,10 +886,9 @@ static void test_LoopbackRead(HANDLE hcom) ...@@ -888,10 +886,9 @@ static void test_LoopbackRead(HANDLE hcom)
res = ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL); res = ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL);
after = GetTickCount(); after = GetTickCount();
ok(res, "Readfile failed\n"); ok(res, "Readfile failed\n");
ok(read == sizeof(tbuf),"ReadFile read %ld bytes, expected %d\n", read, sizeof(tbuf)); ok(read == sizeof(tbuf),"ReadFile read %ld bytes\n", read);
diff = after - before; diff = after - before;
trace("Readfile for %d chars with %d avail took %ld ms\n", trace("Readfile for %ld chars took %ld ms\n", read, diff);
sizeof(rbuf), sizeof(tbuf), diff);
ok( (diff > TIMEOUT - TIMEDELTA) && (diff < TIMEOUT + TIMEDELTA), ok( (diff > TIMEOUT - TIMEDELTA) && (diff < TIMEOUT + TIMEDELTA),
"Timedout Wait took %ld ms, expected around %d\n", diff, TIMEOUT); "Timedout Wait took %ld ms, expected around %d\n", diff, TIMEOUT);
...@@ -914,9 +911,8 @@ static void test_LoopbackRead(HANDLE hcom) ...@@ -914,9 +911,8 @@ static void test_LoopbackRead(HANDLE hcom)
} }
while ((read < sizeof(tbuf)) && (i <10)); while ((read < sizeof(tbuf)) && (i <10));
after = GetTickCount(); after = GetTickCount();
ok( read == sizeof(tbuf),"ReadFile read %ld bytes, expected %d\n", read, sizeof(tbuf)); ok( read == sizeof(tbuf),"ReadFile read %ld bytes\n", read);
trace("Plain Read for %d char at %d baud took %ld ms\n", sizeof(tbuf), SLOWBAUD, after-before); trace("Plain Read for %ld char at %d baud took %ld ms\n", read, SLOWBAUD, after-before);
} }
static void test_LoopbackCtsRts(HANDLE hcom) static void test_LoopbackCtsRts(HANDLE hcom)
......
...@@ -895,7 +895,7 @@ static void test_offset_in_overlapped_structure(void) ...@@ -895,7 +895,7 @@ static void test_offset_in_overlapped_structure(void)
{ {
HANDLE hFile; HANDLE hFile;
OVERLAPPED ov; OVERLAPPED ov;
DWORD done; DWORD done, offset;
BOOL rc; BOOL rc;
BYTE buf[256], pattern[] = "TeSt"; BYTE buf[256], pattern[] = "TeSt";
UINT i; UINT i;
...@@ -925,18 +925,16 @@ static void test_offset_in_overlapped_structure(void) ...@@ -925,18 +925,16 @@ static void test_offset_in_overlapped_structure(void)
if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) { if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
ok(rc, "WriteFile error %ld\n", GetLastError()); ok(rc, "WriteFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done); ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/ offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)), ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %ld\n", offset);
"expected file offset %d\n", PATTERN_OFFSET + sizeof(pattern));
S(U(ov)).Offset = sizeof(buf) * 2; S(U(ov)).Offset = sizeof(buf) * 2;
S(U(ov)).OffsetHigh = 0; S(U(ov)).OffsetHigh = 0;
ret = WriteFile(hFile, pattern, sizeof(pattern), &done, &ov); ret = WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
ok( ret, "WriteFile error %ld\n", GetLastError()); ok( ret, "WriteFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done); ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/ offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (sizeof(buf) * 2 + sizeof(pattern)), ok(offset == sizeof(buf) * 2 + sizeof(pattern), "wrong file offset %ld\n", offset);
"expected file offset %d\n", sizeof(buf) * 2 + sizeof(pattern));
} }
CloseHandle(hFile); CloseHandle(hFile);
...@@ -955,9 +953,8 @@ static void test_offset_in_overlapped_structure(void) ...@@ -955,9 +953,8 @@ static void test_offset_in_overlapped_structure(void)
if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) { if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
ok(rc, "ReadFile error %ld\n", GetLastError()); ok(rc, "ReadFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes read %lu\n", done); ok(done == sizeof(pattern), "expected number of bytes read %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/ offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)), ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %ld\n", offset);
"expected file offset %d\n", PATTERN_OFFSET + sizeof(pattern));
ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed\n"); ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed\n");
} }
......
...@@ -106,7 +106,7 @@ static void InitFunctionPointers(void) ...@@ -106,7 +106,7 @@ static void InitFunctionPointers(void)
#define BUFFER_SIZE 128 #define BUFFER_SIZE 128
#define COUNTOF(x) (sizeof(x)/sizeof(x)[0]) #define COUNTOF(x) (sizeof(x)/sizeof(x)[0])
#define EXPECT_LEN(len) ok(ret == (len), "Expected Len %d, got %d\n", (len), ret) #define EXPECT_LEN(len) ok(ret == (len), "Expected Len %d, got %d\n", (int)(len), ret)
#define EXPECT_INVALID ok(GetLastError() == ERROR_INVALID_PARAMETER, \ #define EXPECT_INVALID ok(GetLastError() == ERROR_INVALID_PARAMETER, \
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()) "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError())
#define EXPECT_BUFFER ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, \ #define EXPECT_BUFFER ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, \
...@@ -1545,7 +1545,7 @@ static void test_FoldStringA(void) ...@@ -1545,7 +1545,7 @@ static void test_FoldStringA(void)
static void test_FoldStringW(void) static void test_FoldStringW(void)
{ {
int ret; int ret;
size_t i, j; unsigned int i, j;
WCHAR src[256], dst[256], ch, prev_ch = 1; WCHAR src[256], dst[256], ch, prev_ch = 1;
static const DWORD badFlags[] = static const DWORD badFlags[] =
{ {
......
...@@ -746,18 +746,18 @@ static void test_CreatePipe(void) ...@@ -746,18 +746,18 @@ static void test_CreatePipe(void)
pipe_attr.lpSecurityDescriptor = NULL; pipe_attr.lpSecurityDescriptor = NULL;
ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n"); ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n");
ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n"); ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n");
ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %ld bytes instead of %d\n", written,sizeof(PIPENAME)); ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %ld bytes\n", written);
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from non empty pipe failed\n"); ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from non empty pipe failed\n");
ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %ld bytes instead of %d\n", read, sizeof(PIPENAME)); ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %ld bytes\n", read);
/* Now write another chunk*/ /* Now write another chunk*/
ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n"); ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n");
ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n"); ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n");
ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %ld bytes instead of %d\n", written,sizeof(PIPENAME)); ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %ld bytes\n", written);
/* and close the write end, read should still succeed*/ /* and close the write end, read should still succeed*/
ok(CloseHandle(pipewrite), "CloseHandle for the Write Pipe failed\n"); ok(CloseHandle(pipewrite), "CloseHandle for the Write Pipe failed\n");
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from broken pipe withe with pending data failed\n"); ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from broken pipe withe with pending data failed\n");
ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %ld bytes instead of %d\n", read, sizeof(PIPENAME)); ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %ld bytes\n", read);
/* But now we need to get informed that the pipe is closed */ /* But now we need to get informed that the pipe is closed */
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n"); ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment