From 347e7838be93e60aecb319cea83d3e15f2abef75 Mon Sep 17 00:00:00 2001 From: Guillaume Chereau Date: Mon, 20 Apr 2015 22:59:24 +0800 Subject: [PATCH] fix compilation of stb_image_write.h with gcc -O3 When compiling with -O3, gcc would complain that 'linear' might not be initialized if comp is superior to 4. In fact passing a value > 4 is an error anyway, but gcc does not know that. I changed the switch case to support comp > 4. I don't think it should affect the performances. --- stb_image_write.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stb_image_write.h b/stb_image_write.h index 1048970..46f60b9 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -294,8 +294,8 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra linear[1] = scanline[x*comp + 1]; linear[0] = scanline[x*comp + 0]; break; - case 2: /* fallthrough */ - case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0]; + default: + linear[0] = linear[1] = linear[2] = scanline[x*comp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); @@ -311,8 +311,8 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra linear[1] = scanline[x*comp + 1]; linear[0] = scanline[x*comp + 0]; break; - case 2: /* fallthrough */ - case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0]; + default: + linear[0] = linear[1] = linear[2] = scanline[x*comp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear);