]> git.sesse.net Git - vlc/commitdiff
src: use vlc_strerror_c() for log messages
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 28 Dec 2013 16:46:52 +0000 (18:46 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 29 Dec 2013 13:36:02 +0000 (15:36 +0200)
src/config/file.c
src/input/es_out_timeshift.c
src/libvlc.c
src/misc/image.c
src/modules/cache.c
src/network/httpd.c
src/network/io.c
src/network/tcp.c
src/network/udp.c
src/playlist/art.c
src/playlist/loadsave.c

index 1c0b876883d138e8e084b5f82ffe8a4ded305bcb..8fec5c113dd01631c68f86ea638e6f6a1556dc28 100644 (file)
@@ -84,8 +84,8 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj )
     FILE *p_stream = vlc_fopen( psz_filename, "rt" );
     if( p_stream == NULL && errno != ENOENT )
     {
-        msg_Err( p_obj, "cannot open config file (%s): %m",
-                 psz_filename );
+        msg_Err( p_obj, "cannot open config file (%s): %s",
+                 psz_filename, vlc_strerror_c(errno) );
 
     }
 #if !( defined(_WIN32) || defined(__APPLE__) || defined(__OS2__) )
@@ -229,8 +229,9 @@ int config_LoadConfigFile( vlc_object_t *p_this )
                 if ((l > item->max.i) || (l < item->min.i))
                     errno = ERANGE;
                 if (errno)
-                    msg_Warn (p_this, "Integer value (%s) for %s: %m",
-                              psz_option_value, psz_option_name);
+                    msg_Warn (p_this, "Integer value (%s) for %s: %s",
+                              psz_option_value, psz_option_name,
+                              vlc_strerror_c(errno));
                 else
                     item->value.i = l;
                 break;
@@ -253,7 +254,8 @@ int config_LoadConfigFile( vlc_object_t *p_this )
 
     if (ferror (file))
     {
-        msg_Err (p_this, "error reading configuration: %m");
+        msg_Err (p_this, "error reading configuration: %s",
+                 vlc_strerror_c(errno));
         clearerr (file);
     }
     fclose (file);
@@ -300,7 +302,8 @@ int config_CreateDir( vlc_object_t *p_this, const char *psz_dirname )
         }
     }
 
-    msg_Warn( p_this, "could not create %s: %m", psz_dirname );
+    msg_Warn( p_this, "could not create %s: %s", psz_dirname,
+              vlc_strerror_c(errno) );
     return -1;
 }
 
@@ -399,7 +402,8 @@ int config_SaveConfigFile (vlc_object_t *p_this)
     FILE *file = fdopen (fd, "wt");
     if (file == NULL)
     {
-        msg_Err (p_this, "cannot create configuration file: %m");
+        msg_Err (p_this, "cannot create configuration file: %s",
+                 vlc_strerror_c(errno));
         vlc_rwlock_unlock (&config_lock);
         close (fd);
         vlc_mutex_unlock (&lock);
index 0864efb97ad0d3c6fff4c4846542395e3003a6de..9c57832b49ac35841aa51fb2dd8396e12bd34fe8 100644 (file)
@@ -1199,7 +1199,7 @@ static void TsStoragePopCmd( ts_storage_t *p_storage, ts_cmd_t *p_cmd, bool b_fl
         }
         else
         {
-            //fprintf( stderr, "TsStoragePopCmd: %m\n" );
+            //perror( "TsStoragePopCmd" );
             p_cmd->u.send.p_block = block_Alloc( 1 );
         }
     }
index 606d8ed01577cebf8f24e2419ad806aa0dc86637..71e7faf484946117a60e20c980cf611f324b526f 100644 (file)
@@ -46,6 +46,7 @@
 #include <stdio.h>                                              /* sprintf() */
 #include <string.h>
 #include <stdlib.h>                                                /* free() */
+#include <errno.h>
 
 #include "config/vlc_getopt.h"
 
@@ -235,8 +236,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
             }
             else
             {
-                msg_Err( p_libvlc, "cannot open pid file for writing: %s (%m)",
-                         psz_pidfile );
+                msg_Err( p_libvlc, "cannot open pid file %s for writing: %s",
+                         psz_pidfile, vlc_strerror_c(errno) );
             }
         }
         free( psz_pidfile );
@@ -562,8 +563,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
             msg_Dbg( p_libvlc, "removing pid file %s", psz_pidfile );
             if( unlink( psz_pidfile ) == -1 )
             {
-                msg_Dbg( p_libvlc, "removing pid file %s: %m",
-                        psz_pidfile );
+                msg_Dbg( p_libvlc, "removing pid file %s: %s",
+                        psz_pidfile, vlc_strerror_c(errno) );
             }
         }
         free( psz_pidfile );
