Browse code

core: pointer aliasing warning fixes for fix_rval_expr

Andrei Pelinescu-Onciul authored on 26/08/2010 19:44:59
Showing 3 changed files
... ...
@@ -549,7 +549,7 @@ int fix_expr(struct expr* exp)
549 549
 			   to non-rvals, e.g. string, avp a.s.o and needs to be done
550 550
 			   before MATCH_OP and other fixups) */
551 551
 			if (exp->l_type==RVEXP_O){
552
-				if ((ret=fix_rval_expr(&exp->l.param))<0){
552
+				if ((ret=fix_rval_expr(exp->l.param))<0){
553 553
 					ERR("Unable to fix left rval expression\n");
554 554
 					return ret;
555 555
 				}
... ...
@@ -557,7 +557,7 @@ int fix_expr(struct expr* exp)
557 557
 					exp_optimize_left(exp);
558 558
 			}
559 559
 			if (exp->r_type==RVE_ST){
560
-				if ((ret=fix_rval_expr(&exp->r.param))<0){
560
+				if ((ret=fix_rval_expr(exp->r.param))<0){
561 561
 					ERR("Unable to fix right rval expression\n");
562 562
 					return ret;
563 563
 				}
... ...
@@ -747,7 +747,7 @@ int fix_actions(struct action* a)
747 747
 						return E_UNSPEC;
748 748
 					}
749 749
 					*/
750
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
750
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
751 751
 						goto error;
752 752
 				}
753 753
 				if ( (t->val[1].type==ACTIONS_ST)&&(t->val[1].u.data) ){
... ...
@@ -775,7 +775,7 @@ int fix_actions(struct action* a)
775 775
 					goto error;
776 776
 				}
777 777
 				if (t->val[0].u.data){
778
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
778
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
779 779
 						goto error;
780 780
 				}else{
781 781
 					LOG(L_CRIT, "BUG: fix_actions: null switch()"
... ...
@@ -827,7 +827,7 @@ int fix_actions(struct action* a)
827 827
 						ret = E_SCRIPT;
828 828
 						goto error;
829 829
 					}
830
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
830
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
831 831
 						goto error;
832 832
 				}else{
833 833
 					LOG(L_CRIT, "BUG: fix_actions: null while()"
... ...
@@ -871,7 +871,7 @@ int fix_actions(struct action* a)
871 871
 						ret = E_SCRIPT;
872 872
 						goto error;
873 873
 					}
874
-					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
874
+					if ((ret=fix_rval_expr(t->val[0].u.data))<0)
875 875
 						goto error;
876 876
 				}else{
877 877
 					LOG(L_CRIT, "BUG: fix_actions: null drop/return"
... ...
@@ -910,7 +910,7 @@ int fix_actions(struct action* a)
910 910
 						goto error;
911 911
 					}
912 912
 				}
913
-				if ((ret=fix_rval_expr(&t->val[1].u.data))<0)
913
+				if ((ret=fix_rval_expr(t->val[1].u.data))<0)
914 914
 					goto error;
915 915
 				break;
916 916
 
... ...
@@ -963,7 +963,7 @@ int fix_actions(struct action* a)
963 963
 								/* expression is not constant => fixup &
964 964
 								   optimize it */
965 965
 								rve_param_no++;
966
-								if ((ret=fix_rval_expr(&t->val[i+2].u.data))
966
+								if ((ret=fix_rval_expr(t->val[i+2].u.data))
967 967
 										< 0) {
968 968
 									ERR("rve fixup failed\n");
969 969
 									ret = E_BUG;
... ...
@@ -1104,7 +1104,7 @@ int fix_actions(struct action* a)
1104 1104
 				if (t->val[0].type == RVE_ST) {
1105 1105
 					rve=(struct rval_expr*)t->val[0].u.data;
1106 1106
 					if (!rve_is_constant(rve)) {
1107
-						if ((ret=fix_rval_expr(&t->val[0].u.data)) < 0){
1107
+						if ((ret=fix_rval_expr(t->val[0].u.data)) < 0){
1108 1108
 							ERR("route() failed to fix rve at %s:%d\n",
1109 1109
 								(t->cfile)?t->cfile:"line", t->cline);
1110 1110
 							ret = E_BUG;
... ...
@@ -2899,7 +2899,7 @@ static int fix_match_rve(struct rval_expr* rve)
2899 2899
 	v.s.s=0;
2900 2900
 	v.re.regex=0;
2901 2901
 	/* normal fix-up for the  left side */
2902
-	ret=fix_rval_expr((void**)&rve->left.rve);
2902
+	ret=fix_rval_expr((void*)rve->left.rve);
2903 2903
 	if (ret<0) return ret;
2904 2904
 	
2905 2905
 	/* fixup the right side (RE) */
... ...
@@ -2946,7 +2946,7 @@ static int fix_match_rve(struct rval_expr* rve)
2946 2946
 			goto error;
2947 2947
 	}else{
2948 2948
 		/* right side is not constant => normal fixup */
2949
-		return fix_rval_expr((void**)&rve->right.rve);
2949
+		return fix_rval_expr((void*)rve->right.rve);
2950 2950
 	}
2951 2951
 	return 0;
2952 2952
 error:
... ...
@@ -3688,19 +3688,16 @@ error:
3688 3688
 /** fix a rval_expr.
3689 3689
  * fixes action, bexprs, resolves selects, pvars and
3690 3690
  * optimizes simple sub expressions (e.g. 1+2).
3691
- * It might modify *p.
3692 3691
  *
3693
- * @param p - double pointer to a rval_expr (might be changed to a new one)
3694
- * @return 0 on success, <0 on error (modifies also *p)
3692
+ * @param p - pointer to a rval_expr
3693
+ * @return 0 on success, <0 on error (modifies also *(struct rval_expr*)p)
3695 3694
  */
3696
-int fix_rval_expr(void** p)
3695
+int fix_rval_expr(void* p)
3697 3696
 {
3698
-	struct rval_expr** prve;
3699 3697
 	struct rval_expr* rve;
3700 3698
 	int ret;
3701 3699
 	
3702
-	prve=(struct rval_expr**)p;
3703
-	rve=*prve;
3700
+	rve=(struct rval_expr*)p;
3704 3701
 	
3705 3702
 	switch(rve->op){
3706 3703
 		case RVE_NONE_OP:
... ...
@@ -3716,7 +3713,7 @@ int fix_rval_expr(void** p)
3716 3716
 		case RVE_DEFINED_OP:
3717 3717
 		case RVE_INT_OP:
3718 3718
 		case RVE_STR_OP:
3719
-			ret=fix_rval_expr((void**)&rve->left.rve);
3719
+			ret=fix_rval_expr((void*)rve->left.rve);
3720 3720
 			if (ret<0) return ret;
3721 3721
 			break;
3722 3722
 		case RVE_MUL_OP:
... ...
@@ -3740,9 +3737,9 @@ int fix_rval_expr(void** p)
3740 3740
 		case RVE_STREQ_OP:
3741 3741
 		case RVE_STRDIFF_OP:
3742 3742
 		case RVE_CONCAT_OP:
3743
-			ret=fix_rval_expr((void**)&rve->left.rve);
3743
+			ret=fix_rval_expr((void*)rve->left.rve);
3744 3744
 			if (ret<0) return ret;
3745
-			ret=fix_rval_expr((void**)&rve->right.rve);
3745
+			ret=fix_rval_expr((void*)rve->right.rve);
3746 3746
 			if (ret<0) return ret;
3747 3747
 			break;
3748 3748
 		case RVE_MATCH_OP:
... ...
@@ -240,5 +240,5 @@ struct rval_expr* mk_rval_expr2(enum rval_expr_op op, struct rval_expr* rve1,
240 240
 void rve_destroy(struct rval_expr* rve);
241 241
 
242 242
 /** fix a rval_expr. */
243
-int fix_rval_expr(void** p);
243
+int fix_rval_expr(void* p);
244 244
 #endif /* _rvalue_h */