浏览代码

core: pointer aliasing warning fixes for fix_rval_expr

Andrei Pelinescu-Onciul 15 年之前
父节点
当前提交
d6dd5f5649
共有 3 个文件被更改,包括 19 次插入22 次删除
  1. 9 9
      route.c
  2. 9 12
      rvalue.c
  3. 1 1
      rvalue.h

+ 9 - 9
route.c

@@ -549,7 +549,7 @@ int fix_expr(struct expr* exp)
 			   to non-rvals, e.g. string, avp a.s.o and needs to be done
 			   before MATCH_OP and other fixups) */
 			if (exp->l_type==RVEXP_O){
-				if ((ret=fix_rval_expr(&exp->l.param))<0){
+				if ((ret=fix_rval_expr(exp->l.param))<0){
 					ERR("Unable to fix left rval expression\n");
 					return ret;
 				}
@@ -557,7 +557,7 @@ int fix_expr(struct expr* exp)
 					exp_optimize_left(exp);
 			}
 			if (exp->r_type==RVE_ST){
-				if ((ret=fix_rval_expr(&exp->r.param))<0){
+				if ((ret=fix_rval_expr(exp->r.param))<0){
 					ERR("Unable to fix right rval expression\n");
 					return ret;
 				}
@@ -747,7 +747,7 @@ int fix_actions(struct action* a)
 						return E_UNSPEC;
 					}
 					*/
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
 						goto error;
 				}
 				if ( (t->val[1].type==ACTIONS_ST)&&(t->val[1].u.data) ){
@@ -775,7 +775,7 @@ int fix_actions(struct action* a)
 					goto error;
 				}
 				if (t->val[0].u.data){
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
 						goto error;
 				}else{
 					LOG(L_CRIT, "BUG: fix_actions: null switch()"
@@ -827,7 +827,7 @@ int fix_actions(struct action* a)
 						ret = E_SCRIPT;
 						goto error;
 					}
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
 						goto error;
 				}else{
 					LOG(L_CRIT, "BUG: fix_actions: null while()"
@@ -871,7 +871,7 @@ int fix_actions(struct action* a)
 						ret = E_SCRIPT;
 						goto error;
 					}
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
 						goto error;
 				}else{
 					LOG(L_CRIT, "BUG: fix_actions: null drop/return"
@@ -910,7 +910,7 @@ int fix_actions(struct action* a)
 						goto error;
 					}
 				}
-				if ((ret=fix_rval_expr(&t->val[1].u.data))<0)
+				if ((ret=fix_rval_expr(t->val[1].u.data))<0)
 					goto error;
 				break;
 
@@ -963,7 +963,7 @@ int fix_actions(struct action* a)
 								/* expression is not constant => fixup &
 								   optimize it */
 								rve_param_no++;
-								if ((ret=fix_rval_expr(&t->val[i+2].u.data))
+								if ((ret=fix_rval_expr(t->val[i+2].u.data))
 										< 0) {
 									ERR("rve fixup failed\n");
 									ret = E_BUG;
@@ -1104,7 +1104,7 @@ int fix_actions(struct action* a)
 				if (t->val[0].type == RVE_ST) {
 					rve=(struct rval_expr*)t->val[0].u.data;
 					if (!rve_is_constant(rve)) {
-						if ((ret=fix_rval_expr(&t->val[0].u.data)) < 0){
+						if ((ret=fix_rval_expr(t->val[0].u.data)) < 0){
 							ERR("route() failed to fix rve at %s:%d\n",
 								(t->cfile)?t->cfile:"line", t->cline);
 							ret = E_BUG;

+ 9 - 12
rvalue.c

@@ -2899,7 +2899,7 @@ static int fix_match_rve(struct rval_expr* rve)
 	v.s.s=0;
 	v.re.regex=0;
 	/* normal fix-up for the  left side */
-	ret=fix_rval_expr((void**)&rve->left.rve);
+	ret=fix_rval_expr((void*)rve->left.rve);
 	if (ret<0) return ret;
 	
 	/* fixup the right side (RE) */
@@ -2946,7 +2946,7 @@ static int fix_match_rve(struct rval_expr* rve)
 			goto error;
 	}else{
 		/* right side is not constant => normal fixup */
-		return fix_rval_expr((void**)&rve->right.rve);
+		return fix_rval_expr((void*)rve->right.rve);
 	}
 	return 0;
 error:
@@ -3688,19 +3688,16 @@ error:
 /** fix a rval_expr.
  * fixes action, bexprs, resolves selects, pvars and
  * optimizes simple sub expressions (e.g. 1+2).
- * It might modify *p.
  *
- * @param p - double pointer to a rval_expr (might be changed to a new one)
- * @return 0 on success, <0 on error (modifies also *p)
+ * @param p - pointer to a rval_expr
+ * @return 0 on success, <0 on error (modifies also *(struct rval_expr*)p)
  */
-int fix_rval_expr(void** p)
+int fix_rval_expr(void* p)
 {
-	struct rval_expr** prve;
 	struct rval_expr* rve;
 	int ret;
 	
-	prve=(struct rval_expr**)p;
-	rve=*prve;
+	rve=(struct rval_expr*)p;
 	
 	switch(rve->op){
 		case RVE_NONE_OP:
@@ -3716,7 +3713,7 @@ int fix_rval_expr(void** p)
 		case RVE_DEFINED_OP:
 		case RVE_INT_OP:
 		case RVE_STR_OP:
-			ret=fix_rval_expr((void**)&rve->left.rve);
+			ret=fix_rval_expr((void*)rve->left.rve);
 			if (ret<0) return ret;
 			break;
 		case RVE_MUL_OP:
@@ -3740,9 +3737,9 @@ int fix_rval_expr(void** p)
 		case RVE_STREQ_OP:
 		case RVE_STRDIFF_OP:
 		case RVE_CONCAT_OP:
-			ret=fix_rval_expr((void**)&rve->left.rve);
+			ret=fix_rval_expr((void*)rve->left.rve);
 			if (ret<0) return ret;
-			ret=fix_rval_expr((void**)&rve->right.rve);
+			ret=fix_rval_expr((void*)rve->right.rve);
 			if (ret<0) return ret;
 			break;
 		case RVE_MATCH_OP:

+ 1 - 1
rvalue.h

@@ -240,5 +240,5 @@ struct rval_expr* mk_rval_expr2(enum rval_expr_op op, struct rval_expr* rve1,
 void rve_destroy(struct rval_expr* rve);
 
 /** fix a rval_expr. */
-int fix_rval_expr(void** p);
+int fix_rval_expr(void* p);
 #endif /* _rvalue_h */