From 7091cb6ed65f6bfbdacf3ffcc23dc61bed59831f Mon Sep 17 00:00:00 2001 From: Nathan Reed Date: Thu, 11 May 2017 22:48:46 -0700 Subject: [PATCH 1/5] Fix integer conversion warning --- stb_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_image.h b/stb_image.h index ae2ada6..6e4568e 100644 --- a/stb_image.h +++ b/stb_image.h @@ -2806,7 +2806,7 @@ static int stbi__process_marker(stbi__jpeg *z, int m) if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) - z->dequant[t][stbi__jpeg_dezigzag[i]] = sixteen ? stbi__get16be(z->s) : stbi__get8(z->s); + z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); L -= (sixteen ? 129 : 65); } return L==0; From 76a1a1c408c29ff39d0d98af1f7e55b099b10052 Mon Sep 17 00:00:00 2001 From: Nathan Reed Date: Thu, 11 May 2017 22:49:19 -0700 Subject: [PATCH 2/5] Fix variable-shadowing warnings --- stb_image.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/stb_image.h b/stb_image.h index 6e4568e..75a9c22 100644 --- a/stb_image.h +++ b/stb_image.h @@ -3611,20 +3611,20 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp } else if (z->s->img_n == 4) { if (z->app14_color_transform == 0) { // CMYK for (i=0; i < z->s->img_x; ++i) { - stbi_uc k = coutput[3][i]; - out[0] = stbi__blinn_8x8(coutput[0][i], k); - out[1] = stbi__blinn_8x8(coutput[1][i], k); - out[2] = stbi__blinn_8x8(coutput[2][i], k); + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(coutput[0][i], m); + out[1] = stbi__blinn_8x8(coutput[1][i], m); + out[2] = stbi__blinn_8x8(coutput[2][i], m); out[3] = 255; out += n; } } else if (z->app14_color_transform == 2) { // YCCK z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); for (i=0; i < z->s->img_x; ++i) { - stbi_uc k = coutput[3][i]; - out[0] = stbi__blinn_8x8(255 - out[0], k); - out[1] = stbi__blinn_8x8(255 - out[1], k); - out[2] = stbi__blinn_8x8(255 - out[2], k); + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(255 - out[0], m); + out[1] = stbi__blinn_8x8(255 - out[1], m); + out[2] = stbi__blinn_8x8(255 - out[2], m); out += n; } } else { // YCbCr + alpha? Ignore the fourth channel for now @@ -3649,10 +3649,10 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp } } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { for (i=0; i < z->s->img_x; ++i) { - stbi_uc k = coutput[3][i]; - stbi_uc r = stbi__blinn_8x8(coutput[0][i], k); - stbi_uc g = stbi__blinn_8x8(coutput[1][i], k); - stbi_uc b = stbi__blinn_8x8(coutput[2][i], k); + stbi_uc m = coutput[3][i]; + stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); + stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); + stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); out[0] = stbi__compute_y(r, g, b); out[1] = 255; out += n; From fb524e67685d6f17063e5c16942df688d9f7a987 Mon Sep 17 00:00:00 2001 From: Nathan Reed Date: Thu, 11 May 2017 22:51:19 -0700 Subject: [PATCH 3/5] Fix warning about context parameter being unused when STBIR_MALLOC and STBIR_FREE have their default definitions. --- stb_image_resize.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stb_image_resize.h b/stb_image_resize.h index b507e04..488e67d 100644 --- a/stb_image_resize.h +++ b/stb_image_resize.h @@ -393,8 +393,9 @@ STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int #ifndef STBIR_MALLOC #include -#define STBIR_MALLOC(size,c) malloc(size) -#define STBIR_FREE(ptr,c) free(ptr) +// use comma operator to evaluate c, to avoid "unused parameter" warnings +#define STBIR_MALLOC(size,c) ((void)(c), malloc(size)) +#define STBIR_FREE(ptr,c) ((void)(c), free(ptr)) #endif #ifndef _MSC_VER From de080e6d0bfa41475e6afa71f2e32359403304f9 Mon Sep 17 00:00:00 2001 From: Nathan Reed Date: Thu, 11 May 2017 22:53:03 -0700 Subject: [PATCH 4/5] Fix warning about unreachable code --- stb_image_resize.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_image_resize.h b/stb_image_resize.h index 488e67d..1c97ce9 100644 --- a/stb_image_resize.h +++ b/stb_image_resize.h @@ -984,7 +984,7 @@ static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max) return (m); } - return n; // NOTREACHED + // NOTREACHED default: STBIR_ASSERT(!"Unimplemented edge type"); From cbca86de6560d7953a7cd3860e6f221ae3fd2a1b Mon Sep 17 00:00:00 2001 From: Nathan Reed Date: Thu, 11 May 2017 22:59:43 -0700 Subject: [PATCH 5/5] Add myself to contributors list --- stb_image_resize.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stb_image_resize.h b/stb_image_resize.h index 1c97ce9..0168a29 100644 --- a/stb_image_resize.h +++ b/stb_image_resize.h @@ -156,7 +156,8 @@ Jorge L Rodriguez: Implementation Sean Barrett: API design, optimizations Aras Pranckevicius: bugfix - + Nathan Reed: warning fixes + REVISIONS 0.94 (2017-03-18) fixed warnings 0.93 (2017-03-03) fixed bug with certain combinations of heights