winverbs/winmad: fix GetOverlappedResult return value
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 24 Feb 2009 23:58:21 +0000 (23:58 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 24 Feb 2009 23:58:21 +0000 (23:58 +0000)
The GetOverlappedResults methods are supposed to return an HRESULT, but are returning a BOOL. This makes GetOverlappedResults return WV_SUCCESS when the underlying ::GetOverlappedResults failed.

This patch returns the NTSTATUS results (not the Win32 conversion thereof) so that the WV_STATUS values are returned (since these map to NTSTATUS values.)

Applied similar fix to winmad.  (-SH)

Signed-off-by: Fab Tillier <ftillier@microsoft.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1987 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/winmad/user/wm_provider.cpp
core/winverbs/user/wv_cq.cpp
core/winverbs/user/wv_device.cpp
core/winverbs/user/wv_ep.cpp
core/winverbs/user/wv_qp.cpp
core/winverbs/user/wv_srq.cpp

index 2086af7..fb5efea 100644 (file)
@@ -50,12 +50,9 @@ Init(void)
 {\r
        m_OverlapRead.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);\r
        m_OverlapWrite.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);\r
-       if (m_OverlapRead.hEvent == NULL || m_OverlapWrite.hEvent == NULL)\r
-               return E_OUTOFMEMORY;\r
 \r
-       m_OverlapRead.hEvent = (HANDLE) ((ULONG_PTR) m_OverlapRead.hEvent | 1);\r
-       m_OverlapWrite.hEvent = (HANDLE) ((ULONG_PTR) m_OverlapWrite.hEvent | 1);\r
-       return NOERROR;\r
+       return (m_OverlapRead.hEvent != NULL && m_OverlapWrite.hEvent != NULL) ?\r
+                       NOERROR : E_OUTOFMEMORY;\r
 }\r
 \r
 CWMProvider::~CWMProvider()\r
@@ -115,8 +112,8 @@ STDMETHODIMP CWMProvider::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP_(HANDLE) CWMProvider::\r
@@ -139,7 +136,7 @@ WmDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode,
                                                lpInBuffer, nInBufferSize,\r
                                                lpOutBuffer, nOutBufferSize,\r
                                                lpBytesReturned, &m_OverlapWrite);\r
-               ret = GetOverlappedResult(&m_OverlapWrite, lpBytesReturned, TRUE);\r
+               ret = ::GetOverlappedResult(m_hFile, &m_OverlapWrite, lpBytesReturned, TRUE);\r
                LeaveCriticalSection(&m_CritSecWrite);\r
        } else {\r
                ret = DeviceIoControl(hDevice, dwIoControlCode,\r
index 9ce1d9a..3816efc 100644 (file)
@@ -148,8 +148,8 @@ STDMETHODIMP CWVCompletionQueue::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVCompletionQueue::\r
index 4034ef5..1038be8 100644 (file)
@@ -181,8 +181,8 @@ STDMETHODIMP CWVDevice::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVDevice::\r
index ddf6467..9c0513c 100644 (file)
@@ -125,8 +125,8 @@ STDMETHODIMP CWVConnectEndpoint::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVConnectEndpoint::\r
@@ -473,8 +473,8 @@ STDMETHODIMP CWVDatagramEndpoint::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVDatagramEndpoint::\r
index 5946ac8..e33841a 100644 (file)
@@ -349,8 +349,8 @@ STDMETHODIMP CWVQueuePair::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVQueuePair::\r
@@ -474,8 +474,8 @@ STDMETHODIMP CWVConnectQueuePair::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return CWVQueuePair::\r
-                  GetOverlappedResult(pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVConnectQueuePair::\r
@@ -666,8 +666,8 @@ STDMETHODIMP CWVDatagramQueuePair::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return CWVQueuePair::\r
-                  GetOverlappedResult(pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVDatagramQueuePair::\r
index 32d5ebe..519a75e 100644 (file)
@@ -152,8 +152,8 @@ STDMETHODIMP CWVSharedReceiveQueue::
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return ::GetOverlappedResult(m_hFile, pOverlapped,\r
-                                                                pNumberOfBytesTransferred, bWait);\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
 }\r
 \r
 STDMETHODIMP CWVSharedReceiveQueue::\r