forked from old/legacy-imlib2
check return value of fread/write funcs
This fixes warnings with newer compilers/distros that enable warning flags by default: loader_zlib.c: In function 'uncompress_file': loader_zlib.c:33:17: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result] write(dest, outbuf, bytes); ^
This commit is contained in:
parent
5dde234b2d
commit
560a58e617
|
@ -71,12 +71,22 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
{
|
||||
int x;
|
||||
|
||||
fread(ptr, im->w, 4, f);
|
||||
if (fread(ptr, im->w, 4, f) != 4)
|
||||
{
|
||||
free(ptr);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
for (x = 0; x < im->w; x++)
|
||||
SWAP32(ptr[x]);
|
||||
}
|
||||
#else
|
||||
fread(ptr, im->w, 4, f);
|
||||
if (fread(ptr, im->w, 4, f) != 4)
|
||||
{
|
||||
free(ptr);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
ptr += im->w;
|
||||
if (progress)
|
||||
|
|
|
@ -208,14 +208,22 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
if (ncols > 256)
|
||||
ncols = 256;
|
||||
for (i = 0; i < ncols; i++)
|
||||
fread(&rgbQuads[i], 3, 1, f);
|
||||
if (fread(&rgbQuads[i], 3, 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ncols /= 4;
|
||||
if (ncols > 256)
|
||||
ncols = 256;
|
||||
fread(rgbQuads, 4, ncols, f);
|
||||
if (fread(rgbQuads, 4, ncols, f) != ncols)
|
||||
{
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bitcount == 16 || bitcount == 32)
|
||||
|
@ -293,12 +301,18 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
im->data = malloc(w * h * sizeof(DATA32));
|
||||
if (!im->data)
|
||||
{
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fread(buffer, imgsize, 1, f);
|
||||
if (fread(buffer, imgsize, 1, f) != 1)
|
||||
{
|
||||
free(im->data);
|
||||
free(buffer);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
fclose(f);
|
||||
buffer_ptr = buffer;
|
||||
buffer_end = buffer + imgsize;
|
||||
|
|
|
@ -28,7 +28,8 @@ uncompress_file(FILE * fp, int dest)
|
|||
bytes = BZ2_bzRead(&error, bf, &outbuf, OUTBUF_SIZE);
|
||||
|
||||
if (error == BZ_OK || error == BZ_STREAM_END)
|
||||
write(dest, outbuf, bytes);
|
||||
if (write(dest, outbuf, bytes) != bytes)
|
||||
break;
|
||||
|
||||
if (error == BZ_STREAM_END)
|
||||
break;
|
||||
|
|
|
@ -37,7 +37,11 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
unsigned char buf[PNG_BYTES_TO_CHECK];
|
||||
|
||||
/* if we haven't read the header before, set the header data */
|
||||
fread(buf, 1, PNG_BYTES_TO_CHECK, f);
|
||||
if (fread(buf, 1, PNG_BYTES_TO_CHECK, f) != PNG_BYTES_TO_CHECK)
|
||||
{
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
if (png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK))
|
||||
{
|
||||
fclose(f);
|
||||
|
|
|
@ -278,7 +278,11 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
if (!file)
|
||||
return 0;
|
||||
|
||||
fread(&magic_number, sizeof(uint16), 1, file);
|
||||
if (fread(&magic_number, sizeof(uint16), 1, file) != 1)
|
||||
{
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
/* Apparently rewind(f) isn't sufficient */
|
||||
fseek(file, (long)0, SEEK_SET);
|
||||
|
||||
|
|
|
@ -125,7 +125,12 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
|||
xpm_parse_done();
|
||||
return 0;
|
||||
}
|
||||
fread(s, 1, 9, f);
|
||||
if (fread(s, 1, 9, f) != 9)
|
||||
{
|
||||
fclose(f);
|
||||
xpm_parse_done();
|
||||
return 0;
|
||||
}
|
||||
rewind(f);
|
||||
s[9] = 0;
|
||||
if (strcmp("/* XPM */", s))
|
||||
|
|
|
@ -29,8 +29,8 @@ uncompress_file(int src, int dest)
|
|||
ret = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
write(dest, outbuf, bytes);
|
||||
else if (write(dest, outbuf, bytes) != bytes)
|
||||
break;
|
||||
}
|
||||
|
||||
gzclose(gf);
|
||||
|
|
Loading…
Reference in New Issue