From b4ab43b3de134d2816393ba7f23f67bfc36bd33f Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 18 Sep 2013 15:55:20 +0900 Subject: [PATCH] kernel32: Remove a 0-length read optimization from ReadFile. --- dlls/kernel32/file.c | 1 - dlls/kernel32/tests/comm.c | 1 - dlls/kernel32/tests/mailslot.c | 3 --- dlls/kernel32/tests/pipe.c | 9 +++------ dlls/ntdll/tests/file.c | 5 ----- 5 files changed, 3 insertions(+), 16 deletions(-) diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index 506b651920b..7dd65cdae8c 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -408,7 +408,6 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead, bytesRead, overlapped ); if (bytesRead) *bytesRead = 0; /* Do this before anything else */ - if (!bytesToRead) return TRUE; if (is_console_handle(hFile)) { diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c index baf3368b2d1..dfd148c5695 100644 --- a/dlls/kernel32/tests/comm.c +++ b/dlls/kernel32/tests/comm.c @@ -2152,7 +2152,6 @@ todo_wine bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(hcom, buf, 0, &bytes, NULL); -todo_wine ok(!ret, "ReadFile should fail\n"); todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); diff --git a/dlls/kernel32/tests/mailslot.c b/dlls/kernel32/tests/mailslot.c index ca0b1088bdc..4171504960b 100644 --- a/dlls/kernel32/tests/mailslot.c +++ b/dlls/kernel32/tests/mailslot.c @@ -80,16 +80,13 @@ static int mailslot_test(void) count = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(INVALID_HANDLE_VALUE, buffer, 0, &count, NULL); -todo_wine ok(!ret, "ReadFile should fail\n"); -todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError()); ok(count == 0, "expected 0, got %u\n", count); count = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(hSlot, buffer, 0, &count, NULL); -todo_wine ok(!ret, "ReadFile should fail\n"); todo_wine ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError()); diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 07e82a8c582..273641de49b 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -1860,9 +1860,7 @@ static void test_readfileex_pending(void) num_bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(INVALID_HANDLE_VALUE, read_buf, 0, &num_bytes, NULL); -todo_wine ok(!ret, "ReadFile should fail\n"); -todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError()); ok(num_bytes == 0, "expected 0, got %u\n", num_bytes); @@ -1877,12 +1875,11 @@ todo_wine todo_wine ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); ok(num_bytes == 0, "bytes %u\n", num_bytes); -todo_wine ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %#lx\n", overlapped.Internal); +todo_wine ok(overlapped.InternalHigh == -1, "expected -1, got %lu\n", overlapped.InternalHigh); wait = WaitForSingleObject(event, 100); -todo_wine ok(wait == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", wait); num_bytes = 0xdeadbeef; @@ -1890,13 +1887,13 @@ todo_wine ok(ret, "WriteFile failed\n"); ok(num_bytes == 1, "bytes %u\n", num_bytes); - wait = WaitForSingleObject(event, 0); + wait = WaitForSingleObject(event, 100); +todo_wine ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", wait); ok(num_bytes == 1, "bytes %u\n", num_bytes); todo_wine ok((NTSTATUS)overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", overlapped.Internal); -todo_wine ok(overlapped.InternalHigh == 0, "expected 0, got %lu\n", overlapped.InternalHigh); /* read the pending byte and clear the pipe */ diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 5ae605b18eb..66299ea9103 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -1986,9 +1986,7 @@ static void test_read_write(void) bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(INVALID_HANDLE_VALUE, buf, 0, &bytes, NULL); -todo_wine ok(!ret, "ReadFile should fail\n"); -todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); ok(bytes == 0, "bytes %u\n", bytes); @@ -2201,9 +2199,7 @@ todo_wine bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(INVALID_HANDLE_VALUE, buf, 0, &bytes, NULL); -todo_wine ok(!ret, "ReadFile should fail\n"); -todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); ok(bytes == 0, "bytes %u\n", bytes); @@ -2220,7 +2216,6 @@ todo_wine ok(bytes == 0, "bytes %u\n", bytes); todo_wine ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal); -todo_wine ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh); bytes = 0xdeadbeef;