[SR-Dev] git:andrei/type_conversion: core expr eval: various fixes

Andrei Pelinescu-Onciul andrei at iptel.org
Wed Apr 29 14:03:56 CEST 2009


Module: sip-router
Branch: andrei/type_conversion
Commit: e9249a149a3dca35c8f7f0b3c1f72343cd1a9c30
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e9249a149a3dca35c8f7f0b3c1f72343cd1a9c30

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed Apr 29 13:55:01 2009 +0200

core expr eval: various fixes

- fix pvars type evaluated to STRING almost always (when they had
  PV_VAL_STR).
- fix undefined not properly propagated for avps (typo) which caused
  some comparsion to behave in unexpected way (e.g.
  $undef_avp != $undef_avp was true).
- fix <undef>+something (used to produce an error, now is
  equivalent to "" + something).

---

 rvalue.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/rvalue.c b/rvalue.c
index 9a74cda..55456a1 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -314,18 +314,18 @@ inline static enum rval_type rval_get_btype(struct run_act_ctx* h,
 			}
 			memset(pv, 0, sizeof(tmp_pval));
 			if (likely(pv_get_spec_value(msg, &rv->v.pvs, pv)==0)){
-				if (pv->flags & PV_VAL_STR){
+				if (pv->flags & PV_TYPE_INT){
 					if (likely(val_cache!=0))
-						val_cache->val_type=RV_STR;
+						val_cache->val_type=RV_INT;
 					else
 						pv_value_destroy(pv);
-					return RV_STR;
-				}else if (pv->flags & PV_TYPE_INT){
+					return RV_INT;
+				}else if (pv->flags & PV_VAL_STR){
 					if (likely(val_cache!=0))
-						val_cache->val_type=RV_INT;
+						val_cache->val_type=RV_STR;
 					else
 						pv_value_destroy(pv);
-					return RV_INT;
+					return RV_STR;
 				}else{
 					pv_value_destroy(pv);
 					if (likely(val_cache!=0))
@@ -339,7 +339,7 @@ inline static enum rval_type rval_get_btype(struct run_act_ctx* h,
 			}
 			break;
 		case RV_AVP:
-			if (likely(val_cache && val_cache==RV_CACHE_EMPTY)){
+			if (likely(val_cache && val_cache->cache_type==RV_CACHE_EMPTY)){
 				ptype=&val_cache->val_type;
 				avpv=&val_cache->c.avp_val;
 				val_cache->cache_type=RV_CACHE_AVP;
@@ -718,6 +718,11 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve,
 			}
 			break;
 		case RVE_NONE_OP:
+		default:
+			BUG("unexpected rve op %d\n", rve->op);
+			if (bad_rve) *bad_rve=rve;
+			if (bad_t) *bad_t=RV_NONE;
+			if (exp_t) *exp_t=RV_STR;
 			break;
 	}
 	return 0;
@@ -2041,6 +2046,7 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg,
 					}
 					break;
 				case RV_STR:
+				case RV_NONE:
 					rv2=rval_expr_eval(h, msg, rve->right.rve);
 					if (unlikely(rv2==0)){
 						ERR("rval expression evaluation failed\n");
@@ -2051,9 +2057,6 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg,
 					break;
 				default:
 					BUG("rv unsupported basic type %d\n", type);
-				case RV_NONE:
-					rval_cache_clean(&c1);
-					goto error;
 			}
 			rval_cache_clean(&c1);
 			break;




More information about the sr-dev mailing list