From mjl@luckie.org.nz  Sun May 18 02:30:14 2008
Return-Path: <mjl@luckie.org.nz>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BDD69106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 18 May 2008 02:30:14 +0000 (UTC)
	(envelope-from mjl@luckie.org.nz)
Received: from mailfilter9.ihug.co.nz (mailfilter9.ihug.co.nz [203.109.136.9])
	by mx1.freebsd.org (Postfix) with ESMTP id 68BA98FC0A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 18 May 2008 02:30:14 +0000 (UTC)
	(envelope-from mjl@luckie.org.nz)
Received: from 203-109-186-4.dsl.dyn.ihug.co.nz (HELO spandex.luckie.org.nz) ([203.109.186.4])
  by smtp.mailfilter1.ihug.co.nz with ESMTP/TLS/DHE-RSA-AES256-SHA; 18 May 2008 14:30:11 +1200
Received: from rayon.luckie.org.nz ([192.168.1.25])
	by spandex.luckie.org.nz with esmtps (TLSv1:AES256-SHA:256)
	(Exim 4.69 (FreeBSD))
	(envelope-from <mjl@luckie.org.nz>)
	id 1JxYf5-000HD6-Ak
	for FreeBSD-gnats-submit@freebsd.org; Sun, 18 May 2008 14:30:11 +1200
Received: from mjl by rayon.luckie.org.nz with local (Exim 4.69 (FreeBSD))
	(envelope-from <mjl@luckie.org.nz>)
	id 1JxYf7-0001QM-NP
	for FreeBSD-gnats-submit@freebsd.org; Sun, 18 May 2008 14:30:13 +1200
Message-Id: <E1JxYf7-0001QM-NP@rayon.luckie.org.nz>
Date: Sun, 18 May 2008 14:30:13 +1200
From: Matthew Luckie <mjl@luckie.org.nz>
Sender: Matthew Luckie <mjl@luckie.org.nz>
Reply-To: Matthew Luckie <mjl@luckie.org.nz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] kdump time_t printing issues
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         123774
>Category:       bin
>Synopsis:       [patch] kdump(1): time_t printing issues
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 18 02:40:03 UTC 2008
>Closed-Date:    Wed Mar 24 17:10:34 UTC 2010
>Last-Modified:  Wed Mar 24 17:10:34 UTC 2010
>Originator:     Matthew Luckie
>Release:        FreeBSD 7.0-RELEASE-p1 arm
>Organization:
>Environment:
System: FreeBSD vinyl.luckie.org.nz 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #4: Sun May 18 08:49:48 NZST 2008     root@rayon.luckie.org.nz:/usr/obj/arm/usr/src/sys/vinyl  arm

>Description:
On systems with 64-bit time_t values, such as arm, kdump -T prints the
following:

   988 ktrace   0.1211060384 RET   ktrace 0

where you would otherwise expect to see

   988 ktrace   1211060384.667338 RET   ktrace 0

>How-To-Repeat:
ktrace / kdump on a system with a 64-bit time_t
>Fix:

There is no non-kludge solution that I am aware of.

http://lists.freebsd.org/pipermail/freebsd-ports/2006-January/028656.html

--- patch-kdump.c begins here ---
--- kdump.c.orig	2008-01-12 13:07:50.000000000 +1300
+++ kdump.c	2008-05-18 14:14:30.000000000 +1200
@@ -290,8 +290,9 @@
 			timevalsub(&kth->ktr_time, &prevtime);
 			prevtime = temp;
 		}
-		(void)printf("%ld.%06ld ",
-		    kth->ktr_time.tv_sec, kth->ktr_time.tv_usec);
+		(void)printf("%lld.%06ld ",
+		    (long long int)kth->ktr_time.tv_sec,
+		    kth->ktr_time.tv_usec);
 	}
 	(void)printf("%s  ", type);
 }
--- patch-kdump.c ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Sat Jan 30 09:06:15 UTC 2010 
Responsible-Changed-Why:  
Take. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/123774: commit references a PR
Date: Sat,  6 Feb 2010 16:01:47 +0000 (UTC)

 Author: jh
 Date: Sat Feb  6 16:01:38 2010
 New Revision: 203551
 URL: http://svn.freebsd.org/changeset/base/203551
 
 Log:
   - Cast intptr_t, pid_t and time_t values to intmax_t and use %jd with
     printf.
   - Cast the system call return value to long and use %ld in a printf in
     ktrsysret().
   
   PR:		bin/123774
   MFC after:	2 weeks
 
 Modified:
   head/usr.bin/kdump/kdump.c
 
 Modified: head/usr.bin/kdump/kdump.c
 ==============================================================================
 --- head/usr.bin/kdump/kdump.c	Sat Feb  6 15:32:42 2010	(r203550)
 +++ head/usr.bin/kdump/kdump.c	Sat Feb  6 16:01:38 2010	(r203551)
 @@ -182,14 +182,16 @@ main(int argc, char *argv[])
  		if (ktr_header.ktr_type & KTR_DROP) {
  			ktr_header.ktr_type &= ~KTR_DROP;
  			if (!drop_logged && threads) {
 -				(void)printf("%6d %6d %-8.*s Events dropped.\n",
 -				    ktr_header.ktr_pid, ktr_header.ktr_tid >
 -				    0 ? ktr_header.ktr_tid : 0, MAXCOMLEN,
 -				    ktr_header.ktr_comm);
 +				(void)printf(
 +				    "%6jd %6jd %-8.*s Events dropped.\n",
 +				    (intmax_t)ktr_header.ktr_pid,
 +				    ktr_header.ktr_tid > 0 ?
 +				    (intmax_t)ktr_header.ktr_tid : 0,
 +				    MAXCOMLEN, ktr_header.ktr_comm);
  				drop_logged = 1;
  			} else if (!drop_logged) {
 -				(void)printf("%6d %-8.*s Events dropped.\n",
 -				    ktr_header.ktr_pid, MAXCOMLEN,
 +				(void)printf("%6jd %-8.*s Events dropped.\n",
 +				    (intmax_t)ktr_header.ktr_pid, MAXCOMLEN,
  				    ktr_header.ktr_comm);
  				drop_logged = 1;
  			}
 @@ -309,10 +311,11 @@ dumpheader(struct ktr_header *kth)
  	 * negative tid's as 0.
  	 */
  	if (threads)
 -		(void)printf("%6d %6d %-8.*s ", kth->ktr_pid, kth->ktr_tid >
 -		    0 ? kth->ktr_tid : 0, MAXCOMLEN, kth->ktr_comm);
 +		(void)printf("%6jd %6jd %-8.*s ", (intmax_t)kth->ktr_pid,
 +		    kth->ktr_tid > 0 ? (intmax_t)kth->ktr_tid : 0,
 +		    MAXCOMLEN, kth->ktr_comm);
  	else
 -		(void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN,
 +		(void)printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN,
  		    kth->ktr_comm);
  	if (timestamp) {
  		if (timestamp == 3) {
 @@ -325,8 +328,8 @@ dumpheader(struct ktr_header *kth)
  			timevalsub(&kth->ktr_time, &prevtime);
  			prevtime = temp;
  		}
 -		(void)printf("%ld.%06ld ",
 -		    kth->ktr_time.tv_sec, kth->ktr_time.tv_usec);
 +		(void)printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec,
 +		    kth->ktr_time.tv_usec);
  	}
  	(void)printf("%s  ", type);
  }
 @@ -821,7 +824,7 @@ ktrsysret(struct ktr_sysret *ktr)
  
  	if (error == 0) {
  		if (fancy) {
 -			(void)printf("%d", ret);
 +			(void)printf("%ld", (long)ret);
  			if (ret < 0 || ret > 9)
  				(void)printf("/%#lx", (long)ret);
  		} else {
 @@ -1267,7 +1270,7 @@ ktrstat(struct stat *statp)
  	printf("rdev=%ju, ", (uintmax_t)statp->st_rdev);
  	printf("atime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_atimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_atimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_atimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1279,7 +1282,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("stime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_mtimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_mtimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_mtimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1291,7 +1294,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("ctime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_ctimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_ctimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_ctimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1303,7 +1306,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("birthtime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_birthtimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_birthtimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_birthtimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 _______________________________________________
 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->patched 
State-Changed-By: jh 
State-Changed-When: Sat Feb 6 16:17:38 UTC 2010 
State-Changed-Why:  
Patched in head (r203551). 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/123774: commit references a PR
Date: Sun, 21 Feb 2010 13:17:45 +0000 (UTC)

 Author: jh
 Date: Sun Feb 21 13:17:35 2010
 New Revision: 204169
 URL: http://svn.freebsd.org/changeset/base/204169
 
 Log:
   MFC r203551:
   
   - Cast intptr_t, pid_t and time_t values to intmax_t and use %jd with
     printf.
   - Cast the system call return value to long and use %ld in a printf in
     ktrsysret().
   
   PR:		bin/123774
 
 Modified:
   stable/8/usr.bin/kdump/kdump.c
 Directory Properties:
   stable/8/usr.bin/kdump/   (props changed)
 
 Modified: stable/8/usr.bin/kdump/kdump.c
 ==============================================================================
 --- stable/8/usr.bin/kdump/kdump.c	Sun Feb 21 11:22:01 2010	(r204168)
 +++ stable/8/usr.bin/kdump/kdump.c	Sun Feb 21 13:17:35 2010	(r204169)
 @@ -182,14 +182,16 @@ main(int argc, char *argv[])
  		if (ktr_header.ktr_type & KTR_DROP) {
  			ktr_header.ktr_type &= ~KTR_DROP;
  			if (!drop_logged && threads) {
 -				(void)printf("%6d %6d %-8.*s Events dropped.\n",
 -				    ktr_header.ktr_pid, ktr_header.ktr_tid >
 -				    0 ? ktr_header.ktr_tid : 0, MAXCOMLEN,
 -				    ktr_header.ktr_comm);
 +				(void)printf(
 +				    "%6jd %6jd %-8.*s Events dropped.\n",
 +				    (intmax_t)ktr_header.ktr_pid,
 +				    ktr_header.ktr_tid > 0 ?
 +				    (intmax_t)ktr_header.ktr_tid : 0,
 +				    MAXCOMLEN, ktr_header.ktr_comm);
  				drop_logged = 1;
  			} else if (!drop_logged) {
 -				(void)printf("%6d %-8.*s Events dropped.\n",
 -				    ktr_header.ktr_pid, MAXCOMLEN,
 +				(void)printf("%6jd %-8.*s Events dropped.\n",
 +				    (intmax_t)ktr_header.ktr_pid, MAXCOMLEN,
  				    ktr_header.ktr_comm);
  				drop_logged = 1;
  			}
 @@ -309,10 +311,11 @@ dumpheader(struct ktr_header *kth)
  	 * negative tid's as 0.
  	 */
  	if (threads)
 -		(void)printf("%6d %6d %-8.*s ", kth->ktr_pid, kth->ktr_tid >
 -		    0 ? kth->ktr_tid : 0, MAXCOMLEN, kth->ktr_comm);
 +		(void)printf("%6jd %6jd %-8.*s ", (intmax_t)kth->ktr_pid,
 +		    kth->ktr_tid > 0 ? (intmax_t)kth->ktr_tid : 0,
 +		    MAXCOMLEN, kth->ktr_comm);
  	else
 -		(void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN,
 +		(void)printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN,
  		    kth->ktr_comm);
  	if (timestamp) {
  		if (timestamp == 3) {
 @@ -325,8 +328,8 @@ dumpheader(struct ktr_header *kth)
  			timevalsub(&kth->ktr_time, &prevtime);
  			prevtime = temp;
  		}
 -		(void)printf("%ld.%06ld ",
 -		    kth->ktr_time.tv_sec, kth->ktr_time.tv_usec);
 +		(void)printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec,
 +		    kth->ktr_time.tv_usec);
  	}
  	(void)printf("%s  ", type);
  }
 @@ -821,7 +824,7 @@ ktrsysret(struct ktr_sysret *ktr)
  
  	if (error == 0) {
  		if (fancy) {
 -			(void)printf("%d", ret);
 +			(void)printf("%ld", (long)ret);
  			if (ret < 0 || ret > 9)
  				(void)printf("/%#lx", (long)ret);
  		} else {
 @@ -1270,7 +1273,7 @@ ktrstat(struct stat *statp)
  	printf("rdev=%ju, ", (uintmax_t)statp->st_rdev);
  	printf("atime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_atimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_atimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_atimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1282,7 +1285,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("stime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_mtimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_mtimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_mtimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1294,7 +1297,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("ctime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_ctimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_ctimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_ctimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1306,7 +1309,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("birthtime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_birthtimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_birthtimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_birthtimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 _______________________________________________
 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: bin/123774: commit references a PR
Date: Wed, 24 Mar 2010 16:47:26 +0000 (UTC)

 Author: jh
 Date: Wed Mar 24 16:47:12 2010
 New Revision: 205608
 URL: http://svn.freebsd.org/changeset/base/205608
 
 Log:
   MFC r203551:
   
   - Cast intptr_t, pid_t and time_t values to intmax_t and use %jd with
     printf.
   - Cast the system call return value to long and use %ld in a printf in
     ktrsysret().
   
   PR:		bin/123774
 
 Modified:
   stable/7/usr.bin/kdump/kdump.c
 Directory Properties:
   stable/7/usr.bin/kdump/   (props changed)
 
 Modified: stable/7/usr.bin/kdump/kdump.c
 ==============================================================================
 --- stable/7/usr.bin/kdump/kdump.c	Wed Mar 24 16:07:33 2010	(r205607)
 +++ stable/7/usr.bin/kdump/kdump.c	Wed Mar 24 16:47:12 2010	(r205608)
 @@ -179,14 +179,16 @@ main(int argc, char *argv[])
  		if (ktr_header.ktr_type & KTR_DROP) {
  			ktr_header.ktr_type &= ~KTR_DROP;
  			if (!drop_logged && threads) {
 -				(void)printf("%6d %6d %-8.*s Events dropped.\n",
 -				    ktr_header.ktr_pid, ktr_header.ktr_tid >
 -				    0 ? ktr_header.ktr_tid : 0, MAXCOMLEN,
 -				    ktr_header.ktr_comm);
 +				(void)printf(
 +				    "%6jd %6jd %-8.*s Events dropped.\n",
 +				    (intmax_t)ktr_header.ktr_pid,
 +				    ktr_header.ktr_tid > 0 ?
 +				    (intmax_t)ktr_header.ktr_tid : 0,
 +				    MAXCOMLEN, ktr_header.ktr_comm);
  				drop_logged = 1;
  			} else if (!drop_logged) {
 -				(void)printf("%6d %-8.*s Events dropped.\n",
 -				    ktr_header.ktr_pid, MAXCOMLEN,
 +				(void)printf("%6jd %-8.*s Events dropped.\n",
 +				    (intmax_t)ktr_header.ktr_pid, MAXCOMLEN,
  				    ktr_header.ktr_comm);
  				drop_logged = 1;
  			}
 @@ -306,10 +308,11 @@ dumpheader(struct ktr_header *kth)
  	 * negative tid's as 0.
  	 */
  	if (threads)
 -		(void)printf("%6d %6d %-8.*s ", kth->ktr_pid, kth->ktr_tid >
 -		    0 ? kth->ktr_tid : 0, MAXCOMLEN, kth->ktr_comm);
 +		(void)printf("%6jd %6jd %-8.*s ", (intmax_t)kth->ktr_pid,
 +		    kth->ktr_tid > 0 ? (intmax_t)kth->ktr_tid : 0,
 +		    MAXCOMLEN, kth->ktr_comm);
  	else
 -		(void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN,
 +		(void)printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN,
  		    kth->ktr_comm);
  	if (timestamp) {
  		if (timestamp == 3) {
 @@ -322,8 +325,8 @@ dumpheader(struct ktr_header *kth)
  			timevalsub(&kth->ktr_time, &prevtime);
  			prevtime = temp;
  		}
 -		(void)printf("%ld.%06ld ",
 -		    kth->ktr_time.tv_sec, kth->ktr_time.tv_usec);
 +		(void)printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec,
 +		    kth->ktr_time.tv_usec);
  	}
  	(void)printf("%s  ", type);
  }
 @@ -824,7 +827,7 @@ ktrsysret(struct ktr_sysret *ktr)
  
  	if (error == 0) {
  		if (fancy) {
 -			(void)printf("%d", ret);
 +			(void)printf("%ld", (long)ret);
  			if (ret < 0 || ret > 9)
  				(void)printf("/%#lx", (long)ret);
  		} else {
 @@ -1273,7 +1276,7 @@ ktrstat(struct stat *statp)
  	printf("rdev=%ju, ", (uintmax_t)statp->st_rdev);
  	printf("atime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_atimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_atimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_atimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1285,7 +1288,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("stime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_mtimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_mtimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_mtimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1297,7 +1300,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("ctime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_ctimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_ctimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_ctimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 @@ -1309,7 +1312,7 @@ ktrstat(struct stat *statp)
  		printf(", ");
  	printf("birthtime=");
  	if (resolv == 0)
 -		printf("%ld", statp->st_birthtimespec.tv_sec);
 +		printf("%jd", (intmax_t)statp->st_birthtimespec.tv_sec);
  	else {
  		tm = localtime(&statp->st_birthtimespec.tv_sec);
  		(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
 _______________________________________________
 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: patched->closed 
State-Changed-By: jh 
State-Changed-When: Wed Mar 24 17:10:33 UTC 2010 
State-Changed-Why:  
Fixed in stable/7, stable/8 and head. Thanks! 

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