int
tr_bencSaveFile( const char * filename, const tr_benc * b )
{
- int ret = TR_OK;
+ int err = TR_OK;
int len;
char * content = tr_bencSave( b, &len );
FILE * out = NULL;
{
tr_err( _( "Couldn't open \"%1$s\": %2$s" ),
filename, tr_strerror( errno ) );
- ret = TR_EINVALID;
+ err = TR_EINVALID;
}
else if( fwrite( content, sizeof( char ), len, out ) != (size_t)len )
{
tr_err( _( "Couldn't save file \"%1$s\": %2$s" ),
filename, tr_strerror( errno ) );
- ret = TR_EINVALID;
+ err = TR_EINVALID;
}
- tr_dbg( "tr_bencSaveFile returned %d when saving \"%s\"", ret, filename );
+ if( !err )
+ tr_dbg( "tr_bencSaveFile saved \"%s\"", filename );
tr_free( content );
if( out )
fclose( out );
- return ret;
+ return err;
}
int
static void
logVal( const char * func, int ret )
{
- if( ret==NATPMP_TRYAGAIN )
- tr_ndbg( getKey(), "%s responded \"try again\"", func );
- else if( ret >= 0 )
+ if( ret == NATPMP_TRYAGAIN )
+ return;
+ if( ret >= 0 )
tr_ninf( getKey(), _( "%s succeeded (%d)" ), func, ret );
else
tr_ndbg( getKey(), "%s failed (%d): %s (%d)", func, ret, tr_strerror(errno), errno );