use vty->type instead of local variable

We can check if we're parsing the config file by checking
whether vty->type equals VTY_FILE. This avoids the use of
an extra local variable to track the parsing state.

Change-Id: I85161575e025f7c389832427a434bd8e2d6ecc75
Fixes: 1051c42088
Related: OS#3355
This commit is contained in:
Stefan Sperling 2018-12-18 18:57:41 +01:00 committed by Harald Welte
parent b12b6cb006
commit b361ea7037
3 changed files with 1 additions and 7 deletions

View File

@ -31,6 +31,4 @@ void msc_vty_init(struct gsm_network *msc_network);
struct gsm_network *gsmnet_from_vty(struct vty *vty); struct gsm_network *gsmnet_from_vty(struct vty *vty);
extern bool msc_parsing_config_file;
#endif #endif

View File

@ -466,7 +466,7 @@ DEFUN(cfg_msc_ipa_name,
"This name is used for GSUP routing and must be set if more than one MSC is connected to the HLR. " "This name is used for GSUP routing and must be set if more than one MSC is connected to the HLR. "
"The default is 'MSC-00-00-00-00-00-00'.\n") "The default is 'MSC-00-00-00-00-00-00'.\n")
{ {
if (!msc_parsing_config_file) { if (vty->type != VTY_FILE) {
vty_out(vty, "The IPA name cannot be changed at run-time; " vty_out(vty, "The IPA name cannot be changed at run-time; "
"It can only be set in the configuraton file.%s", VTY_NEWLINE); "It can only be set in the configuraton file.%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;

View File

@ -515,8 +515,6 @@ extern void *tall_gsms_ctx;
extern void *tall_call_ctx; extern void *tall_call_ctx;
extern void *tall_trans_ctx; extern void *tall_trans_ctx;
bool msc_parsing_config_file = false;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int rc; int rc;
@ -569,9 +567,7 @@ int main(int argc, char **argv)
return -1; return -1;
#endif #endif
msc_parsing_config_file = true;
rc = vty_read_config_file(msc_cmdline_config.config_file, NULL); rc = vty_read_config_file(msc_cmdline_config.config_file, NULL);
msc_parsing_config_file = false;
if (rc < 0) { if (rc < 0) {
LOGP(DMSC, LOGL_FATAL, "Failed to parse the config file: '%s'\n", LOGP(DMSC, LOGL_FATAL, "Failed to parse the config file: '%s'\n",
msc_cmdline_config.config_file); msc_cmdline_config.config_file);