Module: sip-router
Branch: andrei/pointer_alias_warnings
Commit: d103cf3a85bf8346e9c5a0ea1c9bf75caeab03b6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d103cf3…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jan 28 19:52:37 2010 +0100
core: avp aliasing warning fixes
- fixed bug introduced in e95c077.
---
usr_avp.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/usr_avp.c b/usr_avp.c
index a759664..28f19af 100644
--- a/usr_avp.c
+++ b/usr_avp.c
@@ -296,6 +296,8 @@ int add_avp_before(avp_t *avp, avp_flags_t flags, avp_name_t name,
avp_value_t v
/* get value functions */
inline str* get_avp_name(avp_t *avp)
{
+ struct str_int_data *sid;
+ struct str_str_data *ssd;
switch ( avp->flags&(AVP_NAME_STR|AVP_VAL_STR) )
{
@@ -306,10 +308,12 @@ inline str* get_avp_name(avp_t *avp)
return 0;
case AVP_NAME_STR:
/* avp type str, int value */
- return &((struct str_int_data*)avp->d.p)->name;
+ sid = (struct str_int_data*)&avp->d.data[0];
+ return &sid->name;
case AVP_NAME_STR|AVP_VAL_STR:
/* avp type str, str value */
- return &((struct str_str_data*)avp->d.p)->name;
+ ssd = (struct str_str_data*)&avp->d.data[0];
+ return &ssd->name;
}
LOG(L_ERR,"BUG:avp:get_avp_name: unknown avp type (name&val) %d\n",
@@ -320,6 +324,9 @@ inline str* get_avp_name(avp_t *avp)
inline void get_avp_val(avp_t *avp, avp_value_t *val)
{
+ str *s;
+ struct str_int_data *sid;
+ struct str_str_data *ssd;
if (avp==0 || val==0)
return;
@@ -331,15 +338,18 @@ inline void get_avp_val(avp_t *avp, avp_value_t *val)
break;
case AVP_NAME_STR:
/* avp type str, int value */
- val->n = ((struct str_int_data*)avp->d.p)->val;
+ sid = (struct str_int_data*)&avp->d.data[0];
+ val->n = sid->val;
break;
case AVP_VAL_STR:
/* avp type ID, str value */
- val->s = *(str*)avp->d.p;
+ s = (str*)&avp->d.data[0];
+ val->s = *s;
break;
case AVP_NAME_STR|AVP_VAL_STR:
/* avp type str, str value */
- val->s = ((struct str_str_data*)avp->d.p)->val;
+ ssd = (struct str_str_data*)&avp->d.data[0];
+ val->s = ssd->val;
break;
}
}