Browse code

core: pointer aliasing warnings fixed

Andrei Pelinescu-Onciul authored on 12/10/2009 16:49:28
Showing 3 changed files
... ...
@@ -160,6 +160,7 @@ int send_fd(int unix_socket, void* data, int data_len, int fd)
160 160
 	struct iovec iov[1];
161 161
 	int ret;
162 162
 #ifdef HAVE_MSGHDR_MSG_CONTROL
163
+	int* pi;
163 164
 	struct cmsghdr* cmsg;
164 165
 	/* make sure msg_control will point to properly aligned data */
165 166
 	union {
... ...
@@ -176,7 +177,8 @@ int send_fd(int unix_socket, void* data, int data_len, int fd)
176 176
 	cmsg->cmsg_level = SOL_SOCKET;
177 177
 	cmsg->cmsg_type = SCM_RIGHTS;
178 178
 	cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
179
-	*(int*)CMSG_DATA(cmsg)=fd;
179
+	pi=(int*)CMSG_DATA(cmsg);
180
+	*pi=fd;
180 181
 	msg.msg_flags=0;
181 182
 #else
182 183
 	msg.msg_accrights=(caddr_t) &fd;
... ...
@@ -225,6 +227,7 @@ int receive_fd(int unix_socket, void* data, int data_len, int* fd, int flags)
225 225
 	int f;
226 226
 #endif /*NO_MSG_WAITALL */
227 227
 #ifdef HAVE_MSGHDR_MSG_CONTROL
228
+	int* pi;
228 229
 	struct cmsghdr* cmsg;
229 230
 	union{
230 231
 		struct cmsghdr cm;
... ...
@@ -308,7 +311,8 @@ poll_again:
308 308
 			ret=-1;
309 309
 			goto error;
310 310
 		}
311
-		*fd=*((int*) CMSG_DATA(cmsg));
311
+		pi=(int*) CMSG_DATA(cmsg);
312
+		*fd=*pi;
312 313
 	}else{
313 314
 		/*
314 315
 		LOG(L_ERR, "ERROR: receive_fd: no descriptor passed, cmsg=%p,"
... ...
@@ -727,7 +727,7 @@ int fix_actions(struct action* a)
727 727
 						return E_UNSPEC;
728 728
 					}
729 729
 					*/
730
-					if ((ret=fix_rval_expr((void**)&rve))<0)
730
+					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
731 731
 						return ret;
732 732
 				}
733 733
 				if ( (t->val[1].type==ACTIONS_ST)&&(t->val[1].u.data) ){
... ...
@@ -800,7 +800,7 @@ int fix_actions(struct action* a)
800 800
 								rve->fpos.s_line, rve->fpos.s_col);
801 801
 						return E_UNSPEC;
802 802
 					}
803
-					if ((ret=fix_rval_expr((void**)&rve))<0)
803
+					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
804 804
 						return ret;
805 805
 				}else{
806 806
 					LOG(L_CRIT, "BUG: fix_actions: null while()"
... ...
@@ -841,7 +841,7 @@ int fix_actions(struct action* a)
841 841
 								rve->fpos.s_line, rve->fpos.s_col);
842 842
 						return E_UNSPEC;
843 843
 					}
844
-					if ((ret=fix_rval_expr((void**)&rve))<0)
844
+					if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
845 845
 						return ret;
846 846
 				}else{
847 847
 					LOG(L_CRIT, "BUG: fix_actions: null drop/return"
... ...
@@ -306,10 +306,10 @@ inline str* get_avp_name(avp_t *avp)
306 306
 			return 0;
307 307
 		case AVP_NAME_STR:
308 308
 			/* avp type str, int value */
309
-			return &((struct str_int_data*)&avp->d.data[0])->name;
309
+			return &((struct str_int_data*)avp->d.p)->name;
310 310
 		case AVP_NAME_STR|AVP_VAL_STR:
311 311
 			/* avp type str, str value */
312
-			return &((struct str_str_data*)&avp->d.data[0])->name;
312
+			return &((struct str_str_data*)avp->d.p)->name;
313 313
 	}
314 314
 
315 315
 	LOG(L_ERR,"BUG:avp:get_avp_name: unknown avp type (name&val) %d\n",
... ...
@@ -331,15 +331,15 @@ inline void get_avp_val(avp_t *avp, avp_value_t *val)
331 331
 			break;
332 332
 		case AVP_NAME_STR:
333 333
 			/* avp type str, int value */
334
-			val->n = ((struct str_int_data*)&avp->d.data[0])->val;
334
+			val->n = ((struct str_int_data*)avp->d.p)->val;
335 335
 			break;
336 336
 		case AVP_VAL_STR:
337 337
 			/* avp type ID, str value */
338
-			val->s = *(str*)&avp->d.data[0];
338
+			val->s = *(str*)avp->d.p;
339 339
 			break;
340 340
 		case AVP_NAME_STR|AVP_VAL_STR:
341 341
 			/* avp type str, str value */
342
-			val->s = ((struct str_str_data*)&avp->d.data[0])->val;
342
+			val->s = ((struct str_str_data*)avp->d.p)->val;
343 343
 			break;
344 344
 	}
345 345
 }