Jacek Caban : winex11: Avoid using sprintfW.

Alexandre Julliard julliard at winehq.org
Wed May 4 16:14:45 CDT 2022


Module: wine
Branch: master
Commit: 30d5a04f6d8dd74c2a390e3bf9569ad6d5b9c01c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=30d5a04f6d8dd74c2a390e3bf9569ad6d5b9c01c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon May  2 00:43:14 2022 +0200

winex11: Avoid using sprintfW.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/mouse.c    | 8 ++++++--
 dlls/winex11.drv/settings.c | 6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 3d68dc80b3e..7133f2e2694 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -1053,7 +1053,6 @@ static int find_fallback_shape( const char *name )
  */
 static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
 {
-    static const WCHAR idW[] = {'%','h','u',0};
     const struct system_cursors *cursors;
     unsigned int i;
     Cursor cursor = 0;
@@ -1070,7 +1069,12 @@ static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
     p = name + strlenW( name );
     *p++ = ',';
     if (info->szResName[0]) strcpyW( p, info->szResName );
-    else sprintfW( p, idW, info->wResID );
+    else
+    {
+        char buf[16];
+        sprintf( buf, "%hu", info->wResID );
+        asciiz_to_unicode( p, buf );
+    }
     valueA[0] = 0;
 
     /* @@ Wine registry key: HKCU\Software\Wine\X11 Driver\Cursors */
diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c
index 44c61776b4b..1e8868acc6c 100644
--- a/dlls/winex11.drv/settings.c
+++ b/dlls/winex11.drv/settings.c
@@ -217,8 +217,6 @@ void init_registry_display_settings(void)
 static HKEY get_display_device_reg_key( const WCHAR *device_name )
 {
     static const WCHAR display[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y'};
-    static const WCHAR video_value_fmt[] = {'\\','D','e','v','i','c','e','\\',
-                                            'V','i','d','e','o','%','d',0};
     static const WCHAR video_key[] = {
         '\\','R','e','g','i','s','t','r','y',
         '\\','M','a','c','h','i','n','e',
@@ -235,6 +233,7 @@ static HKEY get_display_device_reg_key( const WCHAR *device_name )
     WCHAR value_name[MAX_PATH], buffer[4096], *end_ptr;
     KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer;
     DWORD adapter_index, size;
+    char adapter_name[100];
     HKEY hkey;
 
     /* Device name has to be \\.\DISPLAY%d */
@@ -248,7 +247,8 @@ static HKEY get_display_device_reg_key( const WCHAR *device_name )
 
     /* Open \Device\Video* in HKLM\HARDWARE\DEVICEMAP\VIDEO\ */
     if (!(hkey = reg_open_key( NULL, video_key, sizeof(video_key) ))) return FALSE;
-    sprintfW(value_name, video_value_fmt, adapter_index);
+    sprintf( adapter_name, "\\Device\\Video%d", adapter_index );
+    asciiz_to_unicode( value_name, adapter_name );
     size = query_reg_value( hkey, value_name, value, sizeof(buffer) );
     NtClose( hkey );
     if (!size || value->Type != REG_SZ) return FALSE;




More information about the wine-cvs mailing list