From f365b9d8f7e6a74cfcf0b69c13c0876b2acacc5f Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 11 Jan 2009 17:57:36 -0600 Subject: [PATCH] Add some error checking to unjournaled state save/load. --- Timeline/Loggable.C | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index aad7826..bc0225b 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -143,7 +143,10 @@ Loggable::load_unjournaled_state ( void ) fp = fopen( "unjournaled", "r" ); if ( ! fp ) + { + DWARNING( "Could not open unjournaled state file for reading" ); return false; + } unsigned int id; char buf[BUFSIZ]; @@ -239,12 +242,16 @@ Loggable::close ( void ) bool Loggable::save_unjournaled_state ( void ) { + FILE *fp; - /* FIXME: check for errors */ - FILE *fp = fopen( "unjournaled", "w" ); + fp = fopen( "unjournaled", "w" ); + + if ( ! fp ) + { + DWARNING( "Could not open unjournaled state file for writing!" ); + return false; + } - /* write out the unjournaled state of all currently active - * loggables */ for ( std::map ::iterator i = _loggables_unjournaled.begin(); i != _loggables_unjournaled.end(); ++i ) { @@ -258,8 +265,6 @@ Loggable::save_unjournaled_state ( void ) } } - /* write out the remembered state of inactive loggables. */ - fclose( fp ); return true;