diff --git a/cli/cli.c b/cli/cli.c index a96ea3fac..6df904feb 100644 --- a/cli/cli.c +++ b/cli/cli.c @@ -48,7 +48,6 @@ static sig_atomic_t manualUpdate = 0; static const char * torrentPath = NULL; static const char * finishCall = NULL; static const char * announce = NULL; -static const char * configdir = NULL; static const char * sourceFile = NULL; static const char * comment = NULL; @@ -272,9 +271,12 @@ getConfigDir( int argc, const char ** argv ) const char * optarg; const int ind = tr_optind; - while(( c = tr_getopt( getUsage( ), argc, argv, options, &optarg ))) - if( c == 'g' ) - configdir = optarg; + while(( c = tr_getopt( getUsage( ), argc, argv, options, &optarg ))) { + if( c == 'g' ) { + configDir = optarg; + break; + } + } tr_optind = ind; diff --git a/daemon/daemon.c b/daemon/daemon.c index 569b957fa..f61a9b945 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -156,9 +156,12 @@ getConfigDir( int argc, const char ** argv ) const char * optarg; const int ind = tr_optind; - while(( c = tr_getopt( getUsage( ), argc, argv, options, &optarg ))) - if( c == 'g' ) + while(( c = tr_getopt( getUsage( ), argc, argv, options, &optarg ))) { + if( c == 'g' ) { configDir = optarg; + break; + } + } tr_optind = ind;