瀏覽代碼

tm: warnings and avp param init. fixes

- wrong pointer was passed to pv_get_avp_name(): int instead of
  unsigned short ( => not the whole int was set and problems on
  big endian archs).
- unneeded pointer casts removed
- variables declared at the function start (otherwise older
  compilers won't work)
Andrei Pelinescu-Onciul 15 年之前
父節點
當前提交
ff78f8722f
共有 3 個文件被更改,包括 10 次插入7 次删除
  1. 7 4
      modules/tm/t_funcs.c
  2. 2 2
      modules/tm/t_msgbuilder.c
  3. 1 1
      modules/tm/t_reply.c

+ 7 - 4
modules/tm/t_funcs.c

@@ -402,6 +402,7 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
 					char* contacts_avp_param)
 					char* contacts_avp_param)
 {
 {
 	pv_spec_t avp_spec;
 	pv_spec_t avp_spec;
+	unsigned short avp_type;
 
 
 	if (fr_timer_param && *fr_timer_param) {
 	if (fr_timer_param && *fr_timer_param) {
 		fr_timer_str.s = fr_timer_param;
 		fr_timer_str.s = fr_timer_param;
@@ -417,12 +418,12 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
 				return -1;
 				return -1;
 			}
 			}
 
 
-			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_timer_avp, 
-						(unsigned short*)&fr_timer_avp_type)!=0)
+			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_timer_avp, &avp_type)!=0)
 			{
 			{
 				LM_ERR("[%s]- invalid AVP definition\n", fr_timer_param);
 				LM_ERR("[%s]- invalid AVP definition\n", fr_timer_param);
 				return -1;
 				return -1;
 			}
 			}
+			fr_timer_avp_type = avp_type;
 		} else {
 		} else {
 			if (parse_avp_spec( &fr_timer_str, &fr_timer_avp_type,
 			if (parse_avp_spec( &fr_timer_str, &fr_timer_avp_type,
 			&fr_timer_avp, &fr_timer_index)<0) {
 			&fr_timer_avp, &fr_timer_index)<0) {
@@ -448,11 +449,12 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
 			}
 			}
 
 
 			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_inv_timer_avp,
 			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_inv_timer_avp,
-						(unsigned short*)&fr_inv_timer_avp_type)!=0)
+								&avp_type)!=0)
 			{
 			{
 				LM_ERR("[%s]- invalid AVP definition\n", fr_inv_timer_param);
 				LM_ERR("[%s]- invalid AVP definition\n", fr_inv_timer_param);
 				return -1;
 				return -1;
 			}
 			}
+			fr_inv_timer_avp_type = avp_type;
 		} else {
 		} else {
 			if (parse_avp_spec( &fr_inv_timer_str, &fr_inv_timer_avp_type, 
 			if (parse_avp_spec( &fr_inv_timer_str, &fr_inv_timer_avp_type, 
 			&fr_inv_timer_avp, &fr_inv_timer_index)<0) {
 			&fr_inv_timer_avp, &fr_inv_timer_index)<0) {
@@ -476,10 +478,11 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
 			}
 			}
 
 
 			if(pv_get_avp_name(0, &(avp_spec.pvp), &contacts_avp,
 			if(pv_get_avp_name(0, &(avp_spec.pvp), &contacts_avp,
-						(unsigned short*)&contacts_avp_type) != 0) {
+						&avp_type) != 0) {
 				LM_ERR("invalid AVP definition <%s>\n", contacts_avp_param);
 				LM_ERR("invalid AVP definition <%s>\n", contacts_avp_param);
 				return -1;
 				return -1;
 			}
 			}
+			contacts_avp_type = avp_type;
 		} else {
 		} else {
 			if (parse_avp_spec( &contacts_avp_str, &contacts_avp_type,
 			if (parse_avp_spec( &contacts_avp_str, &contacts_avp_type,
 								&contacts_avp, &contacts_avp_index)<0) {
 								&contacts_avp, &contacts_avp_index)<0) {

+ 2 - 2
modules/tm/t_msgbuilder.c

@@ -808,7 +808,7 @@ static unsigned long nhop_type(sip_msg_t *orig_inv, rte_t *rtset,
 	 * equals the address provided by this route; if does -> loose */
 	 * equals the address provided by this route; if does -> loose */
 	DEBUG("checking INVITE's destination against its first route.\n");
 	DEBUG("checking INVITE's destination against its first route.\n");
 	URI_PORT(&topr_uri, uri_port);
 	URI_PORT(&topr_uri, uri_port);
-	if (! (dst_port = su_getport((void *)&dst_inv->to)))
+	if (! (dst_port = su_getport(&dst_inv->to)))
 		return 0; /* not really expected */
 		return 0; /* not really expected */
 	if (dst_port != uri_port)
 	if (dst_port != uri_port)
 		return F_RB_NH_STRICT;
 		return F_RB_NH_STRICT;
@@ -821,7 +821,7 @@ static unsigned long nhop_type(sip_msg_t *orig_inv, rte_t *rtset,
 		/* we have an IP address in route -> comparison can go swiftly */
 		/* we have an IP address in route -> comparison can go swiftly */
 		if (init_su(&uri_sau, uri_ia, uri_port) < 0)
 		if (init_su(&uri_sau, uri_ia, uri_port) < 0)
 			return 0; /* not really expected */
 			return 0; /* not really expected */
-		if (su_cmp(&uri_sau, (void *)&dst_inv->to))
+		if (su_cmp(&uri_sau, &dst_inv->to))
 			/* ;lr and sent there */
 			/* ;lr and sent there */
 			return F_RB_NH_LOOSE;
 			return F_RB_NH_LOOSE;
 		else
 		else

+ 1 - 1
modules/tm/t_reply.c

@@ -1595,6 +1595,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	/* retransmission structure of outbound reply and request */
 	/* retransmission structure of outbound reply and request */
 	struct retr_buf *uas_rb;
 	struct retr_buf *uas_rb;
 	str* to_tag;
 	str* to_tag;
+	str reason;
 #ifdef TMCB_ONSEND
 #ifdef TMCB_ONSEND
 	struct tmcb_params onsend_params;
 	struct tmcb_params onsend_params;
 #endif
 #endif
@@ -1605,7 +1606,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	relayed_msg=0;
 	relayed_msg=0;
 	relayed_code=0;
 	relayed_code=0;
 	totag_retr=0;
 	totag_retr=0;
-	str reason;
 
 
 
 
 	/* remember, what was sent upstream to know whether we are
 	/* remember, what was sent upstream to know whether we are