index e0a3ad8412f99e30e010b09497e7c2c85f711226..648925915f7b86bd5eaf2a4be0139c4d7560b04b 100644 (file)
@@ -385,7 +385,7 @@ static int ImageWriteUrl( image_handler_t *p_image, picture_t *p_pic,
     file = vlc_fopen( psz_url, "wb" );
     if( !file )
     {
-        msg_Err( p_image->p_parent, "%s: %m", psz_url );
+        msg_Err( p_image->p_parent, "%s: %s", psz_url, vlc_strerror_c(errno) );
         return VLC_EGENERIC;
     }
 
@@ -405,7 +405,7 @@ static int ImageWriteUrl( image_handler_t *p_image, picture_t *p_pic,
     if( err )
     {
        errno = err;
-       msg_Err( p_image->p_parent, "%s: %m", psz_url );
+       msg_Err( p_image->p_parent, "%s: %s", psz_url, vlc_strerror_c(errno) );
     }
 
     return err ? VLC_EGENERIC : VLC_SUCCESS;
index 5d9651fcf2ee1fb6c5a2fda272b740dc4c950952..ddf3f98f5f8fd4992c8f15696a494d15a9a520e4 100644 (file)
@@ -245,8 +245,8 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t **r )
     file = vlc_fopen( psz_filename, "rb" );
     if( !file )
     {
-        msg_Warn( p_this, "cannot read %s (%m)",
-                  psz_filename );
+        msg_Warn( p_this, "cannot read %s: %s", psz_filename,
+                  vlc_strerror_c(errno) );
         free( psz_filename );
         return 0;
     }
@@ -499,13 +499,15 @@ void CacheSave (vlc_object_t *p_this, const char *dir,
     if (file == NULL)
     {
         if (errno != EACCES && errno != ENOENT)
-            msg_Warn (p_this, "cannot create %s (%m)", tmpname);
+            msg_Warn (p_this, "cannot create %s: %s", tmpname,
+                      vlc_strerror_c(errno));
         goto out;
     }
 
     if (CacheSaveBank (file, entries, n))
     {
-        msg_Warn (p_this, "cannot write %s (%m)", tmpname);
+        msg_Warn (p_this, "cannot write %s: %s", tmpname,
+                  vlc_strerror_c(errno));
         clearerr (file);
         fclose (file);
         vlc_unlink (tmpname);
index ff7e653777dfb7da2509e82d91afd937274c6815..53b7511a95690715ff87ba575bac15f0f92b9b5b 100644 (file)
@@ -1052,7 +1052,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
 
     if( vlc_object_waitpipe( VLC_OBJECT( host ) ) == -1 )
     {
-        msg_Err( host, "signaling pipe error: %m" );
+        msg_Err( host, "signaling pipe error: %s", vlc_strerror_c(errno) );
         goto error;
     }
 
@@ -2292,7 +2292,8 @@ static void* httpd_HostThread( void *data )
                 if (errno != EINTR)
                 {
                     /* Kernel on low memory or a bug: pace */
-                    msg_Err( host, "polling error: %m" );
+                    msg_Err( host, "polling error: %s",
+                             vlc_strerror_c(errno) );
                     msleep( 100000 );
                 }
             case 0:
index 6cadffaba54bb86970d2e301a7eaf75751473e1b..abf07a4b0e528455493fd4e662ff34c1b4be5891 100644 (file)
@@ -85,7 +85,8 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
     if (fd == -1)
     {
         if (net_errno != EAFNOSUPPORT)
-            msg_Err (p_this, "cannot create socket: %m");
+            msg_Err (p_this, "cannot create socket: %s",
+                     vlc_strerror_c(net_errno));
         return -1;
     }
 
@@ -158,7 +159,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
                              ptr->ai_protocol);
         if (fd == -1)
         {
-            msg_Dbg (p_this, "socket error: %m");
+            msg_Dbg (p_this, "socket error: %s", vlc_strerror_c(net_errno));
             continue;
         }
 
@@ -198,7 +199,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
             else
 #endif
             {
-                msg_Err (p_this, "socket bind error (%m)");
+                msg_Err (p_this, "socket bind error: %s",
+                         vlc_strerror_c(net_errno));
                 continue;
             }
         }
@@ -223,7 +225,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
 #endif
                 if (listen (fd, INT_MAX))
                 {
-                    msg_Err (p_this, "socket listen error (%m)");
+                    msg_Err (p_this, "socket listen error: %s",
+                             vlc_strerror_c(net_errno));
                     net_Close (fd);
                     continue;
                 }
@@ -360,7 +363,7 @@ do_poll:
 
     return i_total;
 error:
-    msg_Err (p_this, "read error: %m");
+    msg_Err (p_this, "read error: %s", vlc_strerror_c(errno));
     return -1;
 }
 
