[v2 PATCH 2/4] oledb32: IErrorRecords uses 0-based index to access record info

Nikolay Sivov nsivov at codeweavers.com
Tue Nov 15 11:26:48 CST 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

v2: fixed test trace

 dlls/oledb32/errorinfo.c      | 26 ++++++++++++--------------
 dlls/oledb32/tests/database.c | 21 +++++++++++++++++++--
 2 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/dlls/oledb32/errorinfo.c b/dlls/oledb32/errorinfo.c
index 0875d82..7a1eddf 100644
--- a/dlls/oledb32/errorinfo.c
+++ b/dlls/oledb32/errorinfo.c
@@ -267,67 +267,65 @@ static HRESULT WINAPI errorrec_AddErrorRecord(IErrorRecords *iface, ERRORINFO *p
     return S_OK;
 }
 
-static HRESULT WINAPI errorrec_GetBasicErrorInfo(IErrorRecords *iface, ULONG ulRecordNum,
-        ERRORINFO *pErrorInfo)
+static HRESULT WINAPI errorrec_GetBasicErrorInfo(IErrorRecords *iface, ULONG index, ERRORINFO *pErrorInfo)
 {
     ErrorInfoImpl *This = impl_from_IErrorRecords(iface);
 
-    FIXME("(%p)->(%d %p)\n", This, ulRecordNum, pErrorInfo);
+    FIXME("(%p)->(%u %p)\n", This, index, pErrorInfo);
 
     if(!pErrorInfo)
         return E_INVALIDARG;
 
-    if(ulRecordNum > This->count)
+    if (index >= This->count)
         return DB_E_BADRECORDNUM;
 
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI errorrec_GetCustomErrorObject(IErrorRecords *iface, ULONG ulRecordNum,
+static HRESULT WINAPI errorrec_GetCustomErrorObject(IErrorRecords *iface, ULONG index,
         REFIID riid, IUnknown **ppObject)
 {
     ErrorInfoImpl *This = impl_from_IErrorRecords(iface);
 
-    FIXME("(%p)->(%d %s, %p)\n", This, ulRecordNum, debugstr_guid(riid), ppObject);
+    FIXME("(%p)->(%u %s, %p)\n", This, index, debugstr_guid(riid), ppObject);
 
     if (!ppObject)
         return E_INVALIDARG;
 
     *ppObject = NULL;
 
-    if(ulRecordNum > This->count)
+    if (index >= This->count)
         return DB_E_BADRECORDNUM;
 
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI errorrec_GetErrorInfo(IErrorRecords *iface, ULONG ulRecordNum,
+static HRESULT WINAPI errorrec_GetErrorInfo(IErrorRecords *iface, ULONG index,
         LCID lcid, IErrorInfo **ppErrorInfo)
 {
     ErrorInfoImpl *This = impl_from_IErrorRecords(iface);
 
-    FIXME("(%p)->(%d %d, %p)\n", This, ulRecordNum, lcid, ppErrorInfo);
+    FIXME("(%p)->(%u %d, %p)\n", This, index, lcid, ppErrorInfo);
 
     if (!ppErrorInfo)
         return E_INVALIDARG;
 
-    if(ulRecordNum > This->count)
+    if (index >= This->count)
         return DB_E_BADRECORDNUM;
 
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI errorrec_GetErrorParameters(IErrorRecords *iface, ULONG ulRecordNum,
-        DISPPARAMS *pdispparams)
+static HRESULT WINAPI errorrec_GetErrorParameters(IErrorRecords *iface, ULONG index, DISPPARAMS *pdispparams)
 {
     ErrorInfoImpl *This = impl_from_IErrorRecords(iface);
 
-    FIXME("(%p)->(%d %p)\n", This, ulRecordNum, pdispparams);
+    FIXME("(%p)->(%u %p)\n", This, index, pdispparams);
 
     if (!pdispparams)
         return E_INVALIDARG;
 
-    if(ulRecordNum > This->count)
+    if (index >= This->count)
         return DB_E_BADRECORDNUM;
 
     return E_NOTIMPL;
diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c
index 217fb4a..68f9eac 100644
--- a/dlls/oledb32/tests/database.c
+++ b/dlls/oledb32/tests/database.c
@@ -318,9 +318,10 @@ static void test_errorinfo(void)
 {
     ICreateErrorInfo *createerror;
     ERRORINFO info, info2, info3;
-    IErrorInfo *errorinfo;
+    IErrorInfo *errorinfo, *errorinfo2;
     IErrorRecords *errrecs;
-    IUnknown *unk = NULL;
+    IUnknown *unk = NULL, *unk2;
+    DISPPARAMS dispparams;
     DWORD context;
     ULONG cnt = 0;
     HRESULT hr;
@@ -381,6 +382,22 @@ static void test_errorinfo(void)
     hr = IUnknown_QueryInterface(unk, &IID_IErrorRecords, (void**)&errrecs);
     ok(hr == S_OK, "got %08x\n", hr);
 
+    hr = IErrorRecords_GetRecordCount(errrecs, &cnt);
+    ok(hr == S_OK, "got %08x\n", hr);
+    ok(cnt == 0, "Got unexpected record count %u\n", cnt);
+
+    hr = IErrorRecords_GetBasicErrorInfo(errrecs, 0, &info3);
+    ok(hr == DB_E_BADRECORDNUM, "got %08x\n", hr);
+
+    hr = IErrorRecords_GetCustomErrorObject(errrecs, 0, &IID_IUnknown, &unk2);
+    ok(hr == DB_E_BADRECORDNUM, "got %08x\n", hr);
+
+    hr = IErrorRecords_GetErrorInfo(errrecs, 0, 0, &errorinfo2);
+    ok(hr == DB_E_BADRECORDNUM, "got %08x\n", hr);
+
+    hr = IErrorRecords_GetErrorParameters(errrecs, 0, &dispparams);
+    ok(hr == DB_E_BADRECORDNUM, "got %08x\n", hr);
+
     memset(&info, 0, sizeof(ERRORINFO));
     info.dwMinor = 1;
     memset(&info2, 0, sizeof(ERRORINFO));
-- 
2.10.2




More information about the wine-patches mailing list