fusion: Use proper function pointer

Andrew Talbot Andrew.Talbot at talbotville.com
Sun Aug 3 07:15:28 CDT 2008


James Hawkins wrote:

> On Sat, Aug 2, 2008 at 4:09 PM, Andrew Talbot
> <andrew.talbot at talbotville.com> wrote:
>> Changelog:
>>    fusion: Use proper function pointer.
>>
>> diff --git a/dlls/fusion/fusion.c b/dlls/fusion/fusion.c
>> index ac01cf4..637346c 100644
>> --- a/dlls/fusion/fusion.c
>> +++ b/dlls/fusion/fusion.c
>> @@ -32,6 +32,9 @@
>>
>>  WINE_DEFAULT_DEBUG_CHANNEL(fusion);
>>
>> +typedef HRESULT (WINAPI *PFNGETCORVERSION)(LPWSTR pbuffer, DWORD
>> cchBuffer,
>> +                                           DWORD *dwLength);
>> +
>>  /******************************************************************
>>  *  ClearDownloadCache   (FUSION.@)
>>  */
>> @@ -89,20 +92,18 @@ HRESULT WINAPI GetAssemblyIdentityFromFile(LPCWSTR
>> pwzFilePath, REFIID riid,
>>     return E_NOTIMPL;
>>  }
>>
>> -static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
>> -                                        DWORD *dwLength);
>> -
> 
> There's nothing wrong with this.  We use this type of function pointer
> all over the code base.
> 

Hi James,

I think the part of my patch you have copied excludes the crucial bit (please excuse the line-wrapping).

-    pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
+    pGetCORVersion = (PFNGETCORVERSION)GetProcAddress(hmscoree, "GetCORVersion");

The thing that I would argue is wrong is that we are using an object pointer

    (void*)

in place of a function pointer

    <return type> (*)(<args>)

Granted there are probably around two thousand other instances like this in the dlls, and some may argue that it works, so leave it. On the other hand, there are also quite a lot of type definitions for *PFN...s and several MAKE_FUNCPTR() macros around, too.

I seem to remember that someone tried to compile Wine with Visual Studio or suchlike, recently, and had to suppress warnings about using object pointers instead of function pointers (amongst other things).

Anyway, I just fly the odd flag in good faith, occasionally, and see whether it gets saluted or shot down. :)

Thanks and kind regards,

-- 
Andy.





More information about the wine-devel mailing list