--------------------- PatchSet 11862 Date: 2008/01/02 17:06:50 Author: hno Branch: SQUID_2_6 Tag: (none) Log: MFC: Minor cleanups to make some 64-bit platforms happier - Bug #2106: use size_t for internal cbdata offset calculation - Bug #2107: Unaligned memory access in pinger - Make GCC happier on certain 64-bit platforms Members: src/cbdata.c:1.46->1.46.2.1 src/pinger.c:1.50->1.50.2.1 src/tools.c:1.250.2.3->1.250.2.4 Index: squid/src/cbdata.c =================================================================== RCS file: /cvsroot/squid/squid/src/cbdata.c,v retrieving revision 1.46 retrieving revision 1.46.2.1 diff -u -r1.46 -r1.46.2.1 --- squid/src/cbdata.c 12 May 2006 22:04:59 -0000 1.46 +++ squid/src/cbdata.c 2 Jan 2008 17:06:50 -0000 1.46.2.1 @@ -1,6 +1,6 @@ /* - * $Id: cbdata.c,v 1.46 2006/05/12 22:04:59 hno Exp $ + * $Id: cbdata.c,v 1.46.2.1 2008/01/02 17:06:50 hno Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -122,7 +122,7 @@ } #else -#define OFFSET_OF(type, member) ((int)(char *)&((type *)0L)->member) +#define OFFSET_OF(type, member) ((size_t)(char *)&((type *)0L)->member) #endif void Index: squid/src/pinger.c =================================================================== RCS file: /cvsroot/squid/squid/src/pinger.c,v retrieving revision 1.50 retrieving revision 1.50.2.1 diff -u -r1.50 -r1.50.2.1 --- squid/src/pinger.c 22 May 2006 19:20:30 -0000 1.50 +++ squid/src/pinger.c 2 Jan 2008 17:06:50 -0000 1.50.2.1 @@ -1,6 +1,6 @@ /* - * $Id: pinger.c,v 1.50 2006/05/22 19:20:30 serassio Exp $ + * $Id: pinger.c,v 1.50.2.1 2008/01/02 17:06:50 hno Exp $ * * DEBUG: section 42 ICMP Pinger program * AUTHOR: Duane Wessels @@ -307,7 +307,7 @@ icmp->icmp_seq = (u_short) icmp_pkts_sent++; echo = (icmpEchoData *) (icmp + 1); echo->opcode = (unsigned char) opcode; - echo->tv = current_time; + memcpy(&echo->tv, ¤t_time, sizeof(current_time)); icmp_pktsize += sizeof(struct timeval) + sizeof(char); if (payload) { if (len > MAX_PAYLOAD) @@ -345,6 +345,7 @@ struct timeval now; icmpEchoData *echo; static pingerReplyData preply; + struct timeval tv; if (pkt == NULL) pkt = xmalloc(MAX_PKT_SZ); @@ -380,7 +381,8 @@ preply.from = from.sin_addr; preply.opcode = echo->opcode; preply.hops = ipHops(ip->ip_ttl); - preply.rtt = tvSubMsec(echo->tv, now); + memcpy(&tv, &echo->tv, sizeof(tv)); + preply.rtt = tvSubMsec(tv, now); preply.psize = n - iphdrlen - (sizeof(icmpEchoData) - MAX_PKT_SZ); pingerSendtoSquid(&preply); pingerLog(icmp, from.sin_addr, preply.rtt, preply.hops); Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid/squid/src/tools.c,v retrieving revision 1.250.2.3 retrieving revision 1.250.2.4 diff -u -r1.250.2.3 -r1.250.2.4 --- squid/src/tools.c 1 Sep 2007 20:09:50 -0000 1.250.2.3 +++ squid/src/tools.c 2 Jan 2008 17:06:50 -0000 1.250.2.4 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.250.2.3 2007/09/01 20:09:50 hno Exp $ + * $Id: tools.c,v 1.250.2.4 2008/01/02 17:06:50 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -976,7 +976,7 @@ * 2 until it becomes positive again. */ kb_t x; - x.kb = 1 << 31; + x.kb = 1L << 31; while (x.kb && ((k->kb + x.kb) < 0)) { x.kb <<= 1; } @@ -1295,7 +1295,7 @@ void setUmask(mode_t mask) { - static mode_t orig_umask = ~0; + static mode_t orig_umask = (mode_t) ~ 0; if (orig_umask == (mode_t) ~ 0) { /* Unfortunately, there is no way to get the current * umask value without setting it.