[Cogl] [PATCH] stb_image: Fix warnings that the original stb_image has

Damien Lespiau damien.lespiau at gmail.com
Wed Sep 12 16:14:16 PDT 2012


From: Damien Lespiau <damien.lespiau at intel.com>

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.
---
 cogl/stb_image.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/cogl/stb_image.c b/cogl/stb_image.c
index 629cd28..12315d5 100644
--- a/cogl/stb_image.c
+++ b/cogl/stb_image.c
@@ -2358,10 +2358,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;
@@ -2845,7 +2846,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;
@@ -2895,7 +2896,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;
@@ -3261,6 +3261,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;
@@ -3602,7 +3606,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);
 
-- 
1.7.7.5



More information about the Cogl mailing list