From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 26 20:10:25 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB00A16A40F for ; Tue, 26 Sep 2006 20:10:25 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E5AA43D45 for ; Tue, 26 Sep 2006 20:10:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k8QKAPjN085562 for ; Tue, 26 Sep 2006 20:10:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k8QKAPYg085561; Tue, 26 Sep 2006 20:10:25 GMT (envelope-from gnats) Date: Tue, 26 Sep 2006 20:10:25 GMT Message-Id: <200609262010.k8QKAPYg085561@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Bruce Evans Cc: Subject: Re: bin/103682: nfsstat(1) should use %u instead of %d to display NFS stats X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Bruce Evans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Sep 2006 20:10:26 -0000 The following reply was made to PR bin/103682; it has been noted by GNATS. From: Bruce Evans To: Hiroki Sato 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