summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2012-09-13 00:13:17 +0100
committerRobert Bragg <robert@linux.intel.com>2013-01-18 17:28:25 +0000
commit024a143cb8344e3033e1b837521694e0a24802f2 (patch)
treef0edee7469eb9cfa85bdcbb469662ca4cc8430e7
parent24fa64bea2ab64649afe2f092198d2ae2adfdaee (diff)
downloadcogl-024a143cb8344e3033e1b837521694e0a24802f2.tar.gz
stb_image: Fix warnings that the original stb_image has
Clean compiler output is a must! that also means imported source code from other projects. I can't be bothered to submit a patch upstream, because last time it was totally ignored by the stb_image guy. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit b43b1eac77e2f13d126e2211e12dc0c6d152716e)
-rw-r--r--cogl/stb_image.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cogl/stb_image.c b/cogl/stb_image.c
index ed884851..861c7512 100644
--- a/cogl/stb_image.c
+++ b/cogl/stb_image.c
@@ -2362,10 +2362,11 @@ static int create_png_image_raw(png *a, uint8_t *raw, uint32_t raw_len, int out_
a->out = (uint8_t *) malloc(x * y * out_n);
if (!a->out) return e("outofmem", "Out of memory");
if (!stbi_png_partial) {
- if (s->img_x == x && s->img_y == y)
+ if (s->img_x == x && s->img_y == y) {
if (raw_len != (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG");
- else // interlaced:
+ } else { // interlaced:
if (raw_len < (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG");
+ }
}
for (j=0; j < y; ++j) {
uint8_t *cur = a->out + stride*j;
@@ -2849,7 +2850,7 @@ static int shiftsigned(int v, int shift, int bits)
static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
{
uint8_t *out;
- unsigned int mr=0,mg=0,mb=0,ma=0, fake_a=0;
+ unsigned int mr=0,mg=0,mb=0,ma=0;
stbi_uc pal[256][4];
int psize=0,i,j,compress=0,width;
int bpp, flip_vertically, pad, target, offset, hsz;
@@ -2899,7 +2900,6 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
mg = 0xff << 8;
mb = 0xff << 0;
ma = 0xff << 24;
- fake_a = 1; // @TODO: check for cases like alpha value is all 0 and switch it to 255
} else {
mr = 31 << 10;
mg = 31 << 5;
@@ -3265,6 +3265,10 @@ static stbi_uc *tga_load(stbi *s, int *x, int *y, int *comp, int req_comp)
trans_data[2] = raw_data[0];
trans_data[3] = raw_data[3];
break;
+ default:
+ trans_data[0] = trans_data[1] = 0;
+ trans_data[2] = trans_data[3] = 0;
+ break;
}
// clear the reading flag for the next pixel
read_next_pixel = 0;
@@ -3606,7 +3610,7 @@ int stbi_hdr_test_file(FILE *f)
static char *hdr_gettoken(stbi *z, char *buffer)
{
int len=0;
- char *s = buffer, c = '\0';
+ char c = '\2';
c = get8(z);