Bug 160289 - [tools] [patch] Patch to compile tools/netrate/[netblast|netsend] on sparc64
Summary: [tools] [patch] Patch to compile tools/netrate/[netblast|netsend] on sparc64
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 8.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Marius Strobl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-29 18:40 UTC by olivier
Modified: 2011-09-05 18:54 UTC (History)
0 users

See Also:


Attachments
file.diff (1.59 KB, patch)
2011-08-29 18:40 UTC, olivier
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description olivier 2011-08-29 18:40:13 UTC
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

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:
How-To-Repeat: On a sparc64 machine:
/usr/src/tools/tools/netrate/netblast;make
or:
/usr/src/tools/tools/netrate/netsend;make
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-08-29 20:12:49 UTC
Responsible Changed
From-To: freebsd-sparc64->freebsd-bin

Reclassify, since it's not in the machine-dependent code.
Comment 2 Marius Strobl freebsd_committer freebsd_triage 2011-08-29 20:40:15 UTC
Responsible Changed
From-To: freebsd-bin->marius

Grab in order to stop the journey of my patch.
Comment 3 dfilter service freebsd_committer freebsd_triage 2011-09-02 17:40:28 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"
Comment 4 dfilter service freebsd_committer freebsd_triage 2011-09-05 18:45:32 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"
Comment 5 dfilter service freebsd_committer freebsd_triage 2011-09-05 18:45:46 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"
Comment 6 Marius Strobl freebsd_committer freebsd_triage 2011-09-05 18:54:08 UTC
State Changed
From-To: open->closed

Close; this PR was handled fully.