fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/31863 )
Change subject: layer23: fix parsing of command line options ......................................................................
layer23: fix parsing of command line options
After the recent refactoring, parsing of the command line options is broken for some arguments. Specifically, the value of '-a'/'--arfcn' is ignored and hard-coded ARFCN=871 is used instead.
The problem is that l23_app_init(), which allocates an MS state and sets the initial ARFCN, is called *before* handle_options(). So the cfg_test_arfcn is used before it gets overwritten from the argv[].
The usual approach in osmo-* apps is to parse the command line arguments first, and only then execute code which depends on configurable parameters. Let's follow this approach too.
Change-Id: I77ca11c14561fa3fcb9add60ccea5b0b847a20c4 --- M src/host/layer23/src/common/main.c M src/host/layer23/src/mobile/main.c 2 files changed, 29 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/63/31863/1
diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c index 31e7154..e4a15ee 100644 --- a/src/host/layer23/src/common/main.c +++ b/src/host/layer23/src/common/main.c @@ -254,14 +254,14 @@
print_copyright();
+ handle_options(argc, argv); + rc = l23_app_init(); if (rc < 0) { fprintf(stderr, "Failed during l23_app_init()\n"); exit(1); }
- handle_options(argc, argv); - if (l23_app_info.opt_supported & L23_OPT_VTY) { if (_vty_init() < 0) exit(1); diff --git a/src/host/layer23/src/mobile/main.c b/src/host/layer23/src/mobile/main.c index 3260bff..d24a802 100644 --- a/src/host/layer23/src/mobile/main.c +++ b/src/host/layer23/src/mobile/main.c @@ -255,6 +255,12 @@
print_copyright();
+ rc = handle_options(argc, argv); + if (rc) { /* Abort in case of parsing errors */ + fprintf(stderr, "Error in command line options. Exiting.\n"); + return 1; + } + srand(time(NULL));
INIT_LLIST_HEAD(&ms_list); @@ -272,12 +278,6 @@ exit(1); }
- rc = handle_options(argc, argv); - if (rc) { /* Abort in case of parsing errors */ - fprintf(stderr, "Error in command line options. Exiting.\n"); - return 1; - } - if (custom_cfg_file) { /* Use full path provided by user */ config_file = talloc_strdup(l23_ctx, custom_cfg_file);