Date: Mon, 29 Aug 2011 17:36:02 GMT From: Olivier Cochard-Labbe <olivier@cochard.me> To: freebsd-gnats-submit@FreeBSD.org Subject: sparc64/160289: Patch for compile tools/netrate/[netblast|netsend] on sparc64 Message-ID: <201108291736.p7THa2as076513@red.freebsd.org> Resent-Message-ID: <201108291740.p7THeDhA054052@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 160289 >Category: sparc64 >Synopsis: Patch for compile tools/netrate/[netblast|netsend] on sparc64 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-sparc64 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Aug 29 17:40:13 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Olivier Cochard-Labbe >Release: 8.2-RELEASE >Organization: >Environment: FreeBSD sparc64.bsdrp.net 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Sun Mar 6 17:26:52 CET 2011 root@sparc64.bsdrp.net:/usr/obj/usr/src/sys/GENERIC sparc64 >Description: I'm trying to compile netblast on my Sun Blade 150, but I can't because there is alignement error in the code: [root@sparc64]/usr/src/tools/tools/netrate/netblast#make Warning: Object directory not changed from original /usr/src/tools/tools/netrate/netblast cc -O2 -pipe -std=gnu99 -fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wno-pointer-sign -Wformat=2 -Wno-format-extra-args -Werror -c netblast.c cc1: warnings being treated as errors netblast.c: In function 'blast_loop': netblast.c:115: warning: cast increases required alignment of target type *** Error code 1 Stop in /usr/src/tools/tools/netrate/netblast >How-To-Repeat: On a sparc64 machine: /usr/src/tools/tools/netrate/netblast;make or: /usr/src/tools/tools/netrate/netsend;make >Fix: With the help of Marius Strobl (marius@alchemy.franken.de) from the freebsd-sparc64 mailing-list, here is the patch for fixing theses problems. Patch attached with submission follows: diff -ruN netrate.orig/netblast/netblast.c netrate/netblast/netblast.c --- netrate.orig/netblast/netblast.c 2011-08-29 19:20:21.000000000 +0200 +++ netrate/netblast/netblast.c 2011-08-29 19:19:38.000000000 +0200 @@ -26,6 +26,7 @@ * $FreeBSD: src/tools/tools/netrate/netblast/netblast.c,v 1.3.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $ */ +#include <sys/endian.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> @@ -108,11 +109,9 @@ * previous send, the error will turn up the current send * operation, causing the current sequence number also to be * skipped. - * - * XXXRW: Note alignment assumption. */ if (packet_len >= 4) { - *((u_int32_t *)packet) = htonl(counter); + be32enc(packet, counter); counter++; } if (send(s, packet, packet_len, 0) < 0) diff -ruN netrate.orig/netsend/netsend.c netrate/netsend/netsend.c --- netrate.orig/netsend/netsend.c 2011-08-29 19:20:21.000000000 +0200 +++ netrate/netsend/netsend.c 2011-08-29 19:22:16.000000000 +0200 @@ -26,6 +26,7 @@ * $FreeBSD: src/tools/tools/netrate/netsend/netsend.c,v 1.9.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $ */ +#include <sys/endian.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> @@ -164,11 +165,9 @@ * previous send, the error will turn up the current send * operation, causing the current sequence number also to be * skipped. - * - * XXXRW: Note alignment assumption. */ if (packet_len >= 4) { - *((u_int32_t *)packet) = htonl(counter); + be32enc(packet, counter); counter++; } if (send(s, packet, packet_len, 0) < 0) >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108291736.p7THa2as076513>