From 080d513b885868ab9533a8a8ebcd1a51365f5355 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 10:45:13 +0200 Subject: [PATCH] xwin: fix unitialized variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ../hw/xwin/winclipboard/xevents.c: In function ‘winClipboardSelectionNotifyData.constprop’: > ../hw/xwin/winclipboard/xevents.c:313:23: warning: ‘codepage’ may be used uninitialized in this function [-Wmaybe-uninitialized] > 313 | int iUnicodeLen = MultiByteToWideChar(codepage, 0, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 314 | pszReturnData, -1, NULL, 0); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ../hw/xwin/winclipboard/xevents.c: In function ‘winClipboardFlushXEvents’: > ../hw/xwin/winclipboard/xevents.c:550:35: warning: ‘codepage’ may be used uninitialized in this function [-Wmaybe-uninitialized] > 550 | int iConvertDataLen = WideCharToMultiByte(codepage, 0, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 551 | (LPCWSTR) pszGlobalData, -1, > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 552 | NULL, 0, NULL, NULL); > | ~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xwin/winclipboard/xevents.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c index 41b6d9cbc..6cf4f91c2 100644 --- a/hw/xwin/winclipboard/xevents.c +++ b/hw/xwin/winclipboard/xevents.c @@ -200,7 +200,6 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_ BOOL fSetClipboardData = TRUE; char *pszReturnData = NULL; - UINT codepage; wchar_t *pwszUnicodeStr = NULL; HGLOBAL hGlobal = NULL; char *pszGlobalData = NULL; @@ -275,6 +274,8 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_ xtpText_nitems = nitems; } + UINT codepage = CP_ACP; + if (xtpText_encoding == atoms->atomUTF8String) { pszReturnData = calloc(1, xtpText_nitems + 1); memcpy(pszReturnData, xtpText_value, xtpText_nitems); @@ -412,7 +413,6 @@ winClipboardFlushXEvents(HWND hwnd, { char *xtpText_value = NULL; int xtpText_nitems; - UINT codepage; xcb_selection_request_event_t *selection_request = (xcb_selection_request_event_t *)event; { @@ -535,6 +535,8 @@ winClipboardFlushXEvents(HWND hwnd, } pszGlobalData = (char *) GlobalLock(hGlobal); + UINT codepage = CP_ACP; + /* Convert to target string style */ if (selection_request->target == XCB_ATOM_STRING) { codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1