kernel32.dll: implementation of GetVolumePathNamesForVolumeNameA/W

Dmitry Timoshkov dmitry at codeweavers.com
Sun Jul 4 23:44:39 CDT 2010


Tuomo Mattila <tuomom at ee.oulu.fi> wrote:

> +BOOL WINAPI GetVolumePathNamesForVolumeNameA(LPCSTR volumename, LPSTR volumepathname, DWORD buflen, PDWORD returnlen)
> +{
> +
> +    BOOL ret = FALSE;
> +    WCHAR* volumenameW = 0;
> +    LPWSTR volumepathnameW = 0;
> +
> +    if (volumename == 0 || volumepathname == 0 || returnlen == 0)
> +    {
> +        SetLastError(RPC_X_NULL_REF_POINTER);
> +        return FALSE;
> +    }

It's a common practice to use NULL for pointers, and not 0. Something tells
me that RPC_xxxx error code has nothing to do here, do you have a test case
for that?

> +    memset(volumepathname, 0, buflen);

Is there any reason that you zero out the whole 'volumepathname' here?

> +    volumepathnameW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen*sizeof(WCHAR));
> +    if (volumepathnameW == 0) return FALSE;

Same for 'volumepathnameW' here.

> +    if ((volumenameW = FILE_name_AtoW(volumename, TRUE)) == 0) return FALSE;
> +    
> +    ret = GetVolumePathNamesForVolumeNameW(volumenameW, volumepathnameW, buflen, returnlen);
> +    if (*returnlen > 0)
> +        FILE_name_WtoA(volumepathnameW, (*returnlen), volumepathname, (*returnlen));

There is no need to put '*returnlen' in braces. Besides, '*returnlen' may
differ for multibyte and unicode strings.

-- 
Dmitry.



More information about the wine-devel mailing list