Browse code

core: stop start if ifdef check fails

Related #2057

Victor Seva authored on 23/12/2019 12:53:39
Showing 3 changed files
... ...
@@ -216,19 +216,27 @@ void pp_ifdef_level_update(int val)
216 216
 /**
217 217
  *
218 218
  */
219
-void pp_ifdef_level_check(void)
219
+int pp_ifdef_level_check(void)
220
+{
221
+	if(_pp_ifdef_level!=0) {
222
+		return -1;
223
+	} else {
224
+		LM_DBG("same number of pairing preprocessor directives"
225
+			" #!IF[N]DEF - #!ENDIF\n");
226
+	}
227
+	return 0;
228
+}
229
+
230
+void pp_ifdef_level_error(void)
220 231
 {
221 232
 	if(_pp_ifdef_level!=0) {
222 233
 		if (_pp_ifdef_level > 0) {
223
-	                LM_WARN("different number of preprocessor directives:"
234
+			LM_ERR("different number of preprocessor directives:"
224 235
 				" %d more #!if[n]def as #!endif\n", _pp_ifdef_level);
225 236
 		} else {
226
-			LM_WARN("different number of preprocessor directives:"
237
+			LM_ERR("different number of preprocessor directives:"
227 238
 				" %d more #!endif as #!if[n]def\n", (_pp_ifdef_level)*-1);
228 239
 		}
229
-	} else {
230
-		LM_DBG("same number of pairing preprocessor directives"
231
-			" #!IF[N]DEF - #!ENDIF\n");
232 240
 	}
233 241
 }
234 242
 
... ...
@@ -44,7 +44,8 @@ int  pp_define_set_type(int type);
44 44
 str *pp_define_get(int len, const char * text);
45 45
 
46 46
 void pp_ifdef_level_update(int val);
47
-void pp_ifdef_level_check(void);
47
+int pp_ifdef_level_check(void);
48
+void pp_ifdef_level_error(void);
48 49
 
49 50
 void pp_define_core(void);
50 51
 
... ...
@@ -2299,10 +2299,10 @@ try_again:
2299 2299
 
2300 2300
 	yyin=cfg_stream;
2301 2301
 	debug_save = default_core_cfg.debug;
2302
-	if ((yyparse()!=0)||(cfg_errors)){
2302
+	if ((yyparse()!=0)||(cfg_errors)||(pp_ifdef_level_check()<0)){
2303 2303
 		fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors);
2304 2304
 		if (debug_flag) default_core_cfg.debug = debug_save;
2305
-		pp_ifdef_level_check();
2305
+		pp_ifdef_level_error();
2306 2306
 
2307 2307
 		goto error;
2308 2308
 	}
... ...
@@ -2310,7 +2310,6 @@ try_again:
2310 2310
 		fprintf(stderr, "%d config warnings\n", cfg_warnings);
2311 2311
 	}
2312 2312
 	if (debug_flag) default_core_cfg.debug = debug_save;
2313
-	pp_ifdef_level_check();
2314 2313
 	print_rls();
2315 2314
 
2316 2315
 	if(init_dst_set()<0) {