summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2021-04-11 17:40:13 +0200
committerKim Woelders <kim@woelders.dk>2021-04-16 17:15:06 +0200
commitcd1a42dd079d35f141ae8bfcf3f6db991cfad984 (patch)
tree09a3e7d6dd8be49e490acee919df0543518594b6
parent652d30e8fe9137fa82ddd392d8d1c7746dd43e2f (diff)
Fix clang-analyzer warnings - loaders (trivial)
-rw-r--r--src/modules/loaders/loader_argb.c2
-rw-r--r--src/modules/loaders/loader_bmp.c4
-rw-r--r--src/modules/loaders/loader_gif.c2
-rw-r--r--src/modules/loaders/loader_id3.c2
-rw-r--r--src/modules/loaders/loader_jpeg.c6
-rw-r--r--src/modules/loaders/loader_png.c8
-rw-r--r--src/modules/loaders/loader_tiff.c4
-rw-r--r--src/modules/loaders/loader_xpm.c3
8 files changed, 13 insertions, 18 deletions
diff --git a/src/modules/loaders/loader_argb.c b/src/modules/loaders/loader_argb.c
index b915b7b..c40022c 100644
--- a/src/modules/loaders/loader_argb.c
+++ b/src/modules/loaders/loader_argb.c
@@ -92,8 +92,6 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
92 if (!f) 92 if (!f)
93 return LOAD_FAIL; 93 return LOAD_FAIL;
94 94
95 rc = LOAD_FAIL;
96
97 if (im->flags & F_HAS_ALPHA) 95 if (im->flags & F_HAS_ALPHA)
98 alpha = 1; 96 alpha = 1;
99 97
diff --git a/src/modules/loaders/loader_bmp.c b/src/modules/loaders/loader_bmp.c
index 825eeb9..62a501e 100644
--- a/src/modules/loaders/loader_bmp.c
+++ b/src/modules/loaders/loader_bmp.c
@@ -195,8 +195,6 @@ load2(ImlibImage * im, int load_data)
195 if (fread(&bih.header_size + 1, bih.header_size - 4, 1, im->fp) != 1) 195 if (fread(&bih.header_size + 1, bih.header_size - 4, 1, im->fp) != 1)
196 goto quit; 196 goto quit;
197 197
198 w = h = 0;
199 bitcount = 0;
200 comp = BI_RGB; 198 comp = BI_RGB;
201 amask = rmask = gmask = bmask = 0; 199 amask = rmask = gmask = bmask = 0;
202 ashift1 = rshift1 = gshift1 = bshift1 = 0; 200 ashift1 = rshift1 = gshift1 = bshift1 = 0;
@@ -218,7 +216,7 @@ load2(ImlibImage * im, int load_data)
218// planes = SWAP_LE_16(bih.bih.planes); 216// planes = SWAP_LE_16(bih.bih.planes);
219 bitcount = SWAP_LE_16(bih.bih.bpp); 217 bitcount = SWAP_LE_16(bih.bih.bpp);
220 comp = SWAP_LE_32(bih.bih.compression); 218 comp = SWAP_LE_32(bih.bih.compression);
221 imgsize = SWAP_LE_32(bih.bih.size); /* We don't use this */ 219// imgsize = SWAP_LE_32(bih.bih.size); /* We don't use this */
222 220
223 if (bih.header_size >= 40 && 221 if (bih.header_size >= 40 &&
224 (comp == BI_BITFIELDS || comp == BI_ALPHABITFIELDS)) 222 (comp == BI_BITFIELDS || comp == BI_ALPHABITFIELDS))
diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c
index d012bf2..eee4463 100644
--- a/src/modules/loaders/loader_gif.c
+++ b/src/modules/loaders/loader_gif.c
@@ -57,7 +57,7 @@ load2(ImlibImage * im, int load_data)
57 if (!IMAGE_DIMENSIONS_OK(w, h)) 57 if (!IMAGE_DIMENSIONS_OK(w, h))
58 goto quit; 58 goto quit;
59 59
60 rows = calloc(h, sizeof(GifRowType *)); 60 rows = calloc(h, sizeof(GifRowType));
61 if (!rows) 61 if (!rows)
62 goto quit; 62 goto quit;
63 63
diff --git a/src/modules/loaders/loader_id3.c b/src/modules/loaders/loader_id3.c
index 803c966..34e8ff1 100644
--- a/src/modules/loaders/loader_id3.c
+++ b/src/modules/loaders/loader_id3.c
@@ -591,8 +591,6 @@ load2(ImlibImage * im, int load_data)
591 } 591 }
592#endif 592#endif
593 593
594 res = LOAD_SUCCESS;
595
596 fail_context: 594 fail_context:
597 if (opt.ctx) 595 if (opt.ctx)
598 context_delref(opt.ctx); 596 context_delref(opt.ctx);
diff --git a/src/modules/loaders/loader_jpeg.c b/src/modules/loaders/loader_jpeg.c
index 4f009a6..c9dad29 100644
--- a/src/modules/loaders/loader_jpeg.c
+++ b/src/modules/loaders/loader_jpeg.c
@@ -122,10 +122,11 @@ load2(ImlibImage * im, int load_data)
122 scans = cinfo.rec_outbuf_height; 122 scans = cinfo.rec_outbuf_height;
123 if ((h - l) < scans) 123 if ((h - l) < scans)
124 scans = h - l; 124 scans = h - l;
125 ptr = jdata.data;
126 125
127 for (y = 0; y < scans; y++) 126 for (y = 0; y < scans; y++)
128 { 127 {
128 ptr = line[y];
129
129 switch (cinfo.out_color_space) 130 switch (cinfo.out_color_space)
130 { 131 {
131 default: 132 default:
@@ -162,11 +163,10 @@ load2(ImlibImage * im, int load_data)
162 if (im->lc && __imlib_LoadProgressRows(im, l, scans)) 163 if (im->lc && __imlib_LoadProgressRows(im, l, scans))
163 { 164 {
164 rc = LOAD_BREAK; 165 rc = LOAD_BREAK;
165 goto done; 166 goto quit;
166 } 167 }
167 } 168 }
168 169
169 done:
170 jpeg_finish_decompress(&cinfo); 170 jpeg_finish_decompress(&cinfo);
171 171
172 rc = LOAD_SUCCESS; 172 rc = LOAD_SUCCESS;
diff --git a/src/modules/loaders/loader_png.c b/src/modules/loaders/loader_png.c
index 5e90b33..d216dc9 100644
--- a/src/modules/loaders/loader_png.c
+++ b/src/modules/loaders/loader_png.c
@@ -205,6 +205,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
205 ImlibImageTag *tag; 205 ImlibImageTag *tag;
206 int quality = 75, compression = 3; 206 int quality = 75, compression = 3;
207 int pass, n_passes = 1; 207 int pass, n_passes = 1;
208 int has_alpha;
208 209
209 f = fopen(im->real_file, "wb"); 210 f = fopen(im->real_file, "wb");
210 if (!f) 211 if (!f)
@@ -235,7 +236,8 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
235 } 236 }
236 237
237 png_init_io(png_ptr, f); 238 png_init_io(png_ptr, f);
238 if (im->flags & F_HAS_ALPHA) 239 has_alpha = IMAGE_HAS_ALPHA(im);
240 if (has_alpha)
239 { 241 {
240 png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, 242 png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8,
241 PNG_COLOR_TYPE_RGB_ALPHA, interlace, 243 PNG_COLOR_TYPE_RGB_ALPHA, interlace,
@@ -251,7 +253,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
251 png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, PNG_COLOR_TYPE_RGB, 253 png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, PNG_COLOR_TYPE_RGB,
252 interlace, PNG_COMPRESSION_TYPE_BASE, 254 interlace, PNG_COMPRESSION_TYPE_BASE,
253 PNG_FILTER_TYPE_BASE); 255 PNG_FILTER_TYPE_BASE);
254 data = malloc(im->w * 3 * sizeof(char)); 256 data = malloc(im->w * 3 * sizeof(png_byte));
255 } 257 }
256 sig_bit.red = 8; 258 sig_bit.red = 8;
257 sig_bit.green = 8; 259 sig_bit.green = 8;
@@ -309,7 +311,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
309 311
310 for (y = 0; y < im->h; y++) 312 for (y = 0; y < im->h; y++)
311 { 313 {
312 if (im->flags & F_HAS_ALPHA) 314 if (has_alpha)
313 row_ptr = (png_bytep) ptr; 315 row_ptr = (png_bytep) ptr;
314 else 316 else
315 { 317 {
diff --git a/src/modules/loaders/loader_tiff.c b/src/modules/loaders/loader_tiff.c
index 9cb3038..9411fe6 100644
--- a/src/modules/loaders/loader_tiff.c
+++ b/src/modules/loaders/loader_tiff.c
@@ -69,8 +69,8 @@ raster(TIFFRGBAImage_Extra * img, uint32 * rast,
69 /* I don't understand why, but that seems to be what's going on. */ 69 /* I don't understand why, but that seems to be what's going on. */
70 /* libtiff needs better docs! */ 70 /* libtiff needs better docs! */
71 71
72 if (img->rgba.alpha == EXTRASAMPLE_UNASSALPHA) 72 alpha_premult = img->rgba.alpha == EXTRASAMPLE_UNASSALPHA;
73 alpha_premult = 1; 73
74 switch (img->rgba.orientation) 74 switch (img->rgba.orientation)
75 { 75 {
76 default: 76 default:
diff --git a/src/modules/loaders/loader_xpm.c b/src/modules/loaders/loader_xpm.c
index 727addb..de2dc38 100644
--- a/src/modules/loaders/loader_xpm.c
+++ b/src/modules/loaders/loader_xpm.c
@@ -111,7 +111,7 @@ xpm_cmap_lookup(const cmap_t * cmap, int nc, int cpp, const char *s)
111{ 111{
112 int i, i1, i2, x; 112 int i, i1, i2, x;
113 113
114 i1 = i = 0; 114 i1 = 0;
115 i2 = nc - 1; 115 i2 = nc - 1;
116 while (i1 < i2) 116 while (i1 < i2)
117 { 117 {
@@ -157,7 +157,6 @@ load2(ImlibImage * im, int load_data)
157 157
158 rewind(im->fp); 158 rewind(im->fp);
159 159
160 i = 0;
161 j = 0; 160 j = 0;
162 w = 10; 161 w = 10;
163 h = 10; 162 h = 10;