From nobody@FreeBSD.org  Thu May 23 14:33:26 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id C5B4EED
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 23 May 2013 14:33:26 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.FreeBSD.org (oldred.freebsd.org [8.8.178.121])
	by mx1.freebsd.org (Postfix) with ESMTP id 9E5917A3
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 23 May 2013 14:33:26 +0000 (UTC)
Received: from oldred.FreeBSD.org ([127.0.1.6])
	by oldred.FreeBSD.org (8.14.5/8.14.5) with ESMTP id r4NEXP4D046079
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 23 May 2013 14:33:25 GMT
	(envelope-from nobody@oldred.FreeBSD.org)
Received: (from nobody@localhost)
	by oldred.FreeBSD.org (8.14.5/8.14.5/Submit) id r4NEXPcO046025;
	Thu, 23 May 2013 14:33:25 GMT
	(envelope-from nobody)
Message-Id: <201305231433.r4NEXPcO046025@oldred.FreeBSD.org>
Date: Thu, 23 May 2013 14:33:25 GMT
From: Olivier Cochard-Labbe <olivier@cochard.me>
To: freebsd-gnats-submit@FreeBSD.org
Subject: patch tha fix cross-compilation (amd64/i386) of netrate/netreceive
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         178862
>Category:       misc
>Synopsis:       [tools] [patch] fix cross-compilation (amd64/i386) of netrate/netreceive
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 23 14:40:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Thu May 23 19:00:58 UTC 2013
>Originator:     Olivier Cochard-Labbe
>Release:        -current
>Organization:
>Environment:
FreeBSD labtop.orange.bsdrp.net 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r250926M: Thu May 23 14:29:46 CEST 2013     root@labtop.orange.bsdrp.net:/usr/obj/usr/src/sys/LAPTOP  amd64

>Description:
Trying to compile src/tools/tools/netrate/netrceive on amd64 -current works great for compiling amd64 version. But when I tried to compile with target_arch=i386, I've got "netreceive.c:166:42: error: format specifies type 'long' but the argument has type 'time_t' (aka 'int') [-Werror,-Wformat]" here:

fprintf(stderr, "start at %ld.%09ld\n", then.tv_sec, then.tv_nsec);

With the help of cognet@, here is a patch.


>How-To-Repeat:
From a -current amd64, start this compilation:

env TARGET=i386 TARGET_ARCH=i386 MACHINE=i386 OSVERSION=901000 UNAME_r=9.1-RELEASE-p1 UNAME_v=9.1-RELEASE-p1 UNAME_p=i386 UNAME_m=i386 make -C /usr/src/tools/tools/netrate/netreceive

>Fix:
Applying the patch

Patch attached with submission follows:

--- tools/tools/netrate/netreceive/netreceive.c.orig	2013-05-23 12:00:42.735844141 +0200
+++ tools/tools/netrate/netreceive/netreceive.c	2013-05-23 15:16:31.582033409 +0200
@@ -163,7 +163,7 @@
 	/* now the parent collects and prints results */
 	c0 = c1 = bc0 = bc1 = 0;
 	clock_gettime(CLOCK_REALTIME, &then);
-	fprintf(stderr, "start at %ld.%09ld\n", then.tv_sec, then.tv_nsec);
+	fprintf(stderr, "start at %jd.%09ld\n", (__intmax_t)then.tv_sec, then.tv_nsec);
 	while (1) {
 		int i, nt = nsock * nthreads;
 		int64_t dn;
@@ -185,8 +185,8 @@
 		pps = (pps * 1000000000) / (delta.tv_sec*1000000000 + delta.tv_nsec + 1);
 		bps = ((bc0 - bc1) * 8000000000) / (delta.tv_sec*1000000000 + delta.tv_nsec + 1);
 		fprintf(stderr, " %9ld pps %8.3f Mbps", (long)pps, .000001*bps);
-		fprintf(stderr, " - %d pkts in %ld.%09ld ns\n",
-			(int)dn, delta.tv_sec, delta.tv_nsec);
+		fprintf(stderr, " - %d pkts in %jd.%09ld ns\n",
+			(int)dn, (__intmax_t)delta.tv_sec, delta.tv_nsec);
 		c1 = c0;
 		bc1 = bc0;
 	}


>Release-Note:
>Audit-Trail:
>Unformatted:
