Commit 9ff28119 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

src: use vlc_strerror_c() for log messages

parent 4e7185eb
......@@ -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);
......
......@@ -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 );
}
}
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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);
......
......@@ -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:
......
......@@ -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;
}
......
......@@ -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;
}
}
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment