From 53907d37396e71cb59ef220d2a62055836db3eaf Mon Sep 17 00:00:00 2001 From: oai <francois.taburet@nokia-bell-labs.com> Date: Tue, 26 Sep 2017 15:35:26 +0200 Subject: [PATCH] fix command line processing crash --- common/config/config_cmdline.c | 33 +++++++++++++++++++-------------- openair1/PHY/defs.h | 3 ++- targets/RT/USER/lte-softmodem.c | 12 +++++++----- targets/RT/USER/lte-softmodem.h | 2 +- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 6c91e71e52e..c22ecf964a0 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -39,9 +39,8 @@ int processoption(paramdef_t *cfgoptions, char *value) { int argok=1; char *tmpval = value; -int ret =0; int optisset; - +char defbool[2]="1"; if (value == NULL) { argok=0; } else if ( value[0] == '-') { @@ -51,11 +50,11 @@ int optisset; if (argok == 0) { fprintf(stderr,"[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname); return 0; - } else { /* boolean value */ - tmpval = "1"; - } - } - + } + } else { /* boolean value */ + tmpval = defbool; + } + printf("cc 0x%08x, %i\n",tmpval,argok); switch(cfgoptions->type) { case TYPE_STRING: @@ -128,7 +127,7 @@ char *cfgpath; j=0; p++; c--; - while (c >= 0 && *p != NULL) { + while (c > 0 && *p != NULL) { if (strcmp(*p, "-h") == 0 || strcmp(*p, "--help") == 0 ) { config_printhelp(cfgoptions,numoptions); } @@ -143,13 +142,19 @@ char *cfgpath; } if ( ((strlen(*p) == 2) && (strcmp(*p + 1,cfgpath) == 0)) || ((strlen(*p) > 2) && (strcmp(*p + 2,cfgpath ) == 0 )) ) { - p++; - c--; - j = processoption(&(cfgoptions[i]), *p); - if ( j== 0) { - c++; - p--; + + if (c > 1) { + p++; + c--; + j = processoption(&(cfgoptions[i]), *p); + if ( j== 0) { + c++; + p--; + } + } else { + j = processoption(&(cfgoptions[i]), NULL); } + } } p++; diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 0fb7b2b01b7..47340dc27d5 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -613,7 +613,8 @@ typedef enum { REMOTE_IF5 =1, REMOTE_MBP_IF5 =2, REMOTE_IF4p5 =3, - MAX_RU_IF_TYPES =4 + REMOTE_IF1pp =4, + MAX_RU_IF_TYPES =5 } RU_if_south_t; typedef struct RU_t_s{ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index f5415e0391f..3badd69cffa 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -625,17 +625,12 @@ void *l2l1_task(void *arg) { static void get_options(void) { int CC_id; - int clock_src; int tddflag; char *loopfile=NULL; int dumpframe; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); - if (tddflag > 0) { - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) - frame_parms[CC_id]->frame_type = TDD; - } if (strlen(in_path) > 0) { opt_type = OPT_PCAP; @@ -650,6 +645,9 @@ static void get_options(void) { if (UE_flag > 0) { paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; + + + config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); if (loopfile != NULL) { @@ -676,6 +674,10 @@ static void get_options(void) { UE_scan=0; } + if (tddflag > 0) { + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) + frame_parms[CC_id]->frame_type = TDD; + } if (frame_parms[0]->N_RB_DL !=0) { if ( frame_parms[0]->N_RB_DL < 6 ) { diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 6fba6096894..00a50c0cc53 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -155,7 +155,7 @@ extern int16_t dlsch_demod_shift; {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ -{"d" , CONFIG_HLP_SOFTS, 0, i8ptr:&do_forms, defintval:0, TYPE_INT8, 0}, \ +{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ {"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ {"U" , CONFIG_HLP_UE, PARAMFLAG_BOOL, i8ptr:&UE_flag, defintval:0, TYPE_INT8, 0}, \ -- GitLab