[PATCH v2] ntdll: Finish serial reads of size 0 immediately.

Alex Henrie alexhenrie24 at gmail.com
Sun Feb 21 15:38:32 CST 2016


Cc: Dmitry Timoshkov <dmitry at baikal.ru>

Fixes https://bugs.winehq.org/show_bug.cgi?id=37115

My previous attempt caused the test at dlls/kernel32/tests/comm.c:784
to fail. It looks like we can only take a shortcut if the length is 0
and not in any other case.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/kernel32/tests/comm.c |  4 ----
 dlls/ntdll/file.c          | 11 +++++++----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c
index 97ec794..6b0c3ed 100644
--- a/dlls/kernel32/tests/comm.c
+++ b/dlls/kernel32/tests/comm.c
@@ -2151,13 +2151,9 @@ static void test_read_write(void)
                     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(U(iob).Status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, U(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 3883e5a..2939047 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -826,14 +826,17 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
         goto done;
     }
 
-    if (type == FD_TYPE_FILE)
+    if (type == FD_TYPE_FILE || type == FD_TYPE_SERIAL || type == FD_TYPE_DEVICE)
     {
         if (async_read && (!offset || offset->QuadPart < 0))
         {
             status = STATUS_INVALID_PARAMETER;
             goto done;
         }
+    }
 
+    if (type == FD_TYPE_FILE)
+    {
         if (offset && offset->QuadPart != FILE_USE_FILE_POINTER_POSITION)
         {
             /* async I/O doesn't make sense on regular files */
@@ -854,11 +857,11 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
             goto done;
         }
     }
-    else if (type == FD_TYPE_SERIAL || type == FD_TYPE_DEVICE)
+    else if (type == FD_TYPE_SERIAL)
     {
-        if (async_read && (!offset || offset->QuadPart < 0))
+        if (!length)
         {
-            status = STATUS_INVALID_PARAMETER;
+            status = STATUS_SUCCESS;
             goto done;
         }
     }
-- 
2.7.1




More information about the wine-patches mailing list