diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index 7077933395..6d1ac43a61 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -179,12 +179,12 @@ BMPreadinfoheader( int *pclassv) { unsigned long cbFix; - unsigned short cPlanes; + unsigned short cPlanes = 0; - unsigned long cx; - unsigned long cy; - unsigned short cBitCount; - int classv; + unsigned long cx = 0; + unsigned long cy = 0; + unsigned short cBitCount = 0; + int classv = 0; cbFix = GetLong(fp); @@ -315,7 +315,7 @@ BMPreadrow( pixval *G, pixval *B) { - BITSTREAM b; + BITSTREAM b = NULL; unsigned nbyte = 0; int rc; unsigned x; diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index 9099c6a147..2d48840330 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -143,7 +143,7 @@ BMPwriteinfoheader( unsigned long x, unsigned long y) { - long cbFix; + long cbFix = 0; /* cbFix */ switch (classv) diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.h b/panda/src/pnmimagetypes/pnmFileTypeJPG.h index 3d6e330587..7a152248b5 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.h @@ -31,6 +31,14 @@ #include // we need to include this before jpeglib. #endif +#ifdef HAVE_PNG +// If we are going to be including png.h (in the unrelated file +// pnmFileTypePNG.h), be sure to include it before including setjmp.h. +// Ugly hack due to png weirdness with setjmp. +#include +#endif + + extern "C" { #include // jpeglib requires this to be included first. #include diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx index ee5b908209..39ec9bb441 100755 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx @@ -351,7 +351,10 @@ read_data(xel *array, xelval *alpha_data) { for (yi = 0; yi < num_rows; yi++) { png_bytep source = rows[yi]; for (int xi = 0; xi < _x_size; xi++) { - int red, green, blue, alpha; + int red = 0; + int green = 0; + int blue = 0; + int alpha = 0; if (_maxval > 255) { if (get_color) { @@ -430,7 +433,7 @@ void PNMFileTypePNG::Reader:: png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { Reader *self = (Reader *)png_get_io_ptr(png_ptr); self->_file->read((char *)data, length); - if (self->_file->gcount() != length) { + if (length != (png_size_t)self->_file->gcount()) { pnmimage_png_cat.error() << "Didn't read enough bytes.\n"; // Is there no way to indicate a read failure to libpng? diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index c421efcb28..65aeb23aa7 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -346,7 +346,7 @@ read_channel(istream *ifp, TabEntry *table, ScanElem *channel_data, long table_start, int channel, int row) { - ScanElem *temp; + ScanElem *temp = NULL; int sgi_index, i; long offset, length; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index cbb0b09f1a..63ee5960c9 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -646,43 +646,44 @@ readtga( istream *ifp, struct ImageHeader *tgaP, const string &magic_number ) { void PNMFileTypeTGA::Reader:: get_map_entry( istream *ifp, pixel *Value, int Size, gray *Alpha ) { - unsigned char j, k, r, g, b, a; + unsigned char j, k; + unsigned char r = 0, g = 0, b = 0, a = 0; /* Read appropriate number of bytes, break into rgb & put in map. */ switch ( Size ) - { - case 8: /* Grey scale, read and triplicate. */ + { + case 8: /* Grey scale, read and triplicate. */ r = g = b = getbyte( ifp ); - a = 0; + a = 0; break; - - case 16: /* 5 bits each of red green and blue. */ - case 15: /* Watch for byte order. */ + + case 16: /* 5 bits each of red green and blue. */ + case 15: /* Watch for byte order. */ j = getbyte( ifp ); k = getbyte( ifp ); r = ( k & 0x7C ) >> 2; g = ( ( k & 0x03 ) << 3 ) + ( ( j & 0xE0 ) >> 5 ); b = j & 0x1F; - a = 0; + a = 0; break; - case 32: /* 8 bits each of blue, green, red, and alpha */ - case 24: /* 8 bits each of blue green and red. */ + case 32: /* 8 bits each of blue, green, red, and alpha */ + case 24: /* 8 bits each of blue green and red. */ b = getbyte( ifp ); g = getbyte( ifp ); r = getbyte( ifp ); if ( Size == 32 ) - a = getbyte( ifp ); - else - a = 0; + a = getbyte( ifp ); + else + a = 0; break; - - default: + + default: pm_error( "unknown colormap pixel size (#2) - %d", Size ); - } + } PPM_ASSIGN( *Value, r, g, b ); *Alpha = a; - } +}