From 6197964d15f4e0c0a5b3abeba6cba11ed53652ee Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Tue, 6 Feb 2007 22:47:55 +0000 Subject: [PATCH] Exit with nonzero status if torrent fails to load. Fixes ticket #195 --- cli/transmissioncli.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/transmissioncli.c b/cli/transmissioncli.c index f8cbbec2e..ea2beb7f9 100644 --- a/cli/transmissioncli.c +++ b/cli/transmissioncli.c @@ -77,13 +77,13 @@ int main( int argc, char ** argv ) if( parseCommandLine( argc, argv ) ) { printf( USAGE, argv[0], TR_DEFAULT_PORT ); - return 1; + return EXIT_FAILURE; } if( showHelp ) { printf( USAGE, argv[0], TR_DEFAULT_PORT ); - return 0; + return EXIT_SUCCESS; } if( verboseLevel < 0 ) @@ -104,7 +104,7 @@ int main( int argc, char ** argv ) if( bindPort < 1 || bindPort > 65535 ) { printf( "Invalid port '%d'\n", bindPort ); - return 1; + return EXIT_FAILURE; } /* Initialize libtransmission */ @@ -114,7 +114,8 @@ int main( int argc, char ** argv ) if( !( tor = tr_torrentInit( h, torrentPath, 0, &error ) ) ) { printf( "Failed opening torrent file `%s'\n", torrentPath ); - goto failed; + tr_close( h ); + return EXIT_FAILURE; } if( showInfo ) @@ -252,11 +253,9 @@ int main( int argc, char ** argv ) cleanup: tr_torrentClose( h, tor ); - -failed: tr_close( h ); - return 0; + return EXIT_SUCCESS; } static int parseCommandLine( int argc, char ** argv )