Module Name: src
Committed By: martin
Date: Wed Jan 5 14:08:12 UTC 2011
Modified Files:
src/tests/net/icmp: t_ping.c
Log Message:
Fix alignment of sndbuf (sparc64 got a SIGBUS in this test)
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/net/icmp/t_ping.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/net/icmp/t_ping.c
diff -u src/tests/net/icmp/t_ping.c:1.11 src/tests/net/icmp/t_ping.c:1.12
--- src/tests/net/icmp/t_ping.c:1.11 Sun Nov 7 17:51:21 2010
+++ src/tests/net/icmp/t_ping.c Wed Jan 5 14:08:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ping.c,v 1.11 2010/11/07 17:51:21 jmmv Exp $ */
+/* $NetBSD: t_ping.c,v 1.12 2011/01/05 14:08:12 martin Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: t_ping.c,v 1.11 2010/11/07 17:51:21 jmmv Exp $");
+__RCSID("$NetBSD: t_ping.c,v 1.12 2011/01/05 14:08:12 martin Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -129,7 +129,10 @@
static int
doping(const char *target, int loops, u_int pktsize)
{
- char sndbuf[IP_MAXPACKET - sizeof(struct ip)];
+ union {
+ char buf[IP_MAXPACKET - sizeof(struct ip)];
+ struct icmp i; /* ensure proper alignment */
+ } sndbuf;
char recvbuf[IP_MAXPACKET];
struct sockaddr_in dst, pingee;
struct icmp *icmp;
@@ -147,7 +150,7 @@
dst.sin_family = AF_INET;
dst.sin_addr.s_addr = inet_addr(target);
- icmp = (struct icmp *)sndbuf;
+ icmp = (struct icmp *)&sndbuf;
memset(icmp, 0, sizeof(*icmp));
icmp->icmp_type = ICMP_ECHO;
icmp->icmp_id = htons(37);