https://git.reactos.org/?p=reactos.git;a=commitdiff;h=064dffe6c3c22336c1ab3acb3127af8e91115f25

commit 064dffe6c3c22336c1ab3acb3127af8e91115f25
Author:     Colin Finck <co...@reactos.org>
AuthorDate: Tue Apr 23 11:37:58 2019 +0200
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Fri Apr 26 08:47:15 2019 +0200

    [ROSAUTOTEST] Cache the result of GetLastError().
---
 modules/rostests/rosautotest/CPipe.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/rostests/rosautotest/CPipe.cpp 
b/modules/rostests/rosautotest/CPipe.cpp
index 5af7163971..73e9eda295 100644
--- a/modules/rostests/rosautotest/CPipe.cpp
+++ b/modules/rostests/rosautotest/CPipe.cpp
@@ -169,7 +169,9 @@ CPipe::Read(PVOID Buffer, DWORD NumberOfBytesToRead, PDWORD 
NumberOfBytesRead, D
         // The asynchronous read request could be satisfied immediately.
         return ERROR_SUCCESS;
     }
-    else if (GetLastError() == ERROR_IO_PENDING)
+
+    DWORD dwLastError = GetLastError();
+    if (dwLastError == ERROR_IO_PENDING)
     {
         // The asynchronous read request could not be satisfied immediately, 
so wait for it with the given timeout.
         DWORD dwWaitResult = WaitForSingleObject(m_ReadOverlapped.hEvent, 
TimeoutMilliseconds);
@@ -181,7 +183,9 @@ CPipe::Read(PVOID Buffer, DWORD NumberOfBytesToRead, PDWORD 
NumberOfBytesRead, D
                 // We successfully read NumberOfBytesRead bytes.
                 return ERROR_SUCCESS;
             }
-            else if (GetLastError() == ERROR_BROKEN_PIPE)
+
+            dwLastError = GetLastError();
+            if (dwLastError == ERROR_BROKEN_PIPE)
             {
                 // The other end of the pipe has been closed.
                 return ERROR_BROKEN_PIPE;
@@ -201,7 +205,7 @@ CPipe::Read(PVOID Buffer, DWORD NumberOfBytesToRead, PDWORD 
NumberOfBytesRead, D
     else
     {
         // This may be ERROR_BROKEN_PIPE or an unexpected error.
-        return GetLastError();
+        return dwLastError;
     }
 }
 

Reply via email to