[vlc-commits] commit: SaveConfigFile: correctly an error on I/O failure ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat Jul 24 15:12:22 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jul 24 16:10:55 2010 +0300| [02cae56912301b19c936a0155a8e11391eac2da9] | committer: Rémi Denis-Courmont 

SaveConfigFile: correctly an error on I/O failure

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=02cae56912301b19c936a0155a8e11391eac2da9
---

 src/config/file.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/config/file.c b/src/config/file.c
index 0582483..0d3f6b6 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -437,7 +437,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     if( config_PrepareDir( p_this ) )
     {
         msg_Err( p_this, "no configuration directory" );
-        goto error;
+        return -1;
     }
 
     file = config_OpenConfigFile( p_this );
@@ -557,6 +557,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     file = fdopen (fd, "wt");
     if (file == NULL)
     {
+        msg_Err (p_this, "cannot create configuration file: %m");
         vlc_rwlock_unlock (&config_lock);
         close (fd);
         vlc_mutex_unlock (&lock);
@@ -704,6 +705,14 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
      * Flush to disk and replace atomically
      */
     fflush (file); /* Flush from run-time */
+    if (ferror (file))
+    {
+        vlc_unlink (temporary);
+        vlc_mutex_unlock (&lock);
+        msg_Err (p_this, "cannot write configuration file");
+        clearerr (file);
+        goto error;
+    }
 #ifndef WIN32
 #ifdef __APPLE__
     fsync (fd); /* Flush from OS */



More information about the vlc-commits mailing list