From 0996cfcee351bfd665f48a205d2f7fe37dec336c Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 18 Mar 2018 22:00:55 -0400 Subject: Fix configuration system and fix race condition in survive_vive. --- src/survive.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 24bb7d3..05c66d7 100755 --- a/src/survive.c +++ b/src/survive.c @@ -164,13 +164,22 @@ SurviveContext * survive_init_internal( int argc, char * const * argv ) if( vartoupdate ) { - survive_configs( ctx, *av, SC_OVERRIDE, *(av+1) ); - av++; + if( av+1 == argvend ) + { + fprintf( stderr, "Error: expected parameter after %s\n", *av ); + showhelp = 1; + } + else + { + survive_configs( ctx, *av+2, SC_OVERRIDE|SC_SET, *(av+1) ); + av++; + } } } } if( showhelp ) { + //Can't use SV_ERROR here since we don't have a context to send to yet. fprintf( stderr, "libsurvive - usage:\n" ); fprintf( stderr, " --[parameter] [value] - sets parameter\n" ); fprintf( stderr, " -h - shows help.\n" ); @@ -178,8 +187,6 @@ SurviveContext * survive_init_internal( int argc, char * const * argv ) fprintf( stderr, " -l [lighthouse count] - use a specific number of lighthoses.\n" ); fprintf( stderr, " -c [config file] - set config file\n" ); fprintf( stderr, " -p [lighthouse count] - use a specific number of lighthoses.\n" ); - - //XXX: TODO: Should this just exit(-1)? return 0; } @@ -435,7 +442,7 @@ void survive_close( SurviveContext * ctx ) int survive_poll( struct SurviveContext * ctx ) { int i, r; - if( ctx->state = SURVIVE_STOPPED ) + if( ctx->state == SURVIVE_STOPPED ) { r = survive_startup( ctx ); if( r ) -- cgit v1.2.3