Andrew Nguyen : kernel32: Don't set last error on success in OpenConsoleW.

Alexandre Julliard julliard at winehq.org
Thu Apr 1 11:25:04 CDT 2010


Module: wine
Branch: master
Commit: 39208d4d6062c5e0b690b1fae706e1928ae8633a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=39208d4d6062c5e0b690b1fae706e1928ae8633a

Author: Andrew Nguyen <arethusa26 at gmail.com>
Date:   Wed Mar 31 18:54:07 2010 -0600

kernel32: Don't set last error on success in OpenConsoleW.

---

 dlls/kernel32/console.c       |    1 -
 dlls/kernel32/tests/console.c |   19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index a5a6607..f682ca1 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -307,7 +307,6 @@ HANDLE WINAPI OpenConsoleW(LPCWSTR name, DWORD access, BOOL inherit, DWORD creat
         req->access     = access;
         req->attributes = inherit ? OBJ_INHERIT : 0;
         req->share      = FILE_SHARE_READ | FILE_SHARE_WRITE;
-        SetLastError(0);
         wine_server_call_err( req );
         ret = wine_server_ptr_handle( reply->handle );
     }
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 43017c1..3d8ae93 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -1062,6 +1062,25 @@ static void test_OpenConsoleW(void)
            "Expected GetLastError() to return %u for index %d, got %u\n",
            invalid_table[index].gle, index, GetLastError());
     }
+
+    /* OpenConsoleW should not touch the last error on success. */
+    SetLastError(0xdeadbeef);
+    ret = pOpenConsoleW(coninW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_EXISTING);
+    ok(ret != INVALID_HANDLE_VALUE,
+       "Expected OpenConsoleW to return a valid handle\n");
+    ok(GetLastError() == 0xdeadbeef,
+       "Expected the last error to be untouched, got %u\n", GetLastError());
+    if (ret != INVALID_HANDLE_VALUE)
+        CloseHandle(ret);
+
+    SetLastError(0xdeadbeef);
+    ret = pOpenConsoleW(conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_EXISTING);
+    ok(ret != INVALID_HANDLE_VALUE,
+       "Expected OpenConsoleW to return a valid handle\n");
+    ok(GetLastError() == 0xdeadbeef,
+       "Expected the last error to be untouched, got %u\n", GetLastError());
+    if (ret != INVALID_HANDLE_VALUE)
+        CloseHandle(ret);
 }
 
 START_TEST(console)




More information about the wine-cvs mailing list