Zhiyi Zhang : winex11.drv: Use length returned from sprintfW().

Alexandre Julliard julliard at winehq.org
Tue Aug 17 16:26:51 CDT 2021


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

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Tue Aug 17 16:41:06 2021 +0800

winex11.drv: Use length returned from sprintfW().

A minor optimization.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c
index b647455a01f..b3ff213ae89 100644
--- a/dlls/winex11.drv/display.c
+++ b/dlls/winex11.drv/display.c
@@ -586,6 +586,7 @@ static BOOL X11DRV_InitMonitor(HDEVINFO devinfo, const struct x11drv_monitor *mo
 {
     SP_DEVINFO_DATA device_data = {sizeof(SP_DEVINFO_DATA)};
     WCHAR bufferW[MAX_PATH];
+    DWORD length;
     HKEY hkey;
     BOOL ret = FALSE;
 
@@ -629,9 +630,9 @@ static BOOL X11DRV_InitMonitor(HDEVINFO devinfo, const struct x11drv_monitor *mo
                                    (const BYTE *)&monitor->rc_work, sizeof(monitor->rc_work), 0))
         goto done;
     /* Adapter name */
-    sprintfW(bufferW, adapter_name_fmtW, video_index + 1);
+    length = sprintfW(bufferW, adapter_name_fmtW, video_index + 1);
     if (!SetupDiSetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, DEVPROP_TYPE_STRING,
-                                   (const BYTE *)bufferW, (strlenW(bufferW) + 1) * sizeof(WCHAR), 0))
+                                   (const BYTE *)bufferW, (length + 1) * sizeof(WCHAR), 0))
         goto done;
 
     ret = TRUE;




More information about the wine-cvs mailing list