cleanup #includes for errno & strerror

This commit is contained in:
Charles Kerr
2008-02-19 04:16:04 +00:00
parent c421bc0266
commit deaeb24cb5
18 changed files with 33 additions and 29 deletions
-1
View File
@@ -23,7 +23,6 @@
*****************************************************************************/
#include <sys/param.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
-1
View File
@@ -22,7 +22,6 @@
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#include <errno.h>
#include <string.h>
#include <unistd.h>
-1
View File
@@ -24,7 +24,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <signal.h>
#include <stdarg.h>
#include <string.h>
-1
View File
@@ -42,7 +42,6 @@
**********************************************************************/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+2 -2
View File
@@ -163,7 +163,7 @@ TrOpenFile( int i,
file->fd = open( filename, flags, 0666 );
if( file->fd == -1 ) {
const int err = errno;
tr_err( "Couldn't open '%s': %s", filename, strerror(err) );
tr_err( "Couldn't open '%s': %s", filename, tr_strerror(err) );
return tr_ioErrorFromErrno( err );
}
@@ -387,7 +387,7 @@ tr_fdSocketCreate( int type, int isReserved )
if( isReserved || ( gFd->normal < getSocketMax( gFd ) ) )
if( ( s = socket( AF_INET, type, 0 ) ) < 0 )
tr_err( "Couldn't create socket (%s)", strerror( sockerrno ) );
tr_err( "Couldn't create socket (%s)", tr_strerror( sockerrno ) );
if( s > -1 )
{
+1 -1
View File
@@ -1024,7 +1024,7 @@ gotError( struct bufferevent * evbuf UNUSED, short what, void * arg )
else
{
dbgmsg( handshake, "libevent got an error what==%d, errno=%d (%s)",
(int)what, errno, strerror(errno) );
(int)what, errno, tr_strerror(errno) );
tr_handshakeDone( handshake, FALSE );
}
}
+1
View File
@@ -11,6 +11,7 @@
*/
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+1 -1
View File
@@ -57,7 +57,7 @@ getFiles( const char * dir,
tr_buildPath( buf, sizeof(buf), dir, base, NULL );
i = stat( buf, &sb );
if( i ) {
tr_err("makemeta couldn't stat \"%s\"; skipping. (%s)", buf, strerror(errno));
tr_err("makemeta couldn't stat \"%s\"; skipping. (%s)", buf, tr_strerror(errno));
return list;
}
+2 -2
View File
@@ -614,13 +614,13 @@ tr_metainfoSave( const char * hash, const char * tag,
file = fopen( path, "wb+" );
if( !file )
{
tr_err( "Could not open file (%s) (%s)", path, strerror( errno ) );
tr_err( "Could not open file (%s) (%s)", path, tr_strerror( errno ) );
return TR_EINVALID;
}
fseek( file, 0, SEEK_SET );
if( fwrite( buf, 1, buflen, file ) != buflen )
{
tr_err( "Could not write file (%s) (%s)", path, strerror( errno ) );
tr_err( "Could not write file (%s) (%s)", path, tr_strerror( errno ) );
fclose( file );
return TR_EINVALID;
}
+1 -2
View File
@@ -14,7 +14,6 @@
#include <errno.h>
#include <time.h>
#include <inttypes.h>
#include <string.h> /* strerror */
#ifdef WIN32
#include <winsock2.h> /* inet_ntoa */
@@ -70,7 +69,7 @@ logVal( const char * func, int ret )
else if( ret >= 0 )
tr_dbg( KEY "%s returned success (%d)", func, ret );
else
tr_err( KEY "%s returned error %d, errno is %d (%s)", func, ret, errno, strerror(errno) );
tr_err( KEY "%s returned error %d, errno is %d (%s)", func, ret, errno, tr_strerror(errno) );
}
struct tr_natpmp*
+3 -3
View File
@@ -93,7 +93,7 @@ makeSocketNonBlocking( int fd )
#endif
{
tr_err( "Couldn't set socket to non-blocking mode (%s)",
strerror( sockerrno ) );
tr_strerror( sockerrno ) );
tr_netClose( fd );
fd = -1;
}
@@ -134,7 +134,7 @@ tr_netOpen( const struct in_addr * addr, tr_port_t port,
{
tr_err( "Couldn't connect socket %d to %s, port %d (errno %d - %s)",
s, inet_ntoa(*addr), port,
sockerrno, strerror(sockerrno) );
sockerrno, tr_strerror(sockerrno) );
tr_netClose( s );
s = -1;
}
@@ -176,7 +176,7 @@ tr_netBind( int port, int type )
if( bind( s, (struct sockaddr *) &sock,
sizeof( struct sockaddr_in ) ) )
{
tr_err( "Couldn't bind port %d: %s", port, strerror(sockerrno) );
tr_err( "Couldn't bind port %d: %s", port, tr_strerror(sockerrno) );
tr_netClose( s );
return -1;
}
+1 -1
View File
@@ -1652,7 +1652,7 @@ gotError( struct bufferevent * evbuf UNUSED, short what, void * vmsgs )
dbgmsg( vmsgs, "libevent got a timeout, what=%hd", what );
if( what & ( EVBUFFER_EOF | EVBUFFER_ERROR ) )
dbgmsg( vmsgs, "libevent got an error! what=%hd, errno=%d (%s)",
what, errno, strerror(errno) );
what, errno, tr_strerror(errno) );
fireError( vmsgs, TR_ERROR );
}
-1
View File
@@ -40,7 +40,6 @@
#endif
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+1 -1
View File
@@ -116,7 +116,7 @@ incomingPeersPulse( tr_shared * s )
listen( s->bindSocket, 5 );
} else {
tr_err( NATKEY "unable to open port %d to listen for incoming peer connections (errno is %d - %s)",
s->publicPort, errno, strerror(errno) );
s->publicPort, errno, tr_strerror(errno) );
s->bindPort = -1;
s->bindSocket = -1;
}
-1
View File
@@ -11,7 +11,6 @@
*/
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+3 -4
View File
@@ -13,7 +13,6 @@
#include <assert.h>
#include <errno.h>
#include <stdio.h> /* snprintf */
#include <string.h> /* strerror */
#include <miniupnp/miniwget.h>
#include <miniupnp/miniupnpc.h>
@@ -89,7 +88,7 @@ tr_upnpPulse( tr_upnp * handle, int port, int isEnabled )
errno = 0;
devlist = upnpDiscover( 2000, NULL, NULL );
if( devlist == NULL ) {
tr_err( KEY "upnpDiscover returned NULL (errno %d - %s)", errno, strerror(errno) );
tr_err( KEY "upnpDiscover returned NULL (errno %d - %s)", errno, tr_strerror(errno) );
}
errno = 0;
if( UPNP_GetValidIGD( devlist, &handle->urls, &handle->data, handle->lanaddr, sizeof(handle->lanaddr))) {
@@ -99,7 +98,7 @@ tr_upnpPulse( tr_upnp * handle, int port, int isEnabled )
handle->hasDiscovered = 1;
} else {
handle->state = TR_UPNP_ERR;
tr_err( KEY "UPNP_GetValidIGD failed. (errno %d - %s)", errno, strerror(errno) );
tr_err( KEY "UPNP_GetValidIGD failed. (errno %d - %s)", errno, tr_strerror(errno) );
tr_err( KEY "If your router supports UPnP, please make sure UPnP is enabled!" );
}
freeUPNPDevlist( devlist );
@@ -154,7 +153,7 @@ tr_upnpPulse( tr_upnp * handle, int port, int isEnabled )
handle->port = port;
handle->state = TR_UPNP_IDLE;
} else {
tr_err( KEY "Port forwarding failed with err %d (%d - %s)", err, errno, strerror(errno) );
tr_err( KEY "Port forwarding failed with err %d (%d - %s)", err, errno, tr_strerror(errno) );
tr_err( KEY "If your router supports UPnP, please make sure UPnP is enabled!" );
handle->port = -1;
handle->state = TR_UPNP_ERR;
+15 -6
View File
@@ -27,7 +27,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h> /* strerror */
#include <sys/time.h>
#include <sys/types.h>
@@ -360,7 +360,7 @@ tr_loadFile( const char * path, size_t * size )
errno = 0;
if( stat( path, &sb ) )
{
tr_err( "Couldn't get information for file \"%s\" %s", path, strerror(errno) );
tr_err( "Couldn't get information for file \"%s\" %s", path, tr_strerror(errno) );
return NULL;
}
@@ -374,7 +374,7 @@ tr_loadFile( const char * path, size_t * size )
file = fopen( path, "rb" );
if( !file )
{
tr_err( "Couldn't open file \"%s\" %s", path, strerror(errno) );
tr_err( "Couldn't open file \"%s\" %s", path, tr_strerror(errno) );
return NULL;
}
buf = malloc( sb.st_size );
@@ -387,7 +387,7 @@ tr_loadFile( const char * path, size_t * size )
fseek( file, 0, SEEK_SET );
if( fread( buf, sb.st_size, 1, file ) != 1 )
{
tr_err( "Error reading \"%s\" %s", path, strerror(errno) );
tr_err( "Error reading \"%s\" %s", path, tr_strerror(errno) );
free( buf );
fclose( file );
return NULL;
@@ -440,7 +440,7 @@ tr_mkdirp( const char * path_in, int permissions )
/* Folder doesn't exist yet */
if( tr_mkdir( path, permissions ) ) {
const int err = errno;
tr_err( "Couldn't create directory %s (%s)", path, strerror( err ) );
tr_err( "Couldn't create directory %s (%s)", path, tr_strerror( err ) );
tr_free( path );
errno = err;
return -1;
@@ -504,7 +504,7 @@ tr_ioErrorFromErrno( int err )
case EFBIG:
return TR_ERROR_IO_FILE_TOO_BIG;
default:
tr_dbg( "generic i/o errno from errno: %s", strerror( errno ) );
tr_dbg( "generic i/o errno from errno: %s", tr_strerror( errno ) );
return TR_ERROR_IO_OTHER;
}
}
@@ -597,6 +597,15 @@ tr_free( void * p )
free( p );
}
const char*
tr_strerror( int i )
{
const char * ret = strerror( i );
if( ret == NULL )
ret = "Unknown Error";
return ret;
}
/****
*****
****/
+2
View File
@@ -118,6 +118,8 @@ void tr_free ( void* );
char* tr_strdup( const char * str );
char* tr_strndup( const char * str, int len );
const char* tr_strerror( int );
/***
****
***/