Commit 49b4e412 authored by Raphael Defosseux's avatar Raphael Defosseux 🌴

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/issue-389-fix-missing-option-value-not-reported' into develop_integration_2019_w03
parents cbb21c10 e179213b
Pipeline #11385 passed with stage
in 0 seconds
......@@ -75,6 +75,7 @@ int processoption(paramdef_t *cfgoptions, char *value) {
if ( value == NULL) {
if( (cfgoptions->paramflags &PARAMFLAG_BOOL) == 0 ) { /* not a boolean, argument required */
fprintf(stderr,"[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname);
exit_fun("[CONFIG] command line parsing fatal error");
return 0;
} else { /* boolean value option without argument, set value to true*/
tmpval = defbool;
......@@ -143,7 +144,10 @@ int processoption(paramdef_t *cfgoptions, char *value) {
return optisset;
}
int config_check_cmdlineopt(char *prefix) {
/*--------------------------------------------------------------------*/
/* check unknown options in the command line
*/
int config_check_unknown_cmdlineopt(char *prefix) {
int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH]="";
int finalcheck = 0;
......@@ -161,6 +165,8 @@ int config_check_cmdlineopt(char *prefix) {
if ( !finalcheck && testprefix[0]==0 && index(config_get_if()->argv[i],'.') != NULL) continue;
if ( !finalcheck && isdigit(config_get_if()->argv[i][0])) continue;
if ( !finalcheck && config_get_if()->argv[i][0] == '-' && isdigit(config_get_if()->argv[i][1])) continue;
if ( (config_get_if()->argv_info[i] & CONFIG_CMDLINEOPT_PROCESSED) == 0 ) {
......@@ -173,7 +179,7 @@ int config_check_cmdlineopt(char *prefix) {
printf_cmdl("[CONFIG] %i unknown option(s) in command line starting with %s (section %s)\n",
unknowndetected,testprefix,((prefix==NULL)?"":prefix));
return unknowndetected;
} /* parse_cmdline*/
} /* config_check_unknown_cmdlineopt */
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
int c = config_get_if()->argc;
......@@ -269,7 +275,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix)
printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j);
if ( !(CONFIG_ISFLAGSET( CONFIG_NOCHECKUNKOPT )) ) {
i=config_check_cmdlineopt(prefix);
i=config_check_unknown_cmdlineopt(prefix);
if (i > 0) {
fprintf(stderr,"[CONFIG] %i unknown options for section %s detected in command line\n",
......
......@@ -370,6 +370,12 @@ int config_checkstr_assign_integer(paramdef_t *param) {
return -1;
}
void config_set_checkfunctions(paramdef_t *params, checkedparam_t *checkfunctions, int numparams) {
for (int i=0; i< numparams ; i++ ) {
params[i].chkPptr = &(checkfunctions[i]);
}
}
int config_setdefault_string(paramdef_t *cfgoptions, char *prefix) {
int status = 0;
......
......@@ -57,10 +57,13 @@ extern int config_assign_ipv4addr(paramdef_t *cfgoptions, char *ipv4addr);
/* apis to get/check parameters, to be used by oai modules, at configuration time */
#define CONFIG_CHECKALLSECTIONS "ALLSECTIONS"
extern int config_check_cmdlineopt(char *prefix);
extern int config_check_unknown_cmdlineopt(char *prefix);
extern int config_get(paramdef_t *params,int numparams, char *prefix);
extern int config_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams, char *prefix);
/* apis to set some of the paramdef_t fields before using the get/getlist api's */
extern void config_set_checkfunctions(paramdef_t *params, checkedparam_t *checkfunctions, int numparams);
/* apis to retrieve parameters info after calling get or getlist functions */
extern int config_isparamset(paramdef_t *params,int paramidx);
extern int config_get_processedint(paramdef_t *cfgoption);
......
This diff is collapsed.
......@@ -689,7 +689,7 @@ int main( int argc, char **argv ) {
#if T_TRACER
T_Config_Init();
#endif
ret=config_check_cmdlineopt(NULL);
ret=config_check_unknown_cmdlineopt(NULL);
if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line\n",ret);
......@@ -938,7 +938,7 @@ int main( int argc, char **argv ) {
sync_var=0;
pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex);
ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS);
ret=config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret);
......
......@@ -1010,7 +1010,7 @@ int main( int argc, char **argv ) {
}
#endif
ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS);
ret=config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment