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
Responsible Changed From-To: freebsd-sparc64->freebsd-bin Reclassify, since it's not in the machine-dependent code.
Responsible Changed From-To: freebsd-bin->marius Grab in order to stop the journey of my patch.
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"
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"
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 Close; this PR was handled fully.