From 8b889d908c7d48fff51b9545a82f2eb06f51755d Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Tue, 7 May 2024 17:12:11 +0200 Subject: [PATCH] fix(phy simulators): fix cmdline configmodule for LTE_PHY ulsim and dlsim --- openair1/SIMULATION/LTE_PHY/dlsim.c | 14 +++++++++++--- openair1/SIMULATION/LTE_PHY/ulsim.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index e8b08a1921..2f112ddc99 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -662,7 +662,15 @@ int main(int argc, char **argv) { int option_index; int res; - while ((res=getopt_long_only(argc, argv, "", long_options, &option_index)) == 0) { + /* disable error messages from getopt_long_only */ + opterr = 0; + while ((res=getopt_long_only(argc, argv, "-", long_options, &option_index)) >= 0) { + + /* ignore configmodule options and their arguments*/ + /* with these opstring and long_options getopt returns 1 for non-option arguments and '?' for unrecognized long options, refer to 'man 3 getopt' */ + if (res == 1 || res == '?') + continue; + if (options[option_index].voidptr != NULL ) { if (long_options[option_index].has_arg==no_argument) *(bool *)options[option_index].iptr=1; @@ -877,8 +885,8 @@ int main(int argc, char **argv) { if (transmission_mode>1) pa=dBm3; printf("dlsim: tmode %d, pa %d\n",transmission_mode,pa); - AssertFatal((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) != NULL, - "Cannot load configuration module, exiting\n"); + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + AssertFatal(uniqCfg != NULL, "Cannot load configuration module, exiting\n"); logInit(); set_glog_onlinelog(true); // enable these lines if you need debug info diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 19c9ded376..7898365e66 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -395,8 +395,8 @@ int main(int argc, char **argv) { cpuf = cpu_freq_GHz; set_parallel_conf("PARALLEL_SINGLE_THREAD"); printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz); - AssertFatal((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) != NULL, - "Cannot load configuration module, exiting\n"); + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + AssertFatal(uniqCfg != NULL, "Cannot load configuration module, exiting\n"); logInit(); set_glog(OAILOG_INFO); // enable these lines if you need debug info @@ -447,7 +447,15 @@ int main(int argc, char **argv) { int option_index; int res; - while ((res=getopt_long_only(argc, argv, "", long_options, &option_index)) == 0) { + /* disable error messages from getopt_long_only */ + opterr = 0; + while ((res=getopt_long_only(argc, argv, "-", long_options, &option_index)) >= 0) { + + /* ignore configmodule options and their arguments*/ + /* with these opstring and long_options getopt returns 1 for non-option arguments and '?' for unrecognized long options, refer to 'man 3 getopt' */ + if (res == 1 || res == '?') + continue; + if (options[option_index].voidptr != NULL ) { if (long_options[option_index].has_arg==no_argument) *(bool *)options[option_index].iptr=1;