From 7c8f6bca80d9a1ef886189a20479f012dde84714 Mon Sep 17 00:00:00 2001 From: dolphin6k Date: Fri, 5 Nov 2021 12:23:09 +0900 Subject: [PATCH] Addressed warnings when compiling on MinGW/MSYS Following warnings still remain so far. src/tuxpaint.c:199:2: warning: #warning "Attempting to define strcasestr(); if errors, build with -DHAVE_STRCASESTR" [-Wcpp] 199 | #warning "Attempting to define strcasestr(); if errors, build with -DHAVE_STRCASESTR" | ^~~~~~~ src/parse.gperf: In function 'parse_one_option': src/parse.gperf:306:45: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'char *' as the destination; expected 'char' or an explicit length [-Wsizeof-pointer-memaccess] 306 | memcpy(offset+(char*)tmpcfg, &opt, sizeof(char*)); /* FIXME: This causes a warning; should it be 'sizeof(char)', or do we need to have the warning suppressed? -bjk 2021.10.14 */ | ^~~~ src/dirwalk.c: In function 'tp_ftw': src/dirwalk.c:348:2: warning: #warning Failed to see DT_UNKNOWN [-Wcpp] 348 | #warning Failed to see DT_UNKNOWN | ^~~~~~~ src/get_fname.c: In function 'get_fname': src/get_fname.c:100:3: warning: 'dir' may be used uninitialized in this function [-Wmaybe-uninitialized] 100 | snprintf(f, sizeof(f), | ^~~~~~~~~~~~~~~~~~~~~~ 101 | "%s%c%s", | ~~~~~~~~~ 102 | dir, (*name) ? '/' : '\0', /* Some mkdir()'s don't like trailing slashes */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 103 | name); | ~~~~~ magic/src/cartoon.c:178:99: warning: unused parameter 'last' [-Wunused-parameter] 178 | static void do_cartoon(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y) | ~~~~~~~~~~~~~~^~~~ --- src/dirwalk.c | 3 +++ src/fonts.c | 1 + src/tuxpaint.c | 5 +++-- src/win32_print.c | 14 ++++++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/dirwalk.c b/src/dirwalk.c index 967602bcc..711e7032e 100644 --- a/src/dirwalk.c +++ b/src/dirwalk.c @@ -64,6 +64,9 @@ #include "debug.h" +#ifdef WIN32 +extern char *strcasestr(const char *haystack, const char *needle); +#endif /* Directory walking callers and callbacks */ diff --git a/src/fonts.c b/src/fonts.c index ac320f94b..c2790b2cc 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -66,6 +66,7 @@ #ifdef WIN32 #include "win32_print.h" +extern char *strcasestr(const char *haystack, const char *needle); #endif #if defined(__MACOS__) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 90e78cb5b..b5a4e5f10 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -14611,10 +14611,10 @@ static void do_png_embed_data(png_structp png_ptr) #ifdef WIN32 iconv_t trans; wchar_t *wch; + char *ch; char *conv, *conv2; size_t in, out; - in = out = 1; conv = malloc(255); trans = iconv_open("UTF-8", "WCHAR_T"); @@ -14625,7 +14625,8 @@ static void do_png_embed_data(png_structp png_ptr) in = 2; out = 10; wch = ¤t_node->save_texttool_str[i]; - iconv(trans, (char **)&wch, &in, &conv, &out); + ch = (char *)wch; + iconv(trans, &ch, &in, &conv, &out); conv[0] = '\0'; fprintf(lfi, "%s", conv2); } diff --git a/src/win32_print.c b/src/win32_print.c index bb2c7a549..e83a81116 100644 --- a/src/win32_print.c +++ b/src/win32_print.c @@ -328,6 +328,7 @@ const char *SurfacePrint(SDL_Surface * surf, const char *printcfg, int showdialo int nError; SDL_SysWMinfo wminfo; BITMAPINFOHEADER bmih; + BITMAPINFO bmi; SDL_Surface *surf24 = NULL; RECT rcDst; float sX, sY; @@ -464,12 +465,13 @@ const char *SurfacePrint(SDL_Surface * surf, const char *printcfg, int showdialo { SetStretchBltMode(hDCprinter, COLORONCOLOR); + bmi.bmiHeader = bmih; nError = StretchDIBits(hDCprinter, rcDst.left, rcDst.top, rcDst.right - rcDst.left, rcDst.bottom - rcDst.top, 0, 0, bmih.biWidth, bmih.biHeight, - surf24->pixels, (BITMAPINFO *) & bmih, DIB_RGB_COLORS, SRCCOPY); - if (nError == GDI_ERROR) + surf24->pixels, &bmi, DIB_RGB_COLORS, SRCCOPY); + if (nError == (int) GDI_ERROR) { res = "win32_print: StretchDIBits() failed."; goto error; @@ -518,11 +520,13 @@ static HRESULT ReadRegistry(const char *key, const char *option, char *value, in { LONG res; HKEY hKey = NULL; + DWORD _size; + _size = size; res = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey); if (res != ERROR_SUCCESS) goto err_exit; - res = RegQueryValueEx(hKey, option, NULL, NULL, (LPBYTE) value, (LPDWORD) & size); + res = RegQueryValueEx(hKey, option, NULL, NULL, (LPBYTE) value, &_size); if (res != ERROR_SUCCESS) goto err_exit; res = ERROR_SUCCESS; @@ -603,6 +607,7 @@ char *GetSystemFontDir(void) * * @return user's image dir */ +char *GetUserImageDir(void); char *GetUserImageDir(void) { char path[MAX_PATH]; @@ -624,7 +629,7 @@ char *GetUserImageDir(void) */ static char *GetUserTempDir(void) { - char *temp = getenv("TEMP"); + const char *temp = getenv("TEMP"); if (!temp) { @@ -659,6 +664,7 @@ static int g_bWindowActive = 0; /** * FIXME */ +LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { int bEatKeystroke = 0;