[PATCH] dmband: Simplify DllGetClassObject

Michael Stefaniuc mstefani at winehq.org
Fri Oct 25 16:37:30 CDT 2019


On 10/25/19 5:10 AM, Alistair Leslie-Hughes wrote:
> Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> ---
> Remove IID_IClassFactory checks
I see some DLLs do something like this

    *ppv = NULL;
    if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid,
&IID_IClassFactory))
        return E_NOINTERFACE;

The only test I could find for this is in propset_private_tests() in
dlls/dsound/tests/propset.c .
And that seems to confirm the E_NOINTERFACE return.

I doubt this really matters in practice but I want to see if somebody
else has an opinion on this.


bye
	michael



> Cast to a IUnknown pointer.
> 
>  dlls/dmband/dmband_main.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/dlls/dmband/dmband_main.c b/dlls/dmband/dmband_main.c
> index f72b41570b..0a5a5c066e 100644
> --- a/dlls/dmband/dmband_main.c
> +++ b/dlls/dmband/dmband_main.c
> @@ -145,16 +145,16 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
>  {
>      TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
>  
> -	if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
> -                *ppv = &Band_CF;
> -		IClassFactory_AddRef((IClassFactory*)*ppv);
> -		return S_OK;
> -	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
> -                *ppv = &BandTrack_CF;
> -		IClassFactory_AddRef((IClassFactory*)*ppv);
> -		return S_OK;	
> -	}
> -	
> +    if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand))
> +        *ppv = &Band_CF;
> +    else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack))
> +        *ppv = &BandTrack_CF;
> +
> +    if (*ppv) {
> +        IUnknown_AddRef((IUnknown*)*ppv);
> +        return S_OK;
> +    }
> +
>      WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
>      return CLASS_E_CLASSNOTAVAILABLE;
>  }
> 




More information about the wine-devel mailing list