dlls/userenv: fixed stubs GetUserProfileDirectoryW/A (2nd try)

Vitaliy Margolen wine-devel at kievinfo.com
Thu Mar 5 15:36:03 CST 2009


Andreas Rosenberg wrote:
> According to MSDN the error codes are not part of the API documentation:
> 
> "The error codes returned by a function are not part of the Windows API

But they are. MS just made their obligation to document all of their craft
that much easer and that much more undefined. According to this logic
"Error!" is the only message you need for anything that happened wrong.

Whenever someone implements a missing part of Wine, conformance tests that
verify normal behavior really help. Checking border cases are not required
unless you have a real life application that depends on such a corner case.

To apply it all here - no need to test for all possible errors in
conformance tests. However you should test it yourself and use correct error
codes where appropriate.

As far as your code goes:

+    r = GetUserProfileDirectoryW(htoken , NULL, NULL );
+    lastError = GetLastError();
+    expect(FALSE, r);
+    expect(lastError, ERROR_INVALID_PARAMETER);
You still have to reset last error before checking it.

+    SetLastError(0xDEADAFFE);
Please use more often used in Wine 0xdeadbeef.

+    expect(sizeExpected,lstrlenW(buffer)+1);
Here and everywhere else - add space after coma.

+    r = GetUserProfileDirectoryW(htoken , NULL, NULL );
Either put space after on both sides or not at all ex:
function( a ); or function(a);

+++ b/dlls/userenv/userenv_main.c
+static WCHAR const profile_pathname[49] = {
Qualifier goes before type - it's "static const WCHAR".
Don't need to explicitly specify size.

+    if (lpcchSize && lpProfileDir) {
+        wBufLen = *lpcchSize;
+        bufW = HeapAlloc(GetProcessHeap(),0,wBufLen * sizeof(WCHAR));
+    }
+    else { /* We need this to get the buffer size */
Here and everywhere else curly brackets go on their separate line (style
already set for this file you have to maintain it).

+    if ( bufW )
+        HeapFree(GetProcessHeap(),0,bufW);
+    }
No need to check pointer for != NULL before freeing it.

+            res = GetUserNameW(&(userName[0]),&sizeName);
Why not just "userName"?

+                    lstrcatW(lpProfileDir,(LPWSTR)&(L"\\"));
L"" syntax for WCHAR strings is not allowed in Wine. Define it as static
const WCHAR aray.


Vitaliy.



More information about the wine-devel mailing list