Browse code

more type punning warnings fixed

Andrei Pelinescu-Onciul authored on 28/11/2008 15:24:15
Showing 4 changed files
... ...
@@ -1142,6 +1142,9 @@ inline static int io_wait_loop_sigio_rt(io_wait_h* h, int t)
1142 1142
 	int sigio_fd;
1143 1143
 	struct fd_map* fm;
1144 1144
 	int revents;
1145
+#ifdef SIGINFO64_WORKARROUND
1146
+	int* pi;
1147
+#endif
1145 1148
 	
1146 1149
 	
1147 1150
 	ret=1; /* 1 event per call normally */
... ...
@@ -1177,8 +1180,9 @@ again:
1177 1177
 		 *  On newer kernels this is fixed (si_band is long in the kernel too).
1178 1178
 		 * -- andrei */
1179 1179
 		if  ((_os_ver<0x020605) && (sizeof(siginfo.si_band)>sizeof(int))){
1180
-			sigio_band=*((int*)(void*)&siginfo.si_band);
1181
-			sigio_fd=*(((int*)(void*)&siginfo.si_band)+1);
1180
+			pi=(int*)(void*)&siginfo.si_band; /* avoid type punning warnings */
1181
+			sigio_band=*pi;
1182
+			sigio_fd=*(pi+1);
1182 1183
 		}else
1183 1184
 #endif
1184 1185
 		{
... ...
@@ -190,7 +190,7 @@ int is_mcast(struct ip_addr* ip)
190 190
 		return IN_MULTICAST(htonl(ip->u.addr32[0]));
191 191
 #ifdef USE_IPV6
192 192
 	} else if (ip->af==AF_INET6){
193
-		return IN6_IS_ADDR_MULTICAST((struct in6_addr *)&ip->u.addr);
193
+		return IN6_IS_ADDR_MULTICAST(&ip->u.addr32[0]);
194 194
 #endif /* USE_IPV6 */
195 195
 	} else {
196 196
 		LOG(L_ERR, "ERROR: is_mcast: Unsupported protocol family\n");
... ...
@@ -242,7 +242,7 @@ inline static int ip_addr_loopback(struct ip_addr* ip)
242 242
 		return ip->u.addr32[0]==htonl(INADDR_LOOPBACK);
243 243
 #ifdef USE_IPV6
244 244
 	else if (ip->af==AF_INET6)
245
-		return IN6_IS_ADDR_LOOPBACK((struct in6_addr *)&ip->u.addr32);
245
+		return IN6_IS_ADDR_LOOPBACK(&ip->u.addr32[0]);
246 246
 #endif /* USE_IPV6 */
247 247
 	return 0;
248 248
 }
... ...
@@ -194,6 +194,7 @@ int cancel_branch( struct cell *t, int branch, int flags )
194 194
 	struct retr_buf *crb, *irb;
195 195
 	int ret;
196 196
 	branch_bm_t tmp_bm;
197
+	void* pcbuf;
197 198
 
198 199
 	crb=&t->uac[branch].local_cancel;
199 200
 	irb=&t->uac[branch].request;
... ...
@@ -216,7 +217,8 @@ int cancel_branch( struct cell *t, int branch, int flags )
216 216
 			DBG("DEBUG: cancel_branch: no response ever received: "
217 217
 			    "giving up on cancel\n");
218 218
 			/* remove BUSY_BUFFER -- mark cancel buffer as not used */
219
-			atomic_set_long((void*)&crb->buffer, 0);
219
+			pcbuf=&crb->buffer; /* workaround for type punning warnings */
220
+			atomic_set_long(pcbuf, 0);
220 221
 			if (flags & F_CANCEL_B_FAKE_REPLY){
221 222
 				LOCK_REPLIES(t);
222 223
 				if (relay_reply(t, FAKED_REPLY, branch, 487, &tmp_bm, 1) == 
... ...
@@ -235,7 +237,8 @@ int cancel_branch( struct cell *t, int branch, int flags )
235 235
 				if (!(flags & F_CANCEL_B_FORCE_RETR))
236 236
 					stop_rb_retr(irb); /* stop retransmissions */
237 237
 				/* remove BUSY_BUFFER -- mark cancel buffer as not used */
238
-				atomic_set_long((void*)&crb->buffer, 0);
238
+				pcbuf=&crb->buffer; /* workaround for type punning warnings */
239
+				atomic_set_long(pcbuf, 0);
239 240
 				if (flags & F_CANCEL_B_FAKE_REPLY){
240 241
 					stop_rb_timers( irb ); /* stop even the fr timer */
241 242
 					LOCK_REPLIES(t);
... ...
@@ -262,7 +265,8 @@ int cancel_branch( struct cell *t, int branch, int flags )
262 262
 	if (!cancel) {
263 263
 		LOG(L_ERR, "ERROR: attempt to build a CANCEL failed\n");
264 264
 		/* remove BUSY_BUFFER -- mark cancel buffer as not used */
265
-		atomic_set_long((void*)&crb->buffer, 0);
265
+		pcbuf=&crb->buffer; /* workaround for type punning warnings */
266
+		atomic_set_long(pcbuf, 0);
266 267
 		return -1;
267 268
 	}
268 269
 	/* install cancel now */