[PATCH v2 2/5] user32: Use user_driver_funcs to expose user driver function from drivers.

Jacek Caban jacek at codeweavers.com
Thu Nov 11 06:30:55 CST 2021


On 11/11/21 9:44 AM, Huw Davies wrote:
> On Wed, Nov 10, 2021 at 01:33:32PM +0100, Jacek Caban wrote:
>> diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
>> index 7b51823014d..ed7cc5c72ba 100644
>> --- a/dlls/user32/driver.c
>> +++ b/dlls/user32/driver.c
>> @@ -59,9 +59,16 @@ static BOOL load_desktop_driver( HWND hwnd, HMODULE *module )
>>       size = sizeof(path);
>>       if (!RegQueryValueExW( hkey, L"GraphicsDriver", NULL, NULL, (BYTE *)path, &size ))
>>       {
>> -        if ((ret = !wcscmp( path, L"null" ))) *module = NULL;
>> -        else ret = (*module = LoadLibraryW( path )) != NULL;
>> -        if (!ret) ERR( "failed to load %s\n", debugstr_w(path) );
>> +        if (wcscmp( path, L"null" ))
>> +        {
>> +            ret = LoadLibraryW( path ) != NULL;
>> +            if (!ret) ERR( "failed to load %s\n", debugstr_w(path) );
>> +        }
>> +        else
>> +        {
>> +            __wine_set_user_driver( &null_driver, WINE_GDI_DRIVER_VERSION );
>> +            ret = TRUE;
>> +        }
>>           TRACE( "%s %p\n", debugstr_w(path), *module );
> This doesn't look quite right as "module" is now unused (I realise it's
> eliminated in the next patch, but it would be nice to have this patch
> make sense too).
>
> This leads to:
> i686-w64-mingw32-gcc -c -o dlls/user32/driver.cross.o dlls/user32/driver.c -Idlls/user32 -Iinclude -Iinclude/msvcrt -I./libs/png \
>    -D__WINESRC__ -D_USER32_ -D_WINABLE_ -D_UCRT -D__WINE_PE_BUILD -Wall -fno-strict-aliasing \
>    -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self \
>    -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \
>    -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -Wabsolute-value \
>    -fno-omit-frame-pointer -gdwarf-2 -gstrict-dwarf -g -O2
> In file included from dlls/user32/driver.c:27:
> dlls/user32/driver.c: In function ‘load_driver’:
> include/wine/debug.h:89:5: warning: ‘module’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>     89 |     wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0)
>        |     ^~~~~~~~~~~~
>
>> diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c
>> index 3148e28afdd..db5cd1b8810 100644
>> --- a/dlls/winemac.drv/gdi.c
>> +++ b/dlls/winemac.drv/gdi.c
>> @@ -57,7 +57,7 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
>>   static CRITICAL_SECTION device_data_section = { &critsect_debug, -1, 0, 0, 0, 0 };
>>
>>   
>> -static const struct gdi_dc_funcs macdrv_funcs;
>> +static const struct user_driver_funcs macdrv_funcs;
>>   
>>   /***********************************************************************
>>    *              compute_desktop_rect
>> @@ -184,7 +184,7 @@ static BOOL CDECL macdrv_CreateDC(PHYSDEV *pdev, LPCWSTR device, LPCWSTR output,
>>   
>>       if (!physDev) return FALSE;
>>   
>> -    push_dc_driver(pdev, &physDev->dev, &macdrv_funcs);
>> +    push_dc_driver(pdev, &physDev->dev, &macdrv_funcs.dc_funcs);
>>       return TRUE;
>>   }
>>   
>> @@ -201,7 +201,7 @@ static BOOL CDECL macdrv_CreateCompatibleDC(PHYSDEV orig, PHYSDEV *pdev)
>>   
>>       if (!physDev) return FALSE;
>>   
>> -    push_dc_driver(pdev, &physDev->dev, &macdrv_funcs);
>> +    push_dc_driver(pdev, &physDev->dev, &macdrv_funcs.dc_funcs);
>>       return TRUE;
>>   }
> You forgot to change macdrv_get_gdi_driver() to avoid this:
>
> gcc -m32 -c -o dlls/winemac.drv/gdi.o dlls/winemac.drv/gdi.c -Idlls/winemac.drv -Iinclude -D__WINESRC__ -fPIC \
>    -fasynchronous-unwind-tables -Wall -pipe -fno-stack-protector -fno-strict-aliasing \
>    -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self -Wno-pragma-pack \
>    -Wstrict-prototypes -Wtype-limits -Wvla -Wwrite-strings -Wpointer-arith -gdwarf-2 -gstrict-dwarf \
>    -fno-omit-frame-pointer -O2 -g -Wno-deprecated-declarations -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
> dlls/winemac.drv/gdi.c:324:12: warning: incompatible pointer types returning 'const struct user_driver_funcs *' from a
>        function with result type 'const struct gdi_dc_funcs *' [-Wincompatible-pointer-types]
>      return &macdrv_funcs;
>
> (I'd have fixed this up myself, if that had been the only issue).


I messed merging mac changes, sorry about that. I sent v3 with mac and 
uninitialized module fixes.


Thanks,

Jacek




More information about the wine-devel mailing list