[6/6] ntdll: Make NtReadFile always initialize a being returned IO_STATUS_BLOCK.

Dmitry Timoshkov dmitry at baikal.ru
Mon Sep 2 04:33:10 CDT 2013


---
 dlls/ntdll/file.c       | 11 ++++++-----
 dlls/ntdll/tests/file.c | 13 ++++---------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 6046771..9e6586f 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -601,7 +601,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
     if (!virtual_check_buffer_for_write( buffer, length ))
     {
         status = STATUS_ACCESS_VIOLATION;
-        goto done;
+        goto err;
     }
 
     if (type == FD_TYPE_FILE)
@@ -609,7 +609,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
         if (!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) && (!offset || offset->QuadPart < 0))
         {
             status = STATUS_INVALID_PARAMETER;
-            goto done;
+            goto err;
         }
 
         if (offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
@@ -655,7 +655,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
                     break;
                 default:
                     status = STATUS_PIPE_BROKEN;
-                    goto done;
+                    goto err;
                 }
             }
             else if (type == FD_TYPE_FILE) continue;  /* no async I/O on regular files */
@@ -747,12 +747,13 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
 done:
     send_completion = cvalue != 0;
 
+    io_status->u.Status = status;
+    io_status->Information = total;
+
 err:
     if (needs_close) close( unix_handle );
     if (status == STATUS_SUCCESS)
     {
-        io_status->u.Status = status;
-        io_status->Information = total;
         TRACE("= SUCCESS (%u)\n", total);
         if (hEvent) NtSetEvent( hEvent, NULL );
         if (apc) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc,
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index c802432..8cb64bc 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -837,9 +837,10 @@ todo_wine
     ResetEvent( event );
     status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL );
     ok( status == STATUS_END_OF_FILE, "wrong status %x\n", status );
-    todo_wine ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
-    todo_wine ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
-    todo_wine ok( is_signaled( event ), "event is not signaled\n" );
+    ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
+    ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
+todo_wine
+    ok( is_signaled( event ), "event is not signaled\n" );
     ok( !apc_count, "apc was called\n" );
     SleepEx( 1, TRUE ); /* alertable sleep */
     ok( !apc_count, "apc was called\n" );
@@ -2017,9 +2018,7 @@ static void test_read_write(void)
     iob.Information = -1;
     status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
     ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
 
     iob.Status = -1;
@@ -2027,9 +2026,7 @@ todo_wine
     offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
     status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
     ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
 
     SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
@@ -2045,9 +2042,7 @@ todo_wine
     iob.Information = -1;
     status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
     ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
 
     iob.Status = -1;
-- 
1.8.3.4




More information about the wine-patches mailing list