Date: Mon, 29 Aug 2011 00:26:58 +0200 From: Marius Strobl <marius@alchemy.franken.de> To: Olivier Cochard-Labb? <olivier@cochard.me> Cc: freebsd-sparc64@freebsd.org Subject: Re: Can't compile tools/netrate/[netblast|netsend] Message-ID: <20110828222658.GA9698@alchemy.franken.de> In-Reply-To: <CA%2Bq%2BTcpSPfGi42H8B-KkPDYeVyh-r-j7kKqmDYX3gxhfvWxWtg@mail.gmail.com> References: <CA%2Bq%2BTcpSPfGi42H8B-KkPDYeVyh-r-j7kKqmDYX3gxhfvWxWtg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Aug 28, 2011 at 09:28:37PM +0200, Olivier Cochard-Labb? wrote: > Hi all, > > 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 > > As I'm not a C coder, and googling about alignment, I've learn that > only x86 platform "hide" this problem, but I didn't find dummy patch > for fix this kind of problem. > Does anyone have a solution ? > Index: netblast.c =================================================================== --- netblast.c (revision 223862) +++ netblast.c (working copy) @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include <sys/endian.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> @@ -108,11 +109,9 @@ blast_loop(int s, long duration, u_char *packet, u * 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110828222658.GA9698>