[sr-dev] git:master: switch.c: logging: convert LOG to LM_*

Ovidiu Sas osas at voipembedded.com
Sat Oct 4 03:50:31 CEST 2014


Module: sip-router
Branch: master
Commit: 14839f0692498e9e6ba30ae14c815c990978465d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=14839f0692498e9e6ba30ae14c815c990978465d

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Fri Oct  3 21:50:19 2014 -0400

switch.c: logging: convert LOG to LM_*

---

 switch.c |   60 +++++++++++++++++++++++++-----------------------------------
 1 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/switch.c b/switch.c
index c1feabc..2958a75 100644
--- a/switch.c
+++ b/switch.c
@@ -197,19 +197,16 @@ int fix_switch(struct action* t)
 	for (c=(struct case_stms*)t->val[1].u.data; c; c=c->next){
 		if (c->ct_rve){
 			if (c->type!=MATCH_INT){
-				LOG(L_ERR, "ERROR: fix_switch: wrong case type %d (int"
-							"expected)\n", c->type);
+				LM_ERR("wrong case type %d (int expected)\n", c->type);
 				return E_UNSPEC;
 			}
 			if (!rve_is_constant(c->ct_rve)){
-				LOG(L_ERR, "ERROR: fix_switch: non constant "
-						"expression in case\n");
+				LM_ERR("non constant expression in case\n");
 				return E_BUG;
 			}
 			if (rval_expr_eval_int(0, 0,  &c->label.match_int, c->ct_rve)
 					<0){
-				LOG(L_ERR, "ERROR: fix_switch: case expression"
-						" (%d,%d) has non-interger type\n",
+				LM_ERR("case expression (%d,%d) has non-interger type\n",
 						c->ct_rve->fpos.s_line,
 						c->ct_rve->fpos.s_col);
 				return E_BUG;
@@ -218,7 +215,7 @@ int fix_switch(struct action* t)
 			n++; /* count only non-default cases */
 		}else{
 			if (default_found){
-				LOG(L_ERR, "ERROR: fix_switch: more then one \"default\"");
+				LM_ERR("more then one \"default\"");
 				return E_UNSPEC;
 			}
 			default_found=1;
@@ -246,8 +243,7 @@ int fix_switch(struct action* t)
 			}
 			DBG("SWITCH: default only switch with side-effect...\n");
 		}else{
-			LOG(L_CRIT, "BUG: fix_switch: empty switch not expected at this"
-					" point\n");
+			LM_CRIT("empty switch not expected at this point\n");
 			ret=E_BUG;
 			goto error;
 		}
@@ -255,7 +251,7 @@ int fix_switch(struct action* t)
 	cond=pkg_malloc(sizeof(cond[0])*n);
 	jmp_bm=pkg_malloc(sizeof(jmp_bm[0])*n);
 	if (cond==0 || jmp_bm==0){
-		LOG(L_ERR, "ERROR: fix_switch: memory allocation failure\n");
+		LM_ERR("memory allocation failure\n");
 		ret=E_OUT_OF_MEM;
 		goto error;
 	}
@@ -280,7 +276,7 @@ int fix_switch(struct action* t)
 		} else {
 			for (j=0; j<n; j++){
 				if (cond[j]==c->label.match_int){
-					LOG(L_ERR, "ERROR: fix_switch: duplicate case (%d,%d)\n",
+					LM_ERR("duplicate case (%d,%d)\n",
 							c->ct_rve->fpos.s_line, c->ct_rve->fpos.s_col);
 					ret=E_UNSPEC;
 					goto error;
@@ -298,8 +294,7 @@ int fix_switch(struct action* t)
 	if ( (scr_opt_lev>=2) &&
 			!rve_has_side_effects(sw_rve) && rve_is_constant(sw_rve)){
 		if (rval_expr_eval_int(0, 0,  &val, sw_rve) <0){
-			LOG(L_ERR, "ERROR: fix_switch: wrong type for switch(...) "
-					"expression (%d,%d)\n", 
+			LM_ERR("wrong type for switch(...) expression (%d,%d)\n", 
 					sw_rve->fpos.s_line, sw_rve->fpos.s_col);
 			ret=E_UNSPEC;
 			goto error;
@@ -355,7 +350,7 @@ int fix_switch(struct action* t)
 		 with a n-best_hits normal switch table */
 		jmp=mk_switch_jmp_table(end-start+1, n-best_hits);
 		if (jmp==0){
-			LOG(L_ERR, "ERROR: fix_switch: memory allocation error\n");
+			LM_ERR("memory allocation error\n");
 			ret=E_OUT_OF_MEM;
 			goto error;
 		}
@@ -385,7 +380,7 @@ int fix_switch(struct action* t)
 	}else{
 		sct=mk_switch_cond_table(n);
 		if (sct==0){
-			LOG(L_ERR, "ERROR: fix_switch: memory allocation error\n");
+			LM_ERR("memory allocation error\n");
 			ret=E_OUT_OF_MEM;
 			goto error;
 		}
@@ -468,26 +463,24 @@ static int fix_match(struct action* t)
 	for (c=(struct case_stms*)t->val[1].u.data; c; c=c->next){
 		if (c->ct_rve){
 			if (c->type!=MATCH_STR && c->type!=MATCH_RE){
-				LOG(L_ERR, "ERROR: fix_match: wrong case type %d (string"
+				LM_ERR("wrong case type %d (string"
 							"or RE expected)\n", c->type);
 				return E_UNSPEC;
 			}
 			if (!rve_is_constant(c->ct_rve)){
-				LOG(L_ERR, "ERROR: fix_match: non constant "
-						"expression in case\n");
+				LM_ERR("non constant expression in case\n");
 				ret=E_BUG;
 				goto error;
 			}
 			if ((rv=rval_expr_eval(0, 0, c->ct_rve)) == 0 ){
-				LOG(L_ERR, "ERROR: fix_match: bad case expression"
-						" (%d,%d)\n",
+				LM_ERR("bad case expression (%d,%d)\n",
 						c->ct_rve->fpos.s_line,
 						c->ct_rve->fpos.s_col);
 				ret=E_BUG;
 				goto error;
 			}
 			if (rval_get_str(0, 0, &s, rv, 0)<0){
-				LOG(L_ERR, "ERROR: fix_match (%d,%d): out of memory?\n",
+				LM_ERR("(%d,%d): out of memory?\n",
 						c->ct_rve->fpos.s_line,
 						c->ct_rve->fpos.s_col);
 				ret=E_BUG;
@@ -495,7 +488,7 @@ static int fix_match(struct action* t)
 			}
 			if (c->type==MATCH_RE){
 				if ((regex=pkg_malloc(sizeof(regex_t))) == 0){
-					LOG(L_ERR, "ERROR: fix_match: out of memory\n");
+					LM_ERR("out of memory\n");
 					ret=E_OUT_OF_MEM;
 					goto error;
 				}
@@ -503,8 +496,7 @@ static int fix_match(struct action* t)
 							REG_EXTENDED | REG_NOSUB | c->re_flags) !=0){
 					pkg_free(regex);
 					regex=0;
-					LOG(L_ERR, "ERROR: fix_match (%d, %d): bad regular"
-								" expression %.*s\n",
+					LM_ERR("(%d, %d): bad regular expression %.*s\n",
 							c->ct_rve->fpos.s_line,
 							c->ct_rve->fpos.s_col,
 							s.len, ZSW(s.s));
@@ -518,7 +510,7 @@ static int fix_match(struct action* t)
 				s.s=0;
 				s.len=0;
 			}else{
-				LOG(L_CRIT, "BUG: fix_match (%d,%d): wrong case type %d\n",
+				LM_CRIT("(%d,%d): wrong case type %d\n",
 						c->ct_rve->fpos.s_line, c->ct_rve->fpos.s_col,
 						c->type);
 				ret=E_BUG;
@@ -536,8 +528,7 @@ static int fix_match(struct action* t)
 			}
 		}else{
 			if (default_found){
-				LOG(L_ERR, "ERROR: fix_match: more then one \"default\""
-						" label found (%d, %d)\n",
+				LM_ERR("more then one \"default\" label found (%d, %d)\n",
 						(c->ct_rve)?c->ct_rve->fpos.s_line:0,
 						(c->ct_rve)?c->ct_rve->fpos.s_col:0);
 				ret=E_UNSPEC;
@@ -567,8 +558,7 @@ static int fix_match(struct action* t)
 			}
 			DBG("MATCH: default only switch with side-effect...\n");
 		}else{
-			LOG(L_CRIT, "BUG: fix_match: empty switch not expected at this"
-					" point\n");
+			LM_CRIT("empty switch not expected at this point\n");
 			ret=E_BUG;
 			goto error;
 		}
@@ -577,7 +567,7 @@ static int fix_match(struct action* t)
 	match=pkg_malloc(sizeof(match[0])*n);
 	jmp_bm=pkg_malloc(sizeof(jmp_bm[0])*n);
 	if (match==0 || jmp_bm==0){
-		LOG(L_ERR, "ERROR: fix_match: memory allocation failure\n");
+		LM_ERR("memory allocation failure\n");
 		ret=E_OUT_OF_MEM;
 		goto error;
 	}
@@ -607,8 +597,8 @@ static int fix_match(struct action* t)
 						 match[j].l.s.len ==  c->label.match_str.len &&
 						 memcmp(match[j].l.s.s, c->label.match_str.s,
 							 		match[j].l.s.len) == 0 ){
-						LOG(L_ERR, "ERROR: fix_match: duplicate case"
-								" (%d,%d)\n", c->ct_rve->fpos.s_line,
+						LM_ERR("duplicate case (%d,%d)\n",
+								c->ct_rve->fpos.s_line,
 								c->ct_rve->fpos.s_col);
 						ret=E_UNSPEC;
 						goto error;
@@ -634,13 +624,13 @@ static int fix_match(struct action* t)
 	if ( (scr_opt_lev>=2) &&
 			!rve_has_side_effects(m_rve) && rve_is_constant(m_rve)){
 		if ((rv=rval_expr_eval(0, 0, m_rve)) == 0){
-			LOG(L_ERR, "ERROR: fix_match: bad expression (%d,%d)\n", 
+			LM_ERR("bad expression (%d,%d)\n", 
 					m_rve->fpos.s_line, m_rve->fpos.s_col);
 			ret=E_UNSPEC;
 			goto error;
 		}
 		if (rval_get_str(0, 0, &s, rv, 0) < 0 ){
-				LOG(L_ERR, "ERROR: fix_match (%d,%d): bad string expression\n",
+				LM_ERR("(%d,%d): bad string expression\n",
 						m_rve->fpos.s_line,
 						m_rve->fpos.s_col);
 			ret=E_UNSPEC;
@@ -678,7 +668,7 @@ static int fix_match(struct action* t)
 	}
 	mct=mk_match_cond_table(n);
 	if (mct==0){
-		LOG(L_ERR, "ERROR: fix_match: memory allocation error\n");
+		LM_ERR("memory allocation error\n");
 		ret=E_OUT_OF_MEM;
 		goto error;
 	}




More information about the sr-dev mailing list