Skip to content
Snippets Groups Projects
Commit 1b8f8bac authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix a couple interesting-looking MSVC warnings.

parent 62d75f50
No related branches found
No related tags found
No related merge requests found
Pipeline #6801 failed
...@@ -91,11 +91,13 @@ utf8_to_utf16(const uint8_t *str8, int buflen) ...@@ -91,11 +91,13 @@ utf8_to_utf16(const uint8_t *str8, int buflen)
if (sz == 0) if (sz == 0)
return NULL; return NULL;
ret = (LPWSTR)malloc((sz + 1) * sizeof(*ret)); ret = (LPWSTR)malloc((sz + 1) * sizeof(*ret));
if (ret != NULL) {
if (sz == MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, (LPCCH)str8, buflen, (LPWSTR)ret, sz)) { if (sz == MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, (LPCCH)str8, buflen, (LPWSTR)ret, sz)) {
ret[sz] = 0; ret[sz] = 0;
return ret; return ret;
} }
free(ret); free(ret);
}
return NULL; return NULL;
} }
...@@ -170,6 +172,8 @@ gdi_add_key(uint16_t key) ...@@ -170,6 +172,8 @@ gdi_add_key(uint16_t key)
lwch = wch; lwch = wch;
if (lwch != NULL) if (lwch != NULL)
WriteFile(lwch, bp, remain, &added, NULL); WriteFile(lwch, bp, remain, &added, NULL);
else
added = remain;
remain -= added; remain -= added;
bp += added; bp += added;
} while (remain > 0); } while (remain > 0);
...@@ -276,7 +280,6 @@ gdi_handle_wm_sizing(WPARAM wParam, RECT *r) ...@@ -276,7 +280,6 @@ gdi_handle_wm_sizing(WPARAM wParam, RECT *r)
{ {
int ow, oh, nw, nh; int ow, oh, nw, nh;
double s; double s;
RECT tr = *r;
ow = r->right - r->left; ow = r->right - r->left;
oh = r->bottom - r->top; oh = r->bottom - r->top;
...@@ -569,7 +572,13 @@ get_monitor_size_pos(int *w, int *h, int *xpos, int *ypos) ...@@ -569,7 +572,13 @@ get_monitor_size_pos(int *w, int *h, int *xpos, int *ypos)
if (!primary && win == NULL) if (!primary && win == NULL)
primary = true; primary = true;
if (win == NULL) {
const POINT origin = {0};
mon = MonitorFromPoint(origin, MONITOR_DEFAULTTOPRIMARY);
}
else {
mon = MonitorFromWindow(win, primary ? MONITOR_DEFAULTTOPRIMARY : MONITOR_DEFAULTTONEAREST); mon = MonitorFromWindow(win, primary ? MONITOR_DEFAULTTOPRIMARY : MONITOR_DEFAULTTONEAREST);
}
if (mon) { if (mon) {
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
ret = GetMonitorInfoW(mon, &mi); ret = GetMonitorInfoW(mon, &mi);
...@@ -864,7 +873,9 @@ magic_message(MSG msg) ...@@ -864,7 +873,9 @@ magic_message(MSG msg)
if (hm) { if (hm) {
MONITORINFO mi = {sizeof(mi)}; MONITORINFO mi = {sizeof(mi)};
if (GetMonitorInfo(hm, &mi)) { if (GetMonitorInfo(hm, &mi)) {
WINDOWINFO wi; WINDOWINFO wi = {
.cbSize = sizeof(WINDOWINFO);
};
if (GetWindowInfo(win, &wi)) { if (GetWindowInfo(win, &wi)) {
window_left = wi.rcWindow.left; window_left = wi.rcWindow.left;
window_top = wi.rcWindow.top; window_top = wi.rcWindow.top;
...@@ -1157,10 +1168,15 @@ gdi_copytext(const char *text, size_t buflen) ...@@ -1157,10 +1168,15 @@ gdi_copytext(const char *text, size_t buflen)
clipBuf = GlobalAlloc(GMEM_MOVEABLE, (wcslen(utf16) + 1) * sizeof(utf16[0])); clipBuf = GlobalAlloc(GMEM_MOVEABLE, (wcslen(utf16) + 1) * sizeof(utf16[0]));
if (clipBuf != NULL) { if (clipBuf != NULL) {
clipStr = GlobalLock(clipBuf); clipStr = GlobalLock(clipBuf);
if (clipStr != NULL) {
wcscpy(clipStr, utf16); wcscpy(clipStr, utf16);
GlobalUnlock(clipBuf); GlobalUnlock(clipBuf);
SetClipboardData(CF_UNICODETEXT, clipBuf); SetClipboardData(CF_UNICODETEXT, clipBuf);
} }
else {
GlobalUnlock(clipBuf);
}
}
CloseClipboard(); CloseClipboard();
} }
free(utf16); free(utf16);
......
...@@ -918,11 +918,12 @@ static uint64_t getdiskspace(const char* path, uint64_t unit, bool freespace) ...@@ -918,11 +918,12 @@ static uint64_t getdiskspace(const char* path, uint64_t unit, bool freespace)
uint64_t total; uint64_t total;
ULARGE_INTEGER avail; ULARGE_INTEGER avail;
ULARGE_INTEGER size; ULARGE_INTEGER size;
static HINSTANCE hK32; static HINSTANCE hK32 = NULL;
GetDiskFreeSpaceEx_t GDFSE; GetDiskFreeSpaceEx_t GDFSE = NULL;
if(hK32 == NULL) if(hK32 == NULL)
hK32 = LoadLibraryA("KERNEL32"); hK32 = LoadLibraryA("KERNEL32");
if(hK32 != NULL)
GDFSE = (GetDiskFreeSpaceEx_t)GetProcAddress(hK32,"GetDiskFreeSpaceExA"); GDFSE = (GetDiskFreeSpaceEx_t)GetProcAddress(hK32,"GetDiskFreeSpaceExA");
if (GDFSE!=NULL) { /* Windows 95-OSR2 or later */ if (GDFSE!=NULL) { /* Windows 95-OSR2 or later */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment