diff --git a/srsue/src/main.cc b/srsue/src/main.cc index f1026f6b7..f71f9ac6f 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -363,8 +363,14 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { exit(1); } - bpo::store(bpo::parse_config_file(conf, common), vm); - bpo::notify(vm); + // parse config file and handle errors gracefully + try { + bpo::store(bpo::parse_config_file(conf, common), vm); + bpo::notify(vm); + } catch (const boost::program_options::error& e) { + cerr << e.what() << endl; + exit(1); + } //Check conflicting OP/OPc options and which is being used if (vm.count("usim.op") && !vm["usim.op"].defaulted() && @@ -373,14 +379,8 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { cout << "Conflicting options OP and OPc. Please configure either one or the other." << endl; exit(1); } - else - { - if(vm["usim.op"].defaulted()){ - args->usim.using_op = true; - } - else{ - args->usim.using_op = false; - } + else { + args->usim.using_op = vm.count("usim.op"); } // Apply all_level to any unset layers diff --git a/srsue/src/upper/usim.cc b/srsue/src/upper/usim.cc index dedbc8794..f13469517 100644 --- a/srsue/src/upper/usim.cc +++ b/srsue/src/upper/usim.cc @@ -53,8 +53,7 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_) usim_log->console("Invalid length for K: %zu should be %d\n", args->k.length(), 32); } - if(args->using_op) - { + if(args->using_op) { if(32 == args->op.length()) { str_to_hex(args->op, op); compute_opc(k,op,opc); @@ -63,7 +62,7 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_) usim_log->console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); } } - else{ + else { if(32 == args->opc.length()) { str_to_hex(args->opc, opc); } else {