diff options
author | Vinson Lee <vlee@vmware.com> | 2010-01-03 21:29:33 -0800 |
---|---|---|
committer | Vinson Lee <vlee@vmware.com> | 2010-01-03 21:29:33 -0800 |
commit | 3ea5a95078bddaed66e3c9412b4b0c4685bc9ec7 (patch) | |
tree | a17555d4c1d386d0272a490f505dca1ae4b4a9bc /progs/samples | |
parent | b14cbfaebc135351a72d86128ae987611ef8c31f (diff) |
progs/samples: Silence compiler warnings.
Diffstat (limited to 'progs/samples')
-rw-r--r-- | progs/samples/rgbtoppm.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c index adc91469e5..403578ef42 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 <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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; |