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

oldstable
Alexandre Julliard 2006-06-13 14:02:31 +02:00
parent e19f31b682
commit c6b342d8ff
5 changed files with 24 additions and 31 deletions

View File

@ -142,7 +142,7 @@ static void test_overlapped_buffers(void)
lstrcpyW((WCHAR *)(buf + 1), strW);
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);
}

View File

@ -765,10 +765,10 @@ static void test_waittxempty(HANDLE hcom)
after = GetTickCount();
ok(res_write == TRUE, "WriteFile failed\n");
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",
after - before, sizeof(tbuf), baud);
trace("WriteFile succeeded, took %ld ms to write %ld Bytes at %ld Baud\n",
after - before, written, baud);
before = GetTickCount();
res = WaitCommEvent(hcom, &evtmask, NULL);
@ -845,8 +845,7 @@ static void test_LoopbackRead(HANDLE hcom)
before = GetTickCount();
ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
after = GetTickCount();
ok(written == sizeof(tbuf),"WriteFile %ld bytes written, expected %d\n",
written, sizeof(tbuf));
ok(written == sizeof(tbuf),"WriteFile %ld bytes written\n", written);
diff = after -before;
/* make sure all bytes are written, so Readfile will succeed in one call*/
@ -859,7 +858,7 @@ static void test_LoopbackRead(HANDLE hcom)
read=0;
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.
As we request more characters then written, we will hit the timeout
@ -876,8 +875,7 @@ static void test_LoopbackRead(HANDLE hcom)
ok(SetCommMask(hcom, EV_RXCHAR), "SetCommMask failed\n");
ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
ok(written == sizeof(tbuf),"WriteFile %ld bytes written, expected %d\n",
written, sizeof(tbuf));
ok(written == sizeof(tbuf),"WriteFile %ld bytes written\n", written);
trace("WaitCommEventEV_RXCHAR\n");
ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n");
@ -888,10 +886,9 @@ static void test_LoopbackRead(HANDLE hcom)
res = ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL);
after = GetTickCount();
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;
trace("Readfile for %d chars with %d avail took %ld ms\n",
sizeof(rbuf), sizeof(tbuf), diff);
trace("Readfile for %ld chars took %ld ms\n", read, diff);
ok( (diff > TIMEOUT - TIMEDELTA) && (diff < TIMEOUT + TIMEDELTA),
"Timedout Wait took %ld ms, expected around %d\n", diff, TIMEOUT);
@ -914,9 +911,8 @@ static void test_LoopbackRead(HANDLE hcom)
}
while ((read < sizeof(tbuf)) && (i <10));
after = GetTickCount();
ok( read == sizeof(tbuf),"ReadFile read %ld bytes, expected %d\n", read, sizeof(tbuf));
trace("Plain Read for %d char at %d baud took %ld ms\n", sizeof(tbuf), SLOWBAUD, after-before);
ok( read == sizeof(tbuf),"ReadFile read %ld bytes\n", read);
trace("Plain Read for %ld char at %d baud took %ld ms\n", read, SLOWBAUD, after-before);
}
static void test_LoopbackCtsRts(HANDLE hcom)

View File

@ -895,7 +895,7 @@ static void test_offset_in_overlapped_structure(void)
{
HANDLE hFile;
OVERLAPPED ov;
DWORD done;
DWORD done, offset;
BOOL rc;
BYTE buf[256], pattern[] = "TeSt";
UINT i;
@ -925,18 +925,16 @@ static void test_offset_in_overlapped_structure(void)
if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
ok(rc, "WriteFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
"expected file offset %d\n", PATTERN_OFFSET + sizeof(pattern));
offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %ld\n", offset);
S(U(ov)).Offset = sizeof(buf) * 2;
S(U(ov)).OffsetHigh = 0;
ret = WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
ok( ret, "WriteFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (sizeof(buf) * 2 + sizeof(pattern)),
"expected file offset %d\n", sizeof(buf) * 2 + sizeof(pattern));
offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
ok(offset == sizeof(buf) * 2 + sizeof(pattern), "wrong file offset %ld\n", offset);
}
CloseHandle(hFile);
@ -955,9 +953,8 @@ static void test_offset_in_overlapped_structure(void)
if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
ok(rc, "ReadFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes read %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
"expected file offset %d\n", PATTERN_OFFSET + sizeof(pattern));
offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %ld\n", offset);
ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed\n");
}

View File

@ -106,7 +106,7 @@ static void InitFunctionPointers(void)
#define BUFFER_SIZE 128
#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, \
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError())
#define EXPECT_BUFFER ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, \
@ -1545,7 +1545,7 @@ static void test_FoldStringA(void)
static void test_FoldStringW(void)
{
int ret;
size_t i, j;
unsigned int i, j;
WCHAR src[256], dst[256], ch, prev_ch = 1;
static const DWORD badFlags[] =
{

View File

@ -746,18 +746,18 @@ static void test_CreatePipe(void)
pipe_attr.lpSecurityDescriptor = NULL;
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(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(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*/
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(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*/
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(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 */
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
}