Browse code

core: avp aliasing warning fixes

- fixed bug introduced in e95c077.

Andrei Pelinescu-Onciul authored on 28/01/2010 18:52:37
Showing 1 changed files
... ...
@@ -296,6 +296,8 @@ int add_avp_before(avp_t *avp, avp_flags_t flags, avp_name_t name, avp_value_t v
296 296
 /* get value functions */
297 297
 inline str* get_avp_name(avp_t *avp)
298 298
 {
299
+	struct str_int_data *sid;
300
+	struct str_str_data *ssd;
299 301
 	
300 302
 	switch ( avp->flags&(AVP_NAME_STR|AVP_VAL_STR) )
301 303
 	{
... ...
@@ -306,10 +308,12 @@ inline str* get_avp_name(avp_t *avp)
306 308
 			return 0;
307 309
 		case AVP_NAME_STR:
308 310
 			/* avp type str, int value */
309
-			return &((struct str_int_data*)avp->d.p)->name;
311
+			sid = (struct str_int_data*)&avp->d.data[0];
312
+			return &sid->name;
310 313
 		case AVP_NAME_STR|AVP_VAL_STR:
311 314
 			/* avp type str, str value */
312
-			return &((struct str_str_data*)avp->d.p)->name;
315
+			ssd = (struct str_str_data*)&avp->d.data[0];
316
+			return &ssd->name;
313 317
 	}
314 318
 
315 319
 	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)
320 324
 
321 325
 inline void get_avp_val(avp_t *avp, avp_value_t *val)
322 326
 {
327
+	str *s;
328
+	struct str_int_data *sid;
329
+	struct str_str_data *ssd;
323 330
 	
324 331
 	if (avp==0 || val==0)
325 332
 		return;
... ...
@@ -331,15 +338,18 @@ inline void get_avp_val(avp_t *avp, avp_value_t *val)
331 338
 			break;
332 339
 		case AVP_NAME_STR:
333 340
 			/* avp type str, int value */
334
-			val->n = ((struct str_int_data*)avp->d.p)->val;
341
+			sid = (struct str_int_data*)&avp->d.data[0];
342
+			val->n = sid->val;
335 343
 			break;
336 344
 		case AVP_VAL_STR:
337 345
 			/* avp type ID, str value */
338
-			val->s = *(str*)avp->d.p;
346
+			s = (str*)&avp->d.data[0];
347
+			val->s = *s;
339 348
 			break;
340 349
 		case AVP_NAME_STR|AVP_VAL_STR:
341 350
 			/* avp type str, str value */
342
-			val->s = ((struct str_str_data*)avp->d.p)->val;
351
+			ssd = (struct str_str_data*)&avp->d.data[0];
352
+			val->s = ssd->val;
343 353
 			break;
344 354
 	}
345 355
 }