diff options
author | Simon Howard | 2010-05-01 19:22:52 +0000 |
---|---|---|
committer | Simon Howard | 2010-05-01 19:22:52 +0000 |
commit | 928963656d68dbface669773eecfb6b22ba15da5 (patch) | |
tree | 8bf89797facde17bf99d9f96737084f81517dacf | |
parent | f151517ba6b7e7caf7b49e8ceafbf0969959e068 (diff) | |
download | chocolate-doom-928963656d68dbface669773eecfb6b22ba15da5.tar.gz chocolate-doom-928963656d68dbface669773eecfb6b22ba15da5.tar.bz2 chocolate-doom-928963656d68dbface669773eecfb6b22ba15da5.zip |
Fix compiler warnings with savegame and response file code.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1926
-rw-r--r-- | src/g_game.c | 4 | ||||
-rw-r--r-- | src/m_argv.c | 9 | ||||
-rw-r--r-- | src/p_saveg.c | 22 | ||||
-rw-r--r-- | src/p_saveg.h | 1 |
4 files changed, 32 insertions, 4 deletions
diff --git a/src/g_game.c b/src/g_game.c index 542c1a7d..b0532f42 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1490,6 +1490,8 @@ void G_DoLoadGame (void) return; } + savegame_error = false; + if (!P_ReadSaveGameHeader()) { fclose(save_stream); @@ -1557,6 +1559,8 @@ void G_DoSaveGame (void) return; } + savegame_error = false; + P_WriteSaveGameHeader(savedescription); P_ArchivePlayers (); diff --git a/src/m_argv.c b/src/m_argv.c index 78404d35..7fc15863 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -89,12 +89,17 @@ static void LoadResponseFile(int argv_index) size = M_FileLength(handle); // Read in the entire file - // Allocate one byte extra - this is incase there is an argument + // Allocate one byte extra - this is in case there is an argument // at the end of the response file, in which case a '\0' will be // needed. file = malloc(size + 1); - fread(file, size, 1, handle); + + if (fread(file, 1, size, handle) < size) + { + I_Error("Failed to read entire response file"); + } + fclose(handle); // Create new arguments list array diff --git a/src/p_saveg.c b/src/p_saveg.c index e557e494..d2a4393d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -44,6 +44,7 @@ FILE *save_stream; int savegamelength; +boolean savegame_error; // Get the filename of a temporary file to write the savegame to. After // the file has been successfully saved, it will be renamed to the @@ -88,14 +89,31 @@ static byte saveg_read8(void) { byte result; - fread(&result, 1, 1, save_stream); + if (fread(&result, 1, 1, save_stream) < 1) + { + if (!savegame_error) + { + fprintf(stderr, "saveg_read8: Unexpected end of file while " + "reading save game\n"); + + savegame_error = true; + } + } return result; } static void saveg_write8(byte value) { - fwrite(&value, 1, 1, save_stream); + if (fwrite(&value, 1, 1, save_stream) < 1) + { + if (!savegame_error) + { + fprintf(stderr, "saveg_write8: Error while writing save game\n"); + + savegame_error = true; + } + } } static short saveg_read16(void) diff --git a/src/p_saveg.h b/src/p_saveg.h index 3a96cc3e..5488289c 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -64,6 +64,7 @@ void P_ArchiveSpecials (void); void P_UnArchiveSpecials (void); extern FILE *save_stream; +extern boolean savegame_error; #endif |