Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Sep 2006 20:10:25 GMT
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/103682: nfsstat(1) should use %u instead of %d to display NFS stats
Message-ID:  <200609262010.k8QKAPYg085561@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

The following reply was made to PR bin/103682; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: Hiroki Sato <hrs@freebsd.org>
Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Subject: Re: bin/103682: nfsstat(1) should use %u instead of %d to display
 NFS stats
Date: Wed, 27 Sep 2006 06:04:19 +1000 (EST)

 On Wed, 27 Sep 2006, Hiroki Sato wrote:
 
 >> Description:
 > 	Although nfsstat(1) uses %d in printf() to display the NFS stats,
 > 	on a busy NFS server/client the stat numbers can become more than
 > 	2147483647 (2^31 - 1, 32-bit int case) and negative numbers are
 > 	printed.  The numbers should be interpreted as unsigned int, and
 > 	displayed by using %u instead.
 
 I prefer to keep using %d.  One extra bit only keeps things working for
 twice as long (either in uptime or code lifetime).  Overflow to negative
 values normally gives obvious garbage, but overflow to bits that aren't
 there gives garbage.
 
 >> How-To-Repeat:
 > 	Use nfsstat(1) on a busy NFS server/client.
 >> Fix:
 > 	A patch is attached.  Also, I think it is better to change members
 > 	in struct nfsstats/nfsrvstats from int to uint64_t or so if possible.
 
 The counters really are ints, so overflow at 2^31 - 1 technically gives
 undefined behaviour.
 
 The code lifetime for these counters as ints expired many years ago.
 They should be changed to int64_t's to avoid sign extension bugs.
 
 Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609262010.k8QKAPYg085561>