From nobody@FreeBSD.org  Mon Aug 29 17:36:02 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AE7A4106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Aug 2011 17:36:02 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 93C978FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Aug 2011 17:36:02 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p7THa2JF076514
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Aug 2011 17:36:02 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p7THa2as076513;
	Mon, 29 Aug 2011 17:36:02 GMT
	(envelope-from nobody)
Message-Id: <201108291736.p7THa2as076513@red.freebsd.org>
Date: Mon, 29 Aug 2011 17:36:02 GMT
From: Olivier Cochard-Labbe <olivier@cochard.me>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Patch for compile tools/netrate/[netblast|netsend] on sparc64
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         160289
>Category:       misc
>Synopsis:       [tools] [patch] Patch to compile tools/netrate/[netblast|netsend] on sparc64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    marius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 29 17:40:13 UTC 2011
>Closed-Date:    Mon Sep 05 17:54:34 UTC 2011
>Last-Modified:  Mon Sep 05 17:54:34 UTC 2011
>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:
Responsible-Changed-From-To: freebsd-sparc64->freebsd-bin 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Aug 29 19:12:49 UTC 2011 
Responsible-Changed-Why:  
Reclassify, since it's not in the machine-dependent code. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160289 
Responsible-Changed-From-To: freebsd-bin->marius 
Responsible-Changed-By: marius 
Responsible-Changed-When: Mon Aug 29 19:40:15 UTC 2011 
Responsible-Changed-Why:  
Grab in order to stop the journey of my patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160289 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/160289: commit references a PR
Date: Fri,  2 Sep 2011 16:40:28 +0000 (UTC)

 Author: marius
 Date: Fri Sep  2 16:40:18 2011
 New Revision: 225334
 URL: http://svn.freebsd.org/changeset/base/225334
 
 Log:
   Fix alignment assumptions.
   
   PR:		160289
   Approved by:	re (kib)
   MFC after:	3 days
 
 Modified:
   head/tools/tools/netrate/netblast/netblast.c
   head/tools/tools/netrate/netsend/netsend.c
 
 Modified: head/tools/tools/netrate/netblast/netblast.c
 ==============================================================================
 --- head/tools/tools/netrate/netblast/netblast.c	Fri Sep  2 16:18:06 2011	(r225333)
 +++ head/tools/tools/netrate/netblast/netblast.c	Fri Sep  2 16:40:18 2011	(r225334)
 @@ -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 
  		 * 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)
 
 Modified: head/tools/tools/netrate/netsend/netsend.c
 ==============================================================================
 --- head/tools/tools/netrate/netsend/netsend.c	Fri Sep  2 16:18:06 2011	(r225333)
 +++ head/tools/tools/netrate/netsend/netsend.c	Fri Sep  2 16:40:18 2011	(r225334)
 @@ -26,6 +26,7 @@
   * $FreeBSD$
   */
  
 +#include <sys/endian.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <sys/time.h>
 @@ -203,11 +204,9 @@ timing_loop(struct _a *a)
  		 * skipped.
  		 * The counter is incremented only on the initial port number,
  		 * so all destinations will see the same set of packets.
 -		 *
 -		 * XXXRW: Note alignment assumption.
  		 */
  		if (cur_port == a->port && a->packet_len >= 4) {
 -			*((u_int32_t *)a->packet) = htonl(counter);
 +			be32enc(a->packet, counter);
  			counter++;
  		}
  		if (a->port == a->port_max) { /* socket already bound */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/160289: commit references a PR
Date: Mon,  5 Sep 2011 17:45:32 +0000 (UTC)

 Author: marius
 Date: Mon Sep  5 17:45:22 2011
 New Revision: 225403
 URL: http://svn.freebsd.org/changeset/base/225403
 
 Log:
   MFC: r225334
   
   Fix alignment assumptions.
   
   PR:		160289
 
 Modified:
   stable/8/tools/tools/netrate/netblast/netblast.c
   stable/8/tools/tools/netrate/netsend/netsend.c
 Directory Properties:
   stable/8/tools/tools/netrate/netblast/   (props changed)
   stable/8/tools/tools/netrate/netsend/   (props changed)
 
 Modified: stable/8/tools/tools/netrate/netblast/netblast.c
 ==============================================================================
 --- stable/8/tools/tools/netrate/netblast/netblast.c	Mon Sep  5 15:21:18 2011	(r225402)
 +++ stable/8/tools/tools/netrate/netblast/netblast.c	Mon Sep  5 17:45:22 2011	(r225403)
 @@ -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 
  		 * 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)
 
 Modified: stable/8/tools/tools/netrate/netsend/netsend.c
 ==============================================================================
 --- stable/8/tools/tools/netrate/netsend/netsend.c	Mon Sep  5 15:21:18 2011	(r225402)
 +++ stable/8/tools/tools/netrate/netsend/netsend.c	Mon Sep  5 17:45:22 2011	(r225403)
 @@ -26,6 +26,7 @@
   * $FreeBSD$
   */
  
 +#include <sys/endian.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <sys/time.h>
 @@ -203,11 +204,9 @@ timing_loop(struct _a *a)
  		 * skipped.
  		 * The counter is incremented only on the initial port number,
  		 * so all destinations will see the same set of packets.
 -		 *
 -		 * XXXRW: Note alignment assumption.
  		 */
  		if (cur_port == a->port && a->packet_len >= 4) {
 -			*((u_int32_t *)a->packet) = htonl(counter);
 +			be32enc(a->packet, counter);
  			counter++;
  		}
  		if (a->port == a->port_max) { /* socket already bound */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/160289: commit references a PR
Date: Mon,  5 Sep 2011 17:45:46 +0000 (UTC)

 Author: marius
 Date: Mon Sep  5 17:45:24 2011
 New Revision: 225404
 URL: http://svn.freebsd.org/changeset/base/225404
 
 Log:
   MFC: r225334
   
   Fix alignment assumptions.
   
   PR:		160289
 
 Modified:
   stable/7/tools/tools/netrate/netblast/netblast.c
   stable/7/tools/tools/netrate/netsend/netsend.c
 Directory Properties:
   stable/7/tools/tools/netrate/netblast/   (props changed)
   stable/7/tools/tools/netrate/netsend/   (props changed)
 
 Modified: stable/7/tools/tools/netrate/netblast/netblast.c
 ==============================================================================
 --- stable/7/tools/tools/netrate/netblast/netblast.c	Mon Sep  5 17:45:22 2011	(r225403)
 +++ stable/7/tools/tools/netrate/netblast/netblast.c	Mon Sep  5 17:45:24 2011	(r225404)
 @@ -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 
  		 * 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)
 
 Modified: stable/7/tools/tools/netrate/netsend/netsend.c
 ==============================================================================
 --- stable/7/tools/tools/netrate/netsend/netsend.c	Mon Sep  5 17:45:22 2011	(r225403)
 +++ stable/7/tools/tools/netrate/netsend/netsend.c	Mon Sep  5 17:45:24 2011	(r225404)
 @@ -26,6 +26,7 @@
   * $FreeBSD$
   */
  
 +#include <sys/endian.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <sys/time.h>
 @@ -203,11 +204,9 @@ timing_loop(struct _a *a)
  		 * skipped.
  		 * The counter is incremented only on the initial port number,
  		 * so all destinations will see the same set of packets.
 -		 *
 -		 * XXXRW: Note alignment assumption.
  		 */
  		if (cur_port == a->port && a->packet_len >= 4) {
 -			*((u_int32_t *)a->packet) = htonl(counter);
 +			be32enc(a->packet, counter);
  			counter++;
  		}
  		if (a->port == a->port_max) { /* socket already bound */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: marius 
State-Changed-When: Mon Sep 5 17:54:08 UTC 2011 
State-Changed-Why:  
Close; this PR was handled fully. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160289 
>Unformatted:
