Can't compile tools/netrate/[netblast|netsend]

Marius Strobl marius at alchemy.franken.de
Sun Aug 28 22:27:02 UTC 2011


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 at 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)


More information about the freebsd-sparc64 mailing list