From rsmith@xs4all.nl  Sun May 21 17:58:11 2006
Return-Path: <rsmith@xs4all.nl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 878D216A4D2
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 May 2006 17:58:11 +0000 (UTC)
	(envelope-from rsmith@xs4all.nl)
Received: from smtp-vbr13.xs4all.nl (smtp-vbr13.xs4all.nl [194.109.24.33])
	by mx1.FreeBSD.org (Postfix) with ESMTP id F205943D46
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 May 2006 17:58:10 +0000 (GMT)
	(envelope-from rsmith@xs4all.nl)
Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160])
	by smtp-vbr13.xs4all.nl (8.13.6/8.13.6) with ESMTP id k4LHw99C071651;
	Sun, 21 May 2006 19:58:09 +0200 (CEST)
	(envelope-from rsmith@xs4all.nl)
Received: by slackbox.xs4all.nl (Postfix, from userid 1001)
	id 2981BB863; Sun, 21 May 2006 19:58:09 +0200 (CEST)
Message-Id: <20060521175809.2981BB863@slackbox.xs4all.nl>
Date: Sun, 21 May 2006 19:58:09 +0200 (CEST)
From: Roland Smith <rsmith@xs4all.nl>
Reply-To: Roland Smith <rsmith@xs4all.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Ulrich Spoerlein <uspoerlein@gmail.com>
Subject: compilation of /usr/src/tools/tools/recoverdisk fails on amd64.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         97566
>Category:       amd64
>Synopsis:       compilation of /usr/src/tools/tools/recoverdisk fails on amd64.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    matteo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 21 18:00:47 GMT 2006
>Closed-Date:    Sun Jun 04 10:51:01 GMT 2006
>Last-Modified:  Sun Jun 04 10:51:01 GMT 2006
>Originator:     Roland Smith
>Release:        FreeBSD 6.1-STABLE amd64
>Organization:
>Environment:
System: FreeBSD slackbox.xs4all.nl 6.1-STABLE FreeBSD 6.1-STABLE #0: Tue May 9 22:46:51 CEST 2006 rsmith@slackbox.xs4all.nl:/usr/obj/usr/src/sys/RFS amd64

>Description:

Compilation of the recoverdisk tool fails on amd64:

slackbox# make
cc -O2 -fno-strict-aliasing -pipe  -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 -c recoverdisk.c
recoverdisk.c: In function `main':
recoverdisk.c:231: warning: comparison between signed and unsigned
recoverdisk.c:231: warning: signed and unsigned type in conditional expression
recoverdisk.c:233: warning: comparison between signed and unsigned
recoverdisk.c:233: warning: signed and unsigned type in conditional expression
recoverdisk.c:235: warning: comparison between signed and unsigned
recoverdisk.c:235: warning: signed and unsigned type in conditional expression
recoverdisk.c:237: warning: comparison between signed and unsigned
*** Error code 1

Stop in /usr/src/tools/tools/recoverdisk.

This is due to the -W flag and the difference between size_t and off_t on
amd64 (and possibly other 64-bit platforms). On i386 size_t and off_t
totally overlap, while on amd64 they only partially overlap.

>How-To-Repeat:

cd /usr/src/tools/tools/recoverdisk
make

>Fix:

Apply the following patch, tested on i386 and amd64:

-------- recoverdisk.c patch --------
--- recoverdisk.c.orig	Sun May 21 19:33:38 2006
+++ recoverdisk.c	Sun May 21 19:41:45 2006
@@ -228,13 +228,13 @@
 		if (lp == NULL)
 			break;
 		while (lp->len > 0 && !aborting) {
-			i = MIN(lp->len, bigsize);
+			i = MIN(lp->len, (off_t)bigsize);
 			if (lp->state == 1)
-				i = MIN(lp->len, medsize);
+				i = MIN(lp->len, (off_t)medsize);
 			if (lp->state > 1)
-				i = MIN(lp->len, minsize);
+				i = MIN(lp->len, (off_t)minsize);
 			time(&t2);
-			if (t1 != t2 || lp->len < bigsize) {
+			if (t1 != t2 || lp->len < (off_t)bigsize) {
 				printf("\r%13jd %7zu %13jd %5d %13jd %13jd %.7f",
 				    (intmax_t)lp->start,
 				    i, 

-------- recoverdisk.c patch --------


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->	 matteo 
Responsible-Changed-By: matteo 
Responsible-Changed-When: Tue May 30 15:43:56 UTC 2006 
Responsible-Changed-Why:  
I'll work on this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97566 
State-Changed-From-To: open->patched 
State-Changed-By: matteo 
State-Changed-When: Tue May 30 19:11:49 UTC 2006 
State-Changed-Why:  
Fixed in HEAD. I'll MFC it in 3 days 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97566 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Sun Jun 4 10:50:41 UTC 2006 
State-Changed-Why:  
Merged to RELENG_6. 

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