From 9566ae0e901cf1292a5c1113f3729dae99db2233 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 21 Feb 2019 17:28:49 +0100 Subject: [PATCH] Fixed mac compilation warnings. --- channels/rdpdr/client/rdpdr_main.c | 2 +- client/Mac/MRDPView.m | 3 --- winpr/libwinpr/crt/unicode.c | 27 +++++++++++++++-------- winpr/libwinpr/library/library.c | 4 ++-- winpr/libwinpr/utils/test/TestArrayList.c | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index e5bc0332a..76c54c5d8 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -538,7 +538,7 @@ static void drive_hotplug_fsevent_callback(ConstFSEventStreamRef streamRef, const FSEventStreamEventId eventIds[]) { rdpdrPlugin* rdpdr; - int i; + size_t i; UINT error; char** paths = (char**)eventPaths; rdpdr = (rdpdrPlugin*) clientCallBackInfo; diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index ff799580c..55fda4206 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -408,9 +408,6 @@ DWORD WINAPI mac_client_thread(void* param) if (!self.is_connected) return; - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; float dx = [event deltaX]; float dy = [event deltaY]; /* 1 event = 120 units */ diff --git a/winpr/libwinpr/crt/unicode.c b/winpr/libwinpr/crt/unicode.c index b60cba875..276883265 100644 --- a/winpr/libwinpr/crt/unicode.c +++ b/winpr/libwinpr/crt/unicode.c @@ -167,7 +167,12 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, /* If cbMultiByte is -1, the string is null-terminated */ if (cbMultiByte == -1) - cbMultiByte = strlen((char*) lpMultiByteStr) + 1; + { + size_t len = strlen((const char*) lpMultiByteStr); + if (len >= INT32_MAX) + return 0; + cbMultiByte = (int)len + 1; + } /* * if cchWideChar is 0, the function returns the required buffer size @@ -190,9 +195,6 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, return 0; } - if (cbMultiByte > UINT32_MAX) - return 0; - targetStart = lpWideCharStr; targetCapacity = cchWideChar; error = U_ZERO_ERROR; @@ -289,7 +291,12 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int /* If cchWideChar is -1, the string is null-terminated */ if (cchWideChar == -1) - cchWideChar = _wcslen(lpWideCharStr) + 1; + { + size_t len = _wcslen(lpWideCharStr); + if (len >= INT32_MAX) + return 0; + cchWideChar = (int)len + 1; + } /* * if cbMultiByte is 0, the function returns the required buffer size @@ -312,9 +319,6 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int return 0; } - if (cchWideChar > UINT32_MAX) - return 0; - targetStart = lpMultiByteStr; targetCapacity = cbMultiByte; error = U_ZERO_ERROR; @@ -384,7 +388,12 @@ int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, return 0; if (cbMultiByte == -1) - cbMultiByte = (int)(strlen(lpMultiByteStr) + 1); + { + size_t len = strlen(lpMultiByteStr); + if (len >= INT_MAX) + return 0; + cbMultiByte = (int)(len + 1); + } if (cchWideChar == 0) { diff --git a/winpr/libwinpr/library/library.c b/winpr/libwinpr/library/library.c index 7731d402d..3966e81e8 100644 --- a/winpr/libwinpr/library/library.c +++ b/winpr/libwinpr/library/library.c @@ -251,7 +251,7 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) #elif defined(__MACOSX__) int status; - int length; + size_t length; if (!hModule) { @@ -278,7 +278,7 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) { CopyMemory(lpFilename, buffer, length); lpFilename[length] = '\0'; - return length; + return (DWORD)length; } CopyMemory(lpFilename, buffer, nSize - 1); diff --git a/winpr/libwinpr/utils/test/TestArrayList.c b/winpr/libwinpr/utils/test/TestArrayList.c index 38d1650e6..cccccd230 100644 --- a/winpr/libwinpr/utils/test/TestArrayList.c +++ b/winpr/libwinpr/utils/test/TestArrayList.c @@ -53,7 +53,7 @@ int TestArrayList(int argc, char* argv[]) ArrayList_RemoveAt(arrayList, 0); if (val != index) { - printf("ArrayList: shifted %d entries, expected value %d, got %"PRIdz"\n", index, index, val); + printf("ArrayList: shifted %"PRIdz" entries, expected value %"PRIdz", got %"PRIdz"\n", index, index, val); return -1; } }