@@ -400,7 +403,7 @@ ssize_t net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
         {
             if (errno == EINTR)
                 continue;
-            msg_Err (p_this, "Polling error: %m");
+            msg_Err (p_this, "Polling error: %s", vlc_strerror_c(errno));
             return -1;
         }
 
@@ -435,7 +438,7 @@ ssize_t net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
         {
             if (errno == EINTR)
                 continue;
-            msg_Err (p_this, "Write error: %m");
+            msg_Err (p_this, "Write error: %s", vlc_strerror_c(errno));
             break;
         }
 
index 9cf1c44e73c04031d21be2e1c1580c4a95cc7f46..d968ae86d3ab6ad93a0f61c6bcffdb40decaeb53 100644 (file)
@@ -158,7 +158,7 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
                              ptr->ai_socktype, ptr->ai_protocol );
         if( fd == -1 )
         {
-            msg_Dbg( p_this, "socket error: %m" );
+            msg_Dbg( p_this, "socket error: %s", vlc_strerror_c(net_errno) );
             continue;
         }
 
@@ -168,7 +168,8 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
 
             if( net_errno != EINPROGRESS && net_errno != EINTR )
             {
-                msg_Err( p_this, "connection failed: %m" );
+                msg_Err( p_this, "connection failed: %s",
+                         vlc_strerror_c(net_errno) );
                 goto next_ai;
             }
 
@@ -185,7 +186,8 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
             switch (val)
             {
                  case -1: /* error */
-                     msg_Err (p_this, "connection polling error: %m");
+                     msg_Err (p_this, "polling error: %s",
+                              vlc_strerror_c(net_errno));
                      goto next_ai;
 
                  case 0: /* timeout */
@@ -202,8 +204,8 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
             if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &val,
                             &(socklen_t){ sizeof (val) }) || val)
             {
-                errno = val;
-                msg_Err (p_this, "connection failed: %m");
+                msg_Err (p_this, "connection failed: %s",
+                         vlc_strerror_c(val));
                 goto next_ai;
             }
         }
@@ -250,7 +252,8 @@ int net_AcceptSingle (vlc_object_t *obj, int lfd)
     if (fd == -1)
     {
         if (net_errno != EAGAIN && net_errno != EWOULDBLOCK)
-            msg_Err (obj, "accept failed (from socket %d): %m", lfd);
+            msg_Err (obj, "accept failed (from socket %d): %s", lfd,
+                     vlc_strerror_c(net_errno));
         return -1;
     }
 
@@ -297,7 +300,7 @@ int net_Accept (vlc_object_t *p_this, int *pi_fd)
         {
             if (net_errno != EINTR)
             {
-                msg_Err (p_this, "poll error: %m");
+                msg_Err (p_this, "poll error: %s", vlc_strerror_c(net_errno));
                 return -1;
             }
         }
index c02da8c6e1084bcdc8212b41923dbbd3d6d3ea99..ce4e419e05e0a716e7c3725b5b0f4dfc491668fb 100644 (file)
@@ -113,7 +113,7 @@ static int net_SetupDgramSocket (vlc_object_t *p_obj, int fd,
 #endif
     if (bind (fd, ptr->ai_addr, ptr->ai_addrlen))
     {
-        msg_Err( p_obj, "socket bind error (%m)" );
+        msg_Err( p_obj, "socket bind error: %s", vlc_strerror_c(net_errno) );
         net_Close (fd);
         return -1;
     }
@@ -152,7 +152,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
                              ptr->ai_protocol);
         if (fd == -1)
         {
-            msg_Dbg (obj, "socket error: %m");
+            msg_Dbg (obj, "socket error: %s", vlc_strerror_c(net_errno));
             continue;
         }
 
@@ -208,7 +208,7 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this,
 
         default:
             errno = EAFNOSUPPORT;
-            msg_Warn( p_this, "%m" );
+            msg_Warn( p_this, "%s", vlc_strerror_c(EAFNOSUPPORT) );
             return VLC_EGENERIC;
     }
 
@@ -217,11 +217,13 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this,
         /* BSD compatibility */
         unsigned char buf;
 
-        msg_Dbg( p_this, "cannot set hop limit (%d): %m", hlim );
+        msg_Dbg( p_this, "cannot set hop limit (%d): %s", hlim,
+                 vlc_strerror_c(net_errno) );
         buf = (unsigned char)(( hlim > 255 ) ? 255 : hlim);
         if( setsockopt( fd, proto, cmd, &buf, sizeof( buf ) ) )
         {
-            msg_Err( p_this, "cannot set hop limit (%d): %m", hlim );
+            msg_Err( p_this, "cannot set hop limit (%d): %s", hlim,
+                     vlc_strerror_c(net_errno) );
             return VLC_EGENERIC;
         }
     }
@@ -263,7 +265,8 @@ static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
         default:
             errno = EAFNOSUPPORT;
     }
-    msg_Err (p_this, "cannot force multicast interface %s: %m", iface);
+    msg_Err (p_this, "cannot force multicast interface %s: %s", iface,
+             vlc_strerror_c(errno));
     return -1;
 }
 
@@ -360,7 +363,8 @@ net_SourceSubscribe (vlc_object_t *obj, int fd,
     }
 
 #endif
-    msg_Err (obj, "cannot join source multicast group: %m");
+    msg_Err (obj, "cannot join source multicast group: %s",
+             vlc_strerror_c(net_errno));
     msg_Warn (obj, "trying ASM instead of SSM...");
     return net_Subscribe (obj, fd, grp, grplen);
 }
@@ -444,7 +448,8 @@ int net_Subscribe (vlc_object_t *obj, int fd,
     }
 
 #endif
-    msg_Err (obj, "cannot join multicast group: %m");
+    msg_Err (obj, "cannot join multicast group: %s",
+             vlc_strerror_c(net_errno));
     return -1;
 }
 
@@ -549,7 +554,8 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
 #endif
             b_unreach = true;
         else
-            msg_Warn( p_this, "%s port %d : %m", psz_host, i_port);
+            msg_Warn( p_this, "%s port %d : %s", psz_host, i_port,
+                      vlc_strerror_c(errno) );
         net_Close( fd );
     }
 
@@ -630,8 +636,8 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
                                      ptr->ai_addr, ptr->ai_addrlen)
               : connect (fd, ptr2->ai_addr, ptr2->ai_addrlen))
             {
-                msg_Err (obj, "cannot connect to %s port %d: %m",
-                         psz_server, i_server);
+                msg_Err (obj, "cannot connect to %s port %d: %s",
+                         psz_server, i_server, vlc_strerror_c(net_errno));
                 continue;
             }
             val = fd;
index 9a93762ee044de5136486fa8e8c31cab9e2fe26b..2aede11d61b56dee188d291513e103dad7fe0d6c 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <assert.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 #include <vlc_common.h>
 #include <vlc_playlist.h>
@@ -297,7 +298,7 @@ int playlist_SaveArt( vlc_object_t *obj, input_item_t *p_item,
     {
         if( fwrite( data, 1, length, f ) != length )
         {
-            msg_Err( obj, "%s: %m", psz_filename );
+            msg_Err( obj, "%s: %s", psz_filename, vlc_strerror_c(errno) );
         }
         else
         {
@@ -327,7 +328,8 @@ int playlist_SaveArt( vlc_object_t *obj, input_item_t *p_item,
         if ( f )
         {
             if( fputs( "file://", f ) < 0 || fputs( psz_filename, f ) < 0 )
-                msg_Err( obj, "Error writing %s: %m", psz_byuidfile );
+                msg_Err( obj, "Error writing %s: %s", psz_byuidfile,
+                         vlc_strerror_c(errno) );
             fclose( f );
         }
         free( psz_byuidfile );
index 85a3e9eb8bb54d966038a385b86f574f99f280ec..a789c9f7ce7f195b7ce0c88acbe875f2d479d758 100644 (file)
@@ -24,6 +24,7 @@
 # include "config.h"
 #endif
 
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -57,8 +58,8 @@ int playlist_Export( playlist_t * p_playlist, const char *psz_filename,
     p_export->psz_filename = psz_filename;
     p_export->p_file = vlc_fopen( psz_filename, "wt" );
     if( p_export->p_file == NULL )
-        msg_Err( p_export, "could not create playlist file %s (%m)",
-                 psz_filename );
+        msg_Err( p_export, "could not create playlist file %s: %s",
+                 psz_filename, vlc_strerror_c(errno) );
     else
     {
         module_t *p_module;