From 49a23fdc2e8463f98e54b4d6a2c6a7dcf398ee9d Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 9 Jan 2012 21:51:09 +0100 Subject: [PATCH] Fix final simgear GCC warnings. --- simgear/io/sg_binobj.cxx | 8 ++++++-- simgear/screen/screen-dump.cxx | 8 +++++++- simgear/sound/sample_openal.hxx | 4 ++-- simgear/timing/timezone.cxx | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/simgear/io/sg_binobj.cxx b/simgear/io/sg_binobj.cxx index a4fbc8ff..f5111640 100644 --- a/simgear/io/sg_binobj.cxx +++ b/simgear/io/sg_binobj.cxx @@ -1006,9 +1006,13 @@ bool SGBinObject::write_ascii( const string& base, const string& name, fclose(fp); string command = "gzip --force --best " + file.str(); - system(command.c_str()); + int err = system(command.c_str()); + if (err) + { + cout << "ERROR: gzip " << file.str() << " failed!" << endl; + } - return true; + return (err == 0); } void SGBinObject::read_properties(gzFile fp, int nproperties) diff --git a/simgear/screen/screen-dump.cxx b/simgear/screen/screen-dump.cxx index ecea8659..ff3e9b71 100644 --- a/simgear/screen/screen-dump.cxx +++ b/simgear/screen/screen-dump.cxx @@ -65,10 +65,16 @@ bool sg_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int for (k = 0; k < RGB3; k++) ibuffer[q++] = (unsigned char) *(buffer + (pixelSize*((win_height-1-i)*win_width+j)+k)); - fwrite(ibuffer, sizeof(unsigned char), RGB3*win_width*win_height, fp); + int written = fwrite(ibuffer, sizeof(unsigned char), RGB3*win_width*win_height, fp); fclose(fp); free(ibuffer); + if ( written != RGB3*win_width*win_height ) + { + printf("Warning: failed to write %s. File truncated.\n", filename); + return false; + } + printf("wrote file '%s' (%d x %d pixels, %d bytes)\n", filename, win_width, win_height, RGB3*win_width*win_height); return true; diff --git a/simgear/sound/sample_openal.hxx b/simgear/sound/sample_openal.hxx index 35aabab9..a231f663 100644 --- a/simgear/sound/sample_openal.hxx +++ b/simgear/sound/sample_openal.hxx @@ -85,7 +85,7 @@ public: virtual ~SGSoundSample (); /** - * Detect wheter this audio sample holds the information of a sound file. + * Detect whether this audio sample holds the information of a sound file. * @return Return true if this audio sample is to be constructed from a file. */ inline bool is_file() const { return _is_file; } @@ -103,7 +103,7 @@ public: } /** - * Test if static dataa of audio sample configuration has changed. + * Test if static data of audio sample configuration has changed. * Calling this function will reset the flag so calling it a second * time in a row will return false. * @return Return true is the static data has changed in the mean time. diff --git a/simgear/timing/timezone.cxx b/simgear/timing/timezone.cxx index 11884918..3a8fa7fc 100644 --- a/simgear/timing/timezone.cxx +++ b/simgear/timing/timezone.cxx @@ -143,7 +143,7 @@ SGTimeZoneContainer::SGTimeZoneContainer(const char *filename) errno = 0; while (1) { - fgets(buffer, 256, infile); + (void) fgets(buffer, 256, infile); if (feof(infile)) { break; } -- 2.39.5