From 4943e48e735993cd02c42cc5477fe79c3862a509 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 9 Oct 2019 09:29:59 -0700 Subject: [PATCH] Fixed some MSVC compiler warnings --- IMG_bmp.c | 3 +++ IMG_gif.c | 7 +++++-- IMG_jpg.c | 3 +++ IMG_lbm.c | 3 +++ IMG_pcx.c | 3 +++ IMG_png.c | 3 +++ IMG_pnm.c | 3 +++ IMG_svg.c | 3 +++ IMG_tga.c | 3 +++ IMG_tif.c | 3 +++ IMG_webp.c | 3 +++ IMG_xcf.c | 3 +++ IMG_xpm.c | 3 +++ IMG_xv.c | 3 +++ IMG_xxx.c | 3 +++ miniz.h | 9 +++++++++ nanosvg.h | 17 ++++++++--------- 17 files changed, 64 insertions(+), 11 deletions(-) diff --git a/IMG_bmp.c b/IMG_bmp.c index 0fc0a714..dad205c5 100644 --- a/IMG_bmp.c +++ b/IMG_bmp.c @@ -425,6 +425,9 @@ SDL_Surface *IMG_LoadCUR_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isBMP(SDL_RWops *src) diff --git a/IMG_gif.c b/IMG_gif.c index 6ce86f94..1bc39f3c 100644 --- a/IMG_gif.c +++ b/IMG_gif.c @@ -615,7 +615,7 @@ LWZReadByte(SDL_RWops *src, int flag, int input_code_size, State_t * state) static Image * ReadImage(SDL_RWops * src, int len, int height, int cmapSize, unsigned char cmap[3][MAXCOLORMAPSIZE], - int gray, int interlace, int ignore, State_t * state) + int /*gray*/, int interlace, int ignore, State_t * state) { Image *image; unsigned char c; @@ -648,7 +648,7 @@ ReadImage(SDL_RWops * src, int len, int height, int cmapSize, cmap[CM_GREEN][i], cmap[CM_BLUE][i]); while ((v = LWZReadByte(src, FALSE, c, state)) >= 0) { - ((Uint8 *)image->pixels)[xpos + ypos * image->pitch] = v; + ((Uint8 *)image->pixels)[xpos + ypos * image->pitch] = (Uint8)v; ++xpos; if (xpos == len) { xpos = 0; @@ -781,6 +781,9 @@ SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isGIF(SDL_RWops *src) diff --git a/IMG_jpg.c b/IMG_jpg.c index 032224a9..f8c9d35e 100644 --- a/IMG_jpg.c +++ b/IMG_jpg.c @@ -535,6 +535,9 @@ static int IMG_SaveJPG_RW_jpeglib(SDL_Surface *surface, SDL_RWops *dst, int free } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif int IMG_InitJPG() { diff --git a/IMG_lbm.c b/IMG_lbm.c index 798efc57..fa59f78a 100644 --- a/IMG_lbm.c +++ b/IMG_lbm.c @@ -484,6 +484,9 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) } #else /* LOAD_LBM */ +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isLBM(SDL_RWops *src) diff --git a/IMG_pcx.c b/IMG_pcx.c index 703ca709..61fa431a 100644 --- a/IMG_pcx.c +++ b/IMG_pcx.c @@ -283,6 +283,9 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isPCX(SDL_RWops *src) diff --git a/IMG_png.c b/IMG_png.c index 9ff6dfd0..99bc8ad7 100644 --- a/IMG_png.c +++ b/IMG_png.c @@ -474,6 +474,9 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif int IMG_InitPNG() { diff --git a/IMG_pnm.c b/IMG_pnm.c index 7e00448a..0ac56e37 100644 --- a/IMG_pnm.c +++ b/IMG_pnm.c @@ -244,6 +244,9 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isPNM(SDL_RWops *src) diff --git a/IMG_svg.c b/IMG_svg.c index 9edd3b9f..0dad52c6 100644 --- a/IMG_svg.c +++ b/IMG_svg.c @@ -145,6 +145,9 @@ SDL_Surface *IMG_LoadSVG_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isSVG(SDL_RWops *src) diff --git a/IMG_tga.c b/IMG_tga.c index 6d99cb72..1561adf1 100644 --- a/IMG_tga.c +++ b/IMG_tga.c @@ -323,6 +323,9 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* dummy TGA load routine */ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) diff --git a/IMG_tif.c b/IMG_tif.c index dc7ca012..04afad6a 100644 --- a/IMG_tif.c +++ b/IMG_tif.c @@ -213,6 +213,9 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif int IMG_InitTIF() { diff --git a/IMG_webp.c b/IMG_webp.c index 03a81544..45b4b76e 100644 --- a/IMG_webp.c +++ b/IMG_webp.c @@ -265,6 +265,9 @@ SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif int IMG_InitWEBP() { diff --git a/IMG_xcf.c b/IMG_xcf.c index de17e893..933678b4 100644 --- a/IMG_xcf.c +++ b/IMG_xcf.c @@ -932,6 +932,9 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isXCF(SDL_RWops *src) diff --git a/IMG_xpm.c b/IMG_xpm.c index c4e9f3e8..bcf427e4 100644 --- a/IMG_xpm.c +++ b/IMG_xpm.c @@ -1189,6 +1189,9 @@ SDL_Surface *IMG_ReadXPMFromArray(char **xpm) } #else /* not LOAD_XPM */ +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isXPM(SDL_RWops *src) diff --git a/IMG_xv.c b/IMG_xv.c index b024feaa..7a3179d9 100644 --- a/IMG_xv.c +++ b/IMG_xv.c @@ -146,6 +146,9 @@ SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isXV(SDL_RWops *src) diff --git a/IMG_xxx.c b/IMG_xxx.c index 787d054a..d036ec27 100644 --- a/IMG_xxx.c +++ b/IMG_xxx.c @@ -69,6 +69,9 @@ SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src) } #else +#if _MSC_VER >= 1300 +#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ +#endif /* See if an image is contained in a data source */ int IMG_isXXX(SDL_RWops *src) diff --git a/miniz.h b/miniz.h index fa7e255b..dab7e9ba 100644 --- a/miniz.h +++ b/miniz.h @@ -940,6 +940,11 @@ MINIZ_STATIC mz_uint tdefl_create_comp_flags_from_zip_params(int level, int wind #ifndef MINIZ_HEADER_FILE_ONLY +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable:4505) // unreferenced local function has been removed +#endif + typedef unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 : -1]; typedef unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 : -1]; typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; @@ -4912,6 +4917,10 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char } #endif +#ifdef _MSC_VER +#pragma warning (pop) +#endif + #endif // MINIZ_HEADER_FILE_ONLY /* diff --git a/nanosvg.h b/nanosvg.h index be35c54d..7aaa15e3 100644 --- a/nanosvg.h +++ b/nanosvg.h @@ -285,8 +285,8 @@ static void nsvg__parseElement(char* s, // Get attribs while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) { - char* name = NULL; - char* value = NULL; + char* attr_name = NULL; + char* attr_value = NULL; // Skip white space before the attrib name while (*s && nsvg__isspace(*s)) s++; @@ -295,7 +295,7 @@ static void nsvg__parseElement(char* s, end = 1; break; } - name = s; + attr_name = s; // Find end of the attrib name. while (*s && !nsvg__isspace(*s) && *s != '=') s++; if (*s) { *s++ = '\0'; } @@ -305,14 +305,14 @@ static void nsvg__parseElement(char* s, quote = *s; s++; // Store value and find the end of it. - value = s; + attr_value = s; while (*s && *s != quote) s++; if (*s) { *s++ = '\0'; } // Store only well formed attributes - if (name && value) { - attr[nattr++] = name; - attr[nattr++] = value; + if (attr_name && attr_value) { + attr[nattr++] = attr_name; + attr[nattr++] = attr_value; } } @@ -822,7 +822,6 @@ static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig, case NSVG_UNITS_PERCENT: return orig + c.value / 100.0f * length; default: return c.value; } - return c.value; } static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id) @@ -2782,7 +2781,7 @@ static void nsvg__content(void* ud, const char* s) if (p->styleFlag) { int state = 0; - const char* start; + const char* start = s; while (*s) { char c = *s; if (nsvg__isspace(c) || c == '{') {