[vlc-commits] file: use vlc_strerror()

Rémi Denis-Courmont git at videolan.org
Sun Dec 29 15:16:26 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec 28 17:57:55 2013 +0200| [a059cf56c964cd8fd1b60f22d12d6fc63b218d89] | committer: Rémi Denis-Courmont

file: use vlc_strerror()

This fixes "%m" in error dialogs on non-GNU platforms.

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

 modules/access/file.c        |   15 +++++++++------
 modules/access_output/file.c |   11 +++++++----
 modules/audio_output/file.c  |   13 ++++++++-----
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/modules/access/file.c b/modules/access/file.c
index 01194bf..6d4423e 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -172,9 +172,11 @@ int FileOpen( vlc_object_t *p_this )
         fd = vlc_open (path, O_RDONLY | O_NONBLOCK);
         if (fd == -1)
         {
-            msg_Err (p_access, "cannot open file %s (%m)", path);
+            msg_Err (p_access, "cannot open file %s (%s)", path,
+                     vlc_strerror_c(errno));
             dialog_Fatal (p_access, _("File reading failed"),
-                          _("VLC could not open the file \"%s\" (%m)."), path);
+                          _("VLC could not open the file \"%s\" (%s)."), path,
+                          vlc_strerror(errno));
         }
     }
     if (fd == -1)
@@ -183,7 +185,7 @@ int FileOpen( vlc_object_t *p_this )
     struct stat st;
     if (fstat (fd, &st))
     {
-        msg_Err (p_access, "failed to read (%m)");
+        msg_Err (p_access, "read error: %s", vlc_strerror_c(errno));
         goto error;
     }
 
@@ -295,9 +297,10 @@ static ssize_t FileRead (access_t *p_access, uint8_t *p_buffer, size_t i_len)
                 return -1;
         }
 
-        msg_Err (p_access, "read error: %m");
+        msg_Err (p_access, "read error: %s", vlc_strerror_c(errno));
         dialog_Fatal (p_access, _("File reading failed"),
-                      _("VLC could not read the file (%m)."));
+                      _("VLC could not read the file (%s)."),
+                      vlc_strerror(errno));
         val = 0;
     }
 
@@ -348,7 +351,7 @@ static ssize_t StreamRead (access_t *p_access, uint8_t *p_buffer, size_t i_len)
             case EAGAIN:
                 return -1;
         }
-        msg_Err (p_access, "read error: %m");
+        msg_Err (p_access, "read error: %s", vlc_strerror_c(errno));
         val = 0;
     }
 
diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index 61192c2..846a0b3 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -149,7 +149,8 @@ static int Open( vlc_object_t *p_this )
         fd = vlc_dup (fd);
         if (fd == -1)
         {
-            msg_Err (p_access, "cannot use file descriptor: %m");
+            msg_Err (p_access, "cannot use file descriptor: %s",
+                     vlc_strerror_c(errno));
             return VLC_EGENERIC;
         }
     }
@@ -162,7 +163,8 @@ static int Open( vlc_object_t *p_this )
         fd = vlc_dup (STDOUT_FILENO);
         if (fd == -1)
         {
-            msg_Err (p_access, "cannot use standard output: %m");
+            msg_Err (p_access, "cannot use standard output: %s",
+                     vlc_strerror_c(errno));
             return VLC_EGENERIC;
         }
         msg_Dbg( p_access, "using stdout" );
@@ -194,7 +196,8 @@ static int Open( vlc_object_t *p_this )
             if (fd != -1)
                 break;
             if (fd == -1)
-                msg_Err (p_access, "cannot create %s: %m", path);
+                msg_Err (p_access, "cannot create %s: %s", path,
+                         vlc_strerror_c(errno));
             if (overwrite || errno != EEXIST)
                 break;
             flags &= ~O_EXCL;
@@ -293,7 +296,7 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
             if (errno == EINTR)
                 continue;
             block_ChainRelease (p_buffer);
-            msg_Err( p_access, "cannot write: %m" );
+            msg_Err( p_access, "cannot write: %s", vlc_strerror_c(errno) );
             return -1;
         }
 
diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
index 5773acc..f34c4c7 100644
--- a/modules/audio_output/file.c
+++ b/modules/audio_output/file.c
@@ -30,6 +30,9 @@
 # include "config.h"
 #endif
 
+#include <stdio.h>
+#include <errno.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
@@ -254,7 +257,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
         if( fwrite( wh, sizeof(WAVEHEADER), 1,
                     p_aout->sys->p_file ) != 1 )
         {
-            msg_Err( p_aout, "write error (%m)" );
+            msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
         }
     }
 
@@ -277,7 +280,7 @@ static void Stop( audio_output_t *p_aout )
         /* Write Wave Header */
         if( fseek( p_aout->sys->p_file, 0, SEEK_SET ) )
         {
-            msg_Err( p_aout, "seek error (%m)" );
+            msg_Err( p_aout, "seek error: %s", vlc_strerror_c(errno) );
         }
 
         /* Header -> little endian format */
@@ -289,7 +292,7 @@ static void Stop( audio_output_t *p_aout )
         if( fwrite( &p_aout->sys->waveh, sizeof(WAVEHEADER), 1,
                     p_aout->sys->p_file ) != 1 )
         {
-            msg_Err( p_aout, "write error (%m)" );
+            msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
         }
     }
 
@@ -306,7 +309,7 @@ static void Play( audio_output_t * p_aout, block_t *p_buffer )
     if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1,
                 p_aout->sys->p_file ) != 1 )
     {
-        msg_Err( p_aout, "write error (%m)" );
+        msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
     }
 
     if( p_aout->sys->b_add_wav_header )
@@ -321,7 +324,7 @@ static void Play( audio_output_t * p_aout, block_t *p_buffer )
 static void Flush( audio_output_t *aout, bool wait )
 {
     if( fflush( aout->sys->p_file ) )
-        msg_Err( aout, "flush error (%m)" );
+        msg_Err( aout, "flush error: %s", vlc_strerror_c(errno) );
     (void) wait;
 }
 



More information about the vlc-commits mailing list