From 3ea5a95078bddaed66e3c9412b4b0c4685bc9ec7 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 3 Jan 2010 21:29:33 -0800 Subject: [PATCH] progs/samples: Silence compiler warnings. --- progs/samples/rgbtoppm.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c index adc91469e56..403578ef423 100644 --- a/progs/samples/rgbtoppm.c +++ b/progs/samples/rgbtoppm.c @@ -3,6 +3,7 @@ /* texload is a simplistic routine for reading an SGI .rgb image file. */ +#include #include #include #include @@ -72,6 +73,7 @@ static ImageRec *ImageOpen(char *fileName) ImageRec *image; int swapFlag; int x; + int result; endianTest.testWord = 1; if (endianTest.testByte[0] == 1) { @@ -90,7 +92,8 @@ static ImageRec *ImageOpen(char *fileName) return NULL; } - fread(image, 1, 12, image->file); + result = fread(image, 1, 12, image->file); + assert(result == 12); if (swapFlag) { ConvertShort(&image->imagic, 1); @@ -117,8 +120,10 @@ static ImageRec *ImageOpen(char *fileName) } image->rleEnd = 512 + (2 * x); fseek(image->file, 512, SEEK_SET); - fread(image->rowStart, 1, x, image->file); - fread(image->rowSize, 1, x, image->file); + result = fread(image->rowStart, 1, x, image->file); + assert(result == x); + result = fread(image->rowSize, 1, x, image->file); + assert(result == x); if (swapFlag) { ConvertUint(image->rowStart, x/(int) sizeof(unsigned)); ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int)); @@ -138,11 +143,13 @@ static void ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { unsigned char *iPtr, *oPtr, pixel; int count; + int result; if ((image->type & 0xFF00) == 0x0100) { fseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET); - fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], - image->file); + result = fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], + image->file); + assert(result == (unsigned int)image->rowSize[y+z*image->ysize]); iPtr = image->tmp; oPtr = buf; @@ -166,10 +173,12 @@ ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { } else { fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize), SEEK_SET); - fread(buf, 1, image->xsize, image->file); + result = fread(buf, 1, image->xsize, image->file); + assert(result == image->xsize); } } +#if 0 static GLubyte * read_alpha_texture(char *name, int *width, int *height) { @@ -199,6 +208,7 @@ read_alpha_texture(char *name, int *width, int *height) return (unsigned char *) base; } +#endif static GLubyte * read_rgb_texture(char *name, int *width, int *height) @@ -261,7 +271,8 @@ read_rgb_texture(char *name, int *width, int *height) int main(int argc, char **argv) { - int width, height; + int width = 0; + int height = 0; GLubyte *data; char buff[32]; int n; -- 2.30.2