From 9d2b0ab82ad1236efa76d644fcc586d6be680fe1 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 11 Sep 2002 18:12:29 +0000 Subject: [PATCH] Modify previous commit to solve the real problem that made gcc think the timestamp was aligned. ie: Use a void * instead of struct timeval * which gcc assumes will be aligned. Go back to memcpy(). Submitted by: bde --- sbin/ping/ping.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 088912239783..3b8db2ae5b2b 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -811,7 +811,7 @@ pr_pack(buf, cc, from, tv) struct icmp *icp; struct ip *ip; struct in_addr ina; - struct timeval *tp; + const void *tp; u_char *cp, *dp; double triptime; int dupflag, hlen, i, j, seq; @@ -839,12 +839,12 @@ pr_pack(buf, cc, from, tv) if (timing) { struct timeval tv1; #ifndef icmp_data - tp = (struct timeval *)&icp->icmp_ip; + tp = &icp->icmp_ip; #else - tp = (struct timeval *)icp->icmp_data; + tp = icp->icmp_data; #endif - /* Avoid unaligned data (cannot use memcpy) */ - bcopy(tp, &tv1, sizeof(tv1)); + /* Copy to avoid alignment problems: */ + memcpy(&tv1, tp, sizeof(tv1)); tvsub(tv, &tv1); triptime = ((double)tv->tv_sec) * 1000.0 + ((double)tv->tv_usec) / 1000.0;