[sr-dev] git:master:992dcdab: core: stop start if ifdef check fails

Victor Seva linuxmaniac at torreviejawireless.org
Fri Jan 3 09:43:31 CET 2020


Module: kamailio
Branch: master
Commit: 992dcdabbb42394ad694354cf283a3beb7b66878
URL: https://github.com/kamailio/kamailio/commit/992dcdabbb42394ad694354cf283a3beb7b66878

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2020-01-03T09:43:23+01:00

core: stop start if ifdef check fails

Related #2057

---

Modified: src/core/ppcfg.c
Modified: src/core/ppcfg.h
Modified: src/main.c

---

Diff:  https://github.com/kamailio/kamailio/commit/992dcdabbb42394ad694354cf283a3beb7b66878.diff
Patch: https://github.com/kamailio/kamailio/commit/992dcdabbb42394ad694354cf283a3beb7b66878.patch

---

diff --git a/src/core/ppcfg.c b/src/core/ppcfg.c
index 584a491ba2..115707aa00 100644
--- a/src/core/ppcfg.c
+++ b/src/core/ppcfg.c
@@ -216,19 +216,27 @@ void pp_ifdef_level_update(int val)
 /**
  *
  */
-void pp_ifdef_level_check(void)
+int pp_ifdef_level_check(void)
+{
+	if(_pp_ifdef_level!=0) {
+		return -1;
+	} else {
+		LM_DBG("same number of pairing preprocessor directives"
+			" #!IF[N]DEF - #!ENDIF\n");
+	}
+	return 0;
+}
+
+void pp_ifdef_level_error(void)
 {
 	if(_pp_ifdef_level!=0) {
 		if (_pp_ifdef_level > 0) {
-	                LM_WARN("different number of preprocessor directives:"
+			LM_ERR("different number of preprocessor directives:"
 				" %d more #!if[n]def as #!endif\n", _pp_ifdef_level);
 		} else {
-			LM_WARN("different number of preprocessor directives:"
+			LM_ERR("different number of preprocessor directives:"
 				" %d more #!endif as #!if[n]def\n", (_pp_ifdef_level)*-1);
 		}
-	} else {
-		LM_DBG("same number of pairing preprocessor directives"
-			" #!IF[N]DEF - #!ENDIF\n");
 	}
 }
 
diff --git a/src/core/ppcfg.h b/src/core/ppcfg.h
index 8485059918..6fbd8a3521 100644
--- a/src/core/ppcfg.h
+++ b/src/core/ppcfg.h
@@ -44,7 +44,8 @@ int  pp_define_set_type(int type);
 str *pp_define_get(int len, const char * text);
 
 void pp_ifdef_level_update(int val);
-void pp_ifdef_level_check(void);
+int pp_ifdef_level_check(void);
+void pp_ifdef_level_error(void);
 
 void pp_define_core(void);
 
diff --git a/src/main.c b/src/main.c
index 0bc2e650dc..1c62c6d130 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2299,10 +2299,10 @@ int main(int argc, char** argv)
 
 	yyin=cfg_stream;
 	debug_save = default_core_cfg.debug;
-	if ((yyparse()!=0)||(cfg_errors)){
+	if ((yyparse()!=0)||(cfg_errors)||(pp_ifdef_level_check()<0)){
 		fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors);
 		if (debug_flag) default_core_cfg.debug = debug_save;
-		pp_ifdef_level_check();
+		pp_ifdef_level_error();
 
 		goto error;
 	}
@@ -2310,7 +2310,6 @@ int main(int argc, char** argv)
 		fprintf(stderr, "%d config warnings\n", cfg_warnings);
 	}
 	if (debug_flag) default_core_cfg.debug = debug_save;
-	pp_ifdef_level_check();
 	print_rls();
 
 	if(init_dst_set()<0) {




More information about the sr-dev mailing list