Commit 4ff99618 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix the most common strerror() usages (threads, network, input) - refs #1297

parent 357771f9
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> /* strerror() */ #include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
......
...@@ -63,7 +63,6 @@ extern const char *net_strerror( int val ); ...@@ -63,7 +63,6 @@ extern const char *net_strerror( int val );
# endif # endif
# include <netdb.h> # include <netdb.h>
# define net_errno errno # define net_errno errno
# define net_strerror strerror
#endif #endif
# ifdef __cplusplus # ifdef __cplusplus
......
...@@ -81,7 +81,6 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line, ...@@ -81,7 +81,6 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
int i_result; int i_result;
/* In case of error : */ /* In case of error : */
unsigned long int i_thread = 0; unsigned long int i_thread = 0;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
i_result = ( pth_mutex_acquire( &p_mutex->mutex, FALSE, NULL ) == FALSE ); i_result = ( pth_mutex_acquire( &p_mutex->mutex, FALSE, NULL ) == FALSE );
...@@ -126,7 +125,7 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line, ...@@ -126,7 +125,7 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
if ( i_result ) if ( i_result )
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_result); errno = i_result;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -138,8 +137,8 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line, ...@@ -138,8 +137,8 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
if( i_result ) if( i_result )
{ {
msg_Err( p_mutex->p_this, msg_Err( p_mutex->p_this,
"thread %li: mutex_lock failed at %s:%d (%d:%s)", "thread %li: mutex_lock failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_result, psz_error ); i_thread, psz_file, i_line, i_result );
} }
return i_result; return i_result;
} }
...@@ -160,7 +159,6 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line, ...@@ -160,7 +159,6 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
int i_result; int i_result;
/* In case of error : */ /* In case of error : */
unsigned long int i_thread = 0; unsigned long int i_thread = 0;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
i_result = ( pth_mutex_release( &p_mutex->mutex ) == FALSE ); i_result = ( pth_mutex_release( &p_mutex->mutex ) == FALSE );
...@@ -203,7 +201,7 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line, ...@@ -203,7 +201,7 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
if ( i_result ) if ( i_result )
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_result); errno = i_result;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -215,8 +213,8 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line, ...@@ -215,8 +213,8 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
if( i_result ) if( i_result )
{ {
msg_Err( p_mutex->p_this, msg_Err( p_mutex->p_this,
"thread %li: mutex_unlock failed at %s:%d (%d:%s)", "thread %li: mutex_unlock failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_result, psz_error ); i_thread, psz_file, i_line, i_result );
} }
return i_result; return i_result;
...@@ -246,7 +244,6 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line, ...@@ -246,7 +244,6 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line,
int i_result; int i_result;
/* In case of error : */ /* In case of error : */
unsigned long int i_thread = 0; unsigned long int i_thread = 0;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
i_result = ( pth_cond_notify( &p_condvar->cond, FALSE ) == FALSE ); i_result = ( pth_cond_notify( &p_condvar->cond, FALSE ) == FALSE );
...@@ -341,7 +338,7 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line, ...@@ -341,7 +338,7 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line,
if ( i_result ) if ( i_result )
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_result); errno = i_result;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -357,8 +354,8 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line, ...@@ -357,8 +354,8 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line,
if( i_result ) if( i_result )
{ {
msg_Err( p_condvar->p_this, msg_Err( p_condvar->p_this,
"thread %li: cond_signal failed at %s:%d (%d:%s)", "thread %li: cond_signal failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_result, psz_error ); i_thread, psz_file, i_line, i_result );
} }
return i_result; return i_result;
...@@ -376,7 +373,6 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line, ...@@ -376,7 +373,6 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
int i_result; int i_result;
/* In case of error : */ /* In case of error : */
unsigned long int i_thread = 0; unsigned long int i_thread = 0;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
i_result = ( pth_cond_await( &p_condvar->cond, &p_mutex->mutex, NULL ) i_result = ( pth_cond_await( &p_condvar->cond, &p_mutex->mutex, NULL )
...@@ -513,10 +509,11 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line, ...@@ -513,10 +509,11 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
if( i_result == ETIMEDOUT ) if( i_result == ETIMEDOUT )
{ {
errno = ETIMEDOUT;
msg_Dbg( p_condvar->p_this, msg_Dbg( p_condvar->p_this,
"thread %li: possible condition deadlock " "thread %li: possible condition deadlock "
"at %s:%d (%s)", CAST_PTHREAD_TO_INT(pthread_self()), "at %s:%d (%m)", CAST_PTHREAD_TO_INT(pthread_self()),
psz_file, i_line, strerror(i_result) ); psz_file, i_line );
i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex ); i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
} }
...@@ -528,7 +525,7 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line, ...@@ -528,7 +525,7 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
if ( i_result ) if ( i_result )
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_result); errno = i_result;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -540,8 +537,8 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line, ...@@ -540,8 +537,8 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
if( i_result ) if( i_result )
{ {
msg_Err( p_condvar->p_this, msg_Err( p_condvar->p_this,
"thread %li: cond_wait failed at %s:%d (%d:%s)", "thread %li: cond_wait failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_result, psz_error ); i_thread, psz_file, i_line, i_result );
} }
return i_result; return i_result;
...@@ -563,7 +560,6 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line, ...@@ -563,7 +560,6 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
{ {
int i_res; int i_res;
unsigned long int i_thread = 0; unsigned long int i_thread = 0;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
# error Unimplemented # error Unimplemented
...@@ -588,7 +584,7 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line, ...@@ -588,7 +584,7 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
if ( i_res ) /* other errors = bug */ if ( i_res ) /* other errors = bug */
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_res); errno = i_res;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -598,8 +594,8 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line, ...@@ -598,8 +594,8 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
if( i_res ) if( i_res )
{ {
msg_Err( p_condvar->p_this, msg_Err( p_condvar->p_this,
"thread %li: cond_wait failed at %s:%d (%d:%s)", "thread %li: cond_wait failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_res, psz_error ); i_thread, psz_file, i_line, i_res );
} }
return i_res; return i_res;
......
...@@ -458,7 +458,10 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -458,7 +458,10 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
stream_Delete( p_stream ); stream_Delete( p_stream );
if( err ) if( err )
msg_Err( p_playlist, "%s: %s", psz_filename, strerror( err ) ); {
errno = err;
msg_Err( p_playlist, "%s: %m", psz_filename );
}
else else
msg_Dbg( p_playlist, "album art saved to %s\n", psz_filename ); msg_Dbg( p_playlist, "album art saved to %s\n", psz_filename );
...@@ -545,7 +548,7 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input ) ...@@ -545,7 +548,7 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
if( f ) if( f )
{ {
if( fwrite( p_attachment->p_data, p_attachment->i_data, 1, f ) != 1 ) if( fwrite( p_attachment->p_data, p_attachment->i_data, 1, f ) != 1 )
msg_Err( p_input, "%s: %s", psz_filename, strerror( errno ) ); msg_Err( p_input, "%s: %m", psz_filename );
else else
msg_Dbg( p_input, "album art saved to %s\n", psz_filename ); msg_Dbg( p_input, "album art saved to %s\n", psz_filename );
fclose( f ); fclose( f );
......
...@@ -330,7 +330,6 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex ...@@ -330,7 +330,6 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex
int i_result; int i_result;
/* In case of error : */ /* In case of error : */
int i_thread = -1; int i_thread = -1;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
return 0; return 0;
...@@ -367,7 +366,7 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex ...@@ -367,7 +366,7 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex
if( i_result ) if( i_result )
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_result); errno = i_result;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -378,8 +377,8 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex ...@@ -378,8 +377,8 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex
if( i_result ) if( i_result )
{ {
msg_Err( p_mutex->p_this, msg_Err( p_mutex->p_this,
"thread %d: mutex_destroy failed at %s:%d (%d:%s)", "thread %d: mutex_destroy failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_result, psz_error ); i_thread, psz_file, i_line, i_result );
} }
return i_result; return i_result;
} }
...@@ -500,7 +499,6 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar ...@@ -500,7 +499,6 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar
int i_result; int i_result;
/* In case of error : */ /* In case of error : */
int i_thread = -1; int i_thread = -1;
const char * psz_error = "";
#if defined( PTH_INIT_IN_PTH_H ) #if defined( PTH_INIT_IN_PTH_H )
return 0; return 0;
...@@ -530,7 +528,7 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar ...@@ -530,7 +528,7 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar
if( i_result ) if( i_result )
{ {
i_thread = CAST_PTHREAD_TO_INT(pthread_self()); i_thread = CAST_PTHREAD_TO_INT(pthread_self());
psz_error = strerror(i_result); errno = i_result;
} }
#elif defined( HAVE_CTHREADS_H ) #elif defined( HAVE_CTHREADS_H )
...@@ -541,8 +539,8 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar ...@@ -541,8 +539,8 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar
if( i_result ) if( i_result )
{ {
msg_Err( p_condvar->p_this, msg_Err( p_condvar->p_this,
"thread %d: cond_destroy failed at %s:%d (%d:%s)", "thread %d: cond_destroy failed at %s:%d (%d:%m)",
i_thread, psz_file, i_line, i_result, psz_error ); i_thread, psz_file, i_line, i_result );
} }
return i_result; return i_result;
} }
...@@ -665,8 +663,9 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line ...@@ -665,8 +663,9 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
if( (i_error = pthread_setschedparam( p_priv->thread_id, if( (i_error = pthread_setschedparam( p_priv->thread_id,
i_policy, &param )) ) i_policy, &param )) )
{ {
msg_Warn( p_this, "couldn't set thread priority (%s:%d): %s", errno = i_error;
psz_file, i_line, strerror(i_error) ); msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
psz_file, i_line );
i_priority = 0; i_priority = 0;
} }
} }
...@@ -708,8 +707,9 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line ...@@ -708,8 +707,9 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
} }
else else
{ {
msg_Err( p_this, "%s thread could not be created at %s:%d (%s)", errno = i_ret;
psz_name, psz_file, i_line, strerror(i_ret) ); msg_Err( p_this, "%s thread could not be created at %s:%d (%m)",
psz_name, psz_file, i_line );
vlc_mutex_unlock( &p_this->object_lock ); vlc_mutex_unlock( &p_this->object_lock );
} }
...@@ -762,8 +762,9 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file, ...@@ -762,8 +762,9 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
if( (i_error = pthread_setschedparam( p_priv->thread_id, if( (i_error = pthread_setschedparam( p_priv->thread_id,
i_policy, &param )) ) i_policy, &param )) )
{ {
msg_Warn( p_this, "couldn't set thread priority (%s:%d): %s", errno = i_error;
psz_file, i_line, strerror(i_error) ); msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
psz_file, i_line );
i_priority = 0; i_priority = 0;
} }
} }
...@@ -881,9 +882,9 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line ...@@ -881,9 +882,9 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
if( i_ret ) if( i_ret )
{ {
msg_Err( p_this, "thread_join(%u) failed at %s:%d (%s)", errno = i_ret;
(unsigned int)p_priv->thread_id, psz_file, i_line, msg_Err( p_this, "thread_join(%u) failed at %s:%d (%m)",
strerror(i_ret) ); (unsigned int)p_priv->thread_id, psz_file, i_line );
} }
else else
{ {
......
...@@ -317,8 +317,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) ...@@ -317,8 +317,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
{ {
if( ferror( file ) ) if( ferror( file ) )
{ {
msg_Err( p_acl->p_owner, "error reading %s : %s\n", psz_path, msg_Err( p_acl->p_owner, "error reading %s : %m", psz_path );
strerror( errno ) );
goto error; goto error;
} }
continue; continue;
...@@ -337,7 +336,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) ...@@ -337,7 +336,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
ptr = strchr( psz_ip, '\n' ); ptr = strchr( psz_ip, '\n' );
if( ptr == NULL ) if( ptr == NULL )
{ {
msg_Warn( p_acl->p_owner, "skipping overly long line in %s\n", msg_Warn( p_acl->p_owner, "skipping overly long line in %s",
psz_path); psz_path);
do do
{ {
...@@ -345,8 +344,8 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) ...@@ -345,8 +344,8 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
{ {
if( ferror( file ) ) if( ferror( file ) )
{ {
msg_Err( p_acl->p_owner, "error reading %s : %s\n", msg_Err( p_acl->p_owner, "error reading %s : %m",
psz_path, strerror( errno ) ); psz_path );
} }
goto error; goto error;
} }
......
...@@ -2362,7 +2362,7 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2362,7 +2362,7 @@ static void httpd_HostThread( httpd_host_t *host )
if (errno != EINTR) if (errno != EINTR)
{ {
/* This is most likely a bug */ /* This is most likely a bug */
msg_Err( host, "polling error: %s", strerror (errno)); msg_Err( host, "polling error: %m" );
msleep( 1000 ); msleep( 1000 );
} }
case 0: case 0:
......
...@@ -88,8 +88,7 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype, ...@@ -88,8 +88,7 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
if (fd == -1) if (fd == -1)
{ {
if (net_errno != EAFNOSUPPORT) if (net_errno != EAFNOSUPPORT)
msg_Err (p_this, "cannot create socket: %s", msg_Err (p_this, "cannot create socket: %m");
net_strerror (net_errno));
return -1; return -1;
} }
...@@ -148,7 +147,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -148,7 +147,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
protocol ?: ptr->ai_protocol); protocol ?: ptr->ai_protocol);
if (fd == -1) if (fd == -1)
{ {
msg_Dbg (p_this, "socket error: %s", net_strerror (net_errno)); msg_Dbg (p_this, "socket error: %m");
continue; continue;
} }
...@@ -176,8 +175,6 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -176,8 +175,6 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
#endif #endif
if (bind (fd, ptr->ai_addr, ptr->ai_addrlen)) if (bind (fd, ptr->ai_addr, ptr->ai_addrlen))
{ {
int saved_errno = net_errno;
net_Close (fd); net_Close (fd);
#if !defined(WIN32) && !defined(UNDER_CE) #if !defined(WIN32) && !defined(UNDER_CE)
fd = rootwrap_bind (ptr->ai_family, ptr->ai_socktype, fd = rootwrap_bind (ptr->ai_family, ptr->ai_socktype,
...@@ -190,8 +187,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -190,8 +187,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
else else
#endif #endif
{ {
msg_Err (p_this, "socket bind error (%s)", msg_Err (p_this, "socket bind error (%m)");
net_strerror( saved_errno ) );
continue; continue;
} }
} }
...@@ -216,8 +212,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -216,8 +212,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
#endif #endif
if (listen (fd, INT_MAX)) if (listen (fd, INT_MAX))
{ {
msg_Err (p_this, "socket listen error (%s)", msg_Err (p_this, "socket listen error (%m)");
net_strerror (net_errno));
net_Close (fd); net_Close (fd);
continue; continue;
} }
...@@ -362,7 +357,7 @@ net_ReadInner (vlc_object_t *restrict p_this, unsigned fdc, const int *fdv, ...@@ -362,7 +357,7 @@ net_ReadInner (vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
return i_total; return i_total;
error: error:
msg_Err (p_this, "Read error: %s", net_strerror (net_errno)); msg_Err (p_this, "Read error: %m");
return i_total ? (ssize_t)i_total : -1; return i_total ? (ssize_t)i_total : -1;
} }
...@@ -421,7 +416,7 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs, ...@@ -421,7 +416,7 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
switch (val) switch (val)
{ {
case -1: case -1:
msg_Err (p_this, "Write error: %s", net_strerror (net_errno)); msg_Err (p_this, "Write error: %m");
goto out; goto out;
case 0: case 0:
...@@ -442,7 +437,7 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs, ...@@ -442,7 +437,7 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
if (val == -1) if (val == -1)
{ {
msg_Err (p_this, "Write error: %s", net_strerror (net_errno)); msg_Err (p_this, "Write error: %m");
break; break;
} }
......
...@@ -147,7 +147,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -147,7 +147,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
proto ?: ptr->ai_protocol ); proto ?: ptr->ai_protocol );
if( fd == -1 ) if( fd == -1 )
{ {
msg_Dbg( p_this, "socket error: %s", strerror( net_errno ) ); msg_Dbg( p_this, "socket error: %m" );
continue; continue;
} }
...@@ -159,8 +159,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -159,8 +159,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
if( net_errno != EINPROGRESS ) if( net_errno != EINPROGRESS )
{ {
msg_Err( p_this, "connection failed: %s", msg_Err( p_this, "connection failed: %m" );
strerror( net_errno ) );
goto next_ai; goto next_ai;
} }
...@@ -199,8 +198,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -199,8 +198,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
if( ( i_ret == -1 ) && ( net_errno != EINTR ) ) if( ( i_ret == -1 ) && ( net_errno != EINTR ) )
{ {
msg_Err( p_this, "connection polling error: %s", msg_Err( p_this, "connection polling error: %m" );
strerror( net_errno ) );
goto next_ai; goto next_ai;
} }
...@@ -217,8 +215,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -217,8 +215,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
if( getsockopt( fd, SOL_SOCKET, SO_ERROR, (void*)&i_val, if( getsockopt( fd, SOL_SOCKET, SO_ERROR, (void*)&i_val,
&i_val_size ) == -1 || i_val != 0 ) &i_val_size ) == -1 || i_val != 0 )
{ {
msg_Err( p_this, "connection failed: %s", msg_Err( p_this, "connection failed: %m" );
net_strerror( i_val ) );
goto next_ai; goto next_ai;
} }
#endif #endif
...@@ -288,8 +285,7 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait ) ...@@ -288,8 +285,7 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait )
case -1: case -1:
if (net_errno != EINTR) if (net_errno != EINTR)
{ {
msg_Err (p_this, "poll error: %s", msg_Err (p_this, "poll error: %m");
net_strerror (net_errno));
} }
return -1; return -1;
...@@ -308,8 +304,7 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait ) ...@@ -308,8 +304,7 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait )
int fd = accept (sfd, NULL, NULL); int fd = accept (sfd, NULL, NULL);
if (fd == -1) if (fd == -1)
{ {
msg_Err (p_this, "accept failed (%s)", msg_Err (p_this, "accept failed (%m)");
net_strerror (net_errno));
continue; continue;
} }
net_SetupSocket (fd); net_SetupSocket (fd);
......
...@@ -124,7 +124,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port, ...@@ -124,7 +124,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
protocol ?: ptr->ai_protocol); protocol ?: ptr->ai_protocol);
if (fd == -1) if (fd == -1)
{ {
msg_Dbg (obj, "socket error: %s", net_strerror (net_errno)); msg_Dbg (obj, "socket error: %m");
continue; continue;
} }
...@@ -157,7 +157,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port, ...@@ -157,7 +157,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
#endif #endif
if (bind (fd, ptr->ai_addr, ptr->ai_addrlen)) if (bind (fd, ptr->ai_addr, ptr->ai_addrlen))
{ {
msg_Err (obj, "socket bind error (%s)", net_strerror (net_errno)); msg_Err (obj, "socket bind error (%m)");
net_Close (fd); net_Close (fd);
continue; continue;
} }
...@@ -204,7 +204,8 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this, ...@@ -204,7 +204,8 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this,
#endif #endif
default: default:
msg_Warn( p_this, "%s", strerror( EAFNOSUPPORT ) ); errno = EAFNOSUPPORT;
msg_Warn( p_this, "%m" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -274,7 +275,7 @@ static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family, ...@@ -274,7 +275,7 @@ static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
if (net_SetMcastOutIface (fd, family, scope) == 0) if (net_SetMcastOutIface (fd, family, scope) == 0)
return 0; return 0;
msg_Err (p_this, "%s: %s", iface, net_strerror (net_errno)); msg_Err (p_this, "%s: %m", iface);
} }
if (addr != NULL) if (addr != NULL)
...@@ -292,7 +293,7 @@ static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family, ...@@ -292,7 +293,7 @@ static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
if (net_SetMcastOutIPv4 (fd, ipv4) == 0) if (net_SetMcastOutIPv4 (fd, ipv4) == 0)
return 0; return 0;
msg_Err (p_this, "%s: %s", addr, net_strerror (net_errno)); msg_Err (p_this, "%s: %m", addr);
} }
} }
...@@ -362,8 +363,7 @@ net_IPv4Join (vlc_object_t *obj, int fd, ...@@ -362,8 +363,7 @@ net_IPv4Join (vlc_object_t *obj, int fd,
error: error:
#endif #endif
msg_Err (obj, "cannot join IPv4 multicast group (%s)", msg_Err (obj, "cannot join IPv4 multicast group (%m)");
net_strerror (net_errno));
return -1; return -1;
} }
...@@ -385,8 +385,7 @@ net_IPv6Join (vlc_object_t *obj, int fd, const struct sockaddr_in6 *src) ...@@ -385,8 +385,7 @@ net_IPv6Join (vlc_object_t *obj, int fd, const struct sockaddr_in6 *src)
errno = ENOSYS; errno = ENOSYS;
#endif #endif
msg_Err (obj, "cannot join IPv6 any-source multicast group (%s)", msg_Err (obj, "cannot join IPv6 any-source multicast group (%m)");
net_strerror (net_errno));
return -1; return -1;
} }
...@@ -549,8 +548,7 @@ net_SourceSubscribe (vlc_object_t *obj, int fd, ...@@ -549,8 +548,7 @@ net_SourceSubscribe (vlc_object_t *obj, int fd,
#endif #endif
} }
msg_Err (obj, "Multicast group join error (%s)", msg_Err (obj, "Multicast group join error (%m)");
net_strerror (net_errno));
if (src != NULL) if (src != NULL)
{ {
...@@ -687,8 +685,7 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -687,8 +685,7 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
b_unreach = VLC_TRUE; b_unreach = VLC_TRUE;
else else
{ {
msg_Warn( p_this, "%s port %d : %s", psz_host, i_port, msg_Warn( p_this, "%s port %d : %m", psz_host, i_port);
strerror( errno ) );
net_Close( fd ); net_Close( fd );
continue; continue;
} }
...@@ -803,8 +800,8 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind, ...@@ -803,8 +800,8 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
ptr->ai_addr, ptr->ai_addrlen) ptr->ai_addr, ptr->ai_addrlen)
: connect (fd, ptr2->ai_addr, ptr2->ai_addrlen)) : connect (fd, ptr2->ai_addr, ptr2->ai_addrlen))
{ {
msg_Err (obj, "cannot connect to %s port %d: %s", msg_Err (obj, "cannot connect to %s port %d: %m",
psz_server, i_server, net_strerror (net_errno)); psz_server, i_server);
continue; continue;
} }
val = fd; val = fd;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <stdlib.h> /* free() */ #include <stdlib.h> /* free() */
#include <stdio.h> /* sprintf() */ #include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */ #include <string.h>
#include <ctype.h> /* tolower(), isxdigit() */ #include <ctype.h> /* tolower(), isxdigit() */
#include <vlc_sout.h> #include <vlc_sout.h>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <stdlib.h> /* free() */ #include <stdlib.h> /* free() */
#include <stdio.h> /* sprintf() */ #include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */ #include <string.h>
#include <vlc_sout.h> #include <vlc_sout.h>
#include <vlc_playlist.h> #include <vlc_playlist.h>
......
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