[4/4] kernel32: Remove a 0-length read optimization from ReadFile. Resend.
Dmitry Timoshkov
dmitry at baikal.ru
Wed Sep 18 01:55:20 CDT 2013
This matches WriteFile behaviour and ensures that invalid parameters are
properly handled and fields in the OVERLAPPED structure are initialized.
---
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 506b651..7dd65cd 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 baf3368..dfd148c 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 ca0b108..4171504 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 07e82a8..273641d 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 5ae605b..66299ea 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;
--
1.8.3.4
More information about the wine-patches
mailing list