[1/2] ntdll: Properly handle 0-length reads. Resend.

Dmitry Timoshkov dmitry at baikal.ru
Fri Sep 13 02:12:34 CDT 2013


This matches what NtWriteFile does.

I assume that this patch is in 'pending' state because of a test failure caused
by 2/2, if the reason is different - please let me know.
---
 dlls/kernel32/tests/comm.c | 6 ------
 dlls/ntdll/file.c          | 8 +++++++-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c
index baf3368..9261b61 100644
--- a/dlls/kernel32/tests/comm.c
+++ b/dlls/kernel32/tests/comm.c
@@ -2163,8 +2163,6 @@ todo_wine
                 status = pNtReadFile(hcom, 0, NULL, NULL, &iob, buf, 0, NULL, NULL);
 todo_wine
                 ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
-                /* FIXME: Remove once Wine is fixed */
-                if (status == STATUS_PENDING) WaitForSingleObject(hcom, TIMEOUT);
 todo_wine
                 ok(iob.Status == -1, "expected -1, got %#x\n", iob.Status);
 todo_wine
@@ -2176,13 +2174,9 @@ todo_wine
                     iob.Information = -1;
                     offset.QuadPart = (LONGLONG)i;
                     status = pNtReadFile(hcom, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
-                    /* FIXME: Remove once Wine is fixed */
-                    if (status == STATUS_PENDING) WaitForSingleObject(hcom, TIMEOUT);
                     if (i >= 0)
                     {
-todo_wine
                         ok(status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, status);
-todo_wine
                         ok(iob.Status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, iob.Status);
                         ok(iob.Information == 0, "%d: expected 0, got %lu\n", i, iob.Information);
                     }
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 15e8829..efb07b3 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -638,7 +638,13 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
         if ((result = read( unix_handle, (char *)buffer + total, length - total )) >= 0)
         {
             total += result;
-            if (!result || total == length)
+            if (total == length)
+            {
+                status = STATUS_SUCCESS;
+                goto done;
+            }
+
+            if (!result)
             {
                 if (total)
                 {
-- 
1.8.3.4




More information about the wine-patches mailing list