Răsfoiți Sursa

more type punning warnings fixed

Andrei Pelinescu-Onciul 17 ani în urmă
părinte
comite
018226b08a
4 a modificat fișierele cu 15 adăugiri și 7 ștergeri
  1. 6 2
      io_wait.h
  2. 1 1
      ip_addr.c
  3. 1 1
      ip_addr.h
  4. 7 3
      modules/tm/t_cancel.c

+ 6 - 2
io_wait.h

@@ -1142,6 +1142,9 @@ inline static int io_wait_loop_sigio_rt(io_wait_h* h, int t)
 	int sigio_fd;
 	struct fd_map* fm;
 	int revents;
+#ifdef SIGINFO64_WORKARROUND
+	int* pi;
+#endif
 	
 	
 	ret=1; /* 1 event per call normally */
@@ -1177,8 +1180,9 @@ again:
 		 *  On newer kernels this is fixed (si_band is long in the kernel too).
 		 * -- andrei */
 		if  ((_os_ver<0x020605) && (sizeof(siginfo.si_band)>sizeof(int))){
-			sigio_band=*((int*)(void*)&siginfo.si_band);
-			sigio_fd=*(((int*)(void*)&siginfo.si_band)+1);
+			pi=(int*)(void*)&siginfo.si_band; /* avoid type punning warnings */
+			sigio_band=*pi;
+			sigio_fd=*(pi+1);
 		}else
 #endif
 		{

+ 1 - 1
ip_addr.c

@@ -190,7 +190,7 @@ int is_mcast(struct ip_addr* ip)
 		return IN_MULTICAST(htonl(ip->u.addr32[0]));
 #ifdef USE_IPV6
 	} else if (ip->af==AF_INET6){
-		return IN6_IS_ADDR_MULTICAST((struct in6_addr *)&ip->u.addr);
+		return IN6_IS_ADDR_MULTICAST(&ip->u.addr32[0]);
 #endif /* USE_IPV6 */
 	} else {
 		LOG(L_ERR, "ERROR: is_mcast: Unsupported protocol family\n");

+ 1 - 1
ip_addr.h

@@ -242,7 +242,7 @@ inline static int ip_addr_loopback(struct ip_addr* ip)
 		return ip->u.addr32[0]==htonl(INADDR_LOOPBACK);
 #ifdef USE_IPV6
 	else if (ip->af==AF_INET6)
-		return IN6_IS_ADDR_LOOPBACK((struct in6_addr *)&ip->u.addr32);
+		return IN6_IS_ADDR_LOOPBACK(&ip->u.addr32[0]);
 #endif /* USE_IPV6 */
 	return 0;
 }

+ 7 - 3
modules/tm/t_cancel.c

@@ -194,6 +194,7 @@ int cancel_branch( struct cell *t, int branch, int flags )
 	struct retr_buf *crb, *irb;
 	int ret;
 	branch_bm_t tmp_bm;
+	void* pcbuf;
 
 	crb=&t->uac[branch].local_cancel;
 	irb=&t->uac[branch].request;
@@ -216,7 +217,8 @@ int cancel_branch( struct cell *t, int branch, int flags )
 			DBG("DEBUG: cancel_branch: no response ever received: "
 			    "giving up on cancel\n");
 			/* remove BUSY_BUFFER -- mark cancel buffer as not used */
-			atomic_set_long((void*)&crb->buffer, 0);
+			pcbuf=&crb->buffer; /* workaround for type punning warnings */
+			atomic_set_long(pcbuf, 0);
 			if (flags & F_CANCEL_B_FAKE_REPLY){
 				LOCK_REPLIES(t);
 				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 )
 				if (!(flags & F_CANCEL_B_FORCE_RETR))
 					stop_rb_retr(irb); /* stop retransmissions */
 				/* remove BUSY_BUFFER -- mark cancel buffer as not used */
-				atomic_set_long((void*)&crb->buffer, 0);
+				pcbuf=&crb->buffer; /* workaround for type punning warnings */
+				atomic_set_long(pcbuf, 0);
 				if (flags & F_CANCEL_B_FAKE_REPLY){
 					stop_rb_timers( irb ); /* stop even the fr timer */
 					LOCK_REPLIES(t);
@@ -262,7 +265,8 @@ int cancel_branch( struct cell *t, int branch, int flags )
 	if (!cancel) {
 		LOG(L_ERR, "ERROR: attempt to build a CANCEL failed\n");
 		/* remove BUSY_BUFFER -- mark cancel buffer as not used */
-		atomic_set_long((void*)&crb->buffer, 0);
+		pcbuf=&crb->buffer; /* workaround for type punning warnings */
+		atomic_set_long(pcbuf, 0);
 		return -1;
 	}
 	/* install cancel now */