[sr-dev] git:master: core: proper return code for pvar assignment

Daniel-Constantin Mierla miconda at gmail.com
Mon Feb 21 23:16:51 CET 2011


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Feb 21 23:15:29 2011 +0100

core: proper return code for pvar assignment

- in some case the value of the right expression was returned instead of
  proper >=0 for success cases
- reported by Juha Heinannen

---

 lvalue.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lvalue.c b/lvalue.c
index e13e1a5..5d433f2 100644
--- a/lvalue.c
+++ b/lvalue.c
@@ -290,7 +290,7 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
 														    break in expr*/
 			} else
 				pval.ri=0;
-			ret=pval.ri;
+			ret=!(!pval.ri);
 			break;
 		case RV_BEXPR: /* logic/boolean expr. */
 			pval.flags=PV_TYPE_INT|PV_VAL_INT;
@@ -301,7 +301,7 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
 				WARN("error in expression\n");
 				pval.ri=0; /* expr. is treated as false */
 			}
-			ret=pval.ri;
+			ret=!(!pval.ri);
 			break;
 		case RV_SEL:
 			pval.flags=PV_VAL_STR;
@@ -315,7 +315,7 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
 					break;
 				}
 			}
-			ret=(pval.rs.len)>0;
+			ret=(pval.rs.len>0);
 			break;
 		case RV_AVP:
 				r_avp = search_avp_by_index(rv->v.avps.type, rv->v.avps.name,




More information about the sr-dev mailing list