From owner-freebsd-stable@FreeBSD.ORG Sun Feb 1 09:57:53 2015 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1D4E3C78 for ; Sun, 1 Feb 2015 09:57:53 +0000 (UTC) Received: from mail.akips.com (mail.akips.com [65.19.130.19]) by mx1.freebsd.org (Postfix) with ESMTP id 090B9EED for ; Sun, 1 Feb 2015 09:57:52 +0000 (UTC) Received: from akips.com (CPE-120-146-191-2.static.qld.bigpond.net.au [120.146.191.2]) by mail.akips.com (Postfix) with ESMTPSA id 2785427DBC for ; Sun, 1 Feb 2015 19:57:43 +1000 (EST) Date: Sun, 1 Feb 2015 19:57:22 +1000 From: Paul Koch To: freebsd-stable@freebsd.org Subject: Re: top, fixed buffer length in utils.c Message-ID: <20150201195722.68845794@akips.com> In-Reply-To: <20150201175159.7fa88d16@B85M-HD3-0.alogt.com> References: <20150201175159.7fa88d16@B85M-HD3-0.alogt.com> Organization: AKIPS X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.22; amd64-portbld-freebsd10.1) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on host1.akips.com X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Feb 2015 09:57:53 -0000 On Sun, 1 Feb 2015 17:51:59 +0800 Erich Dollansky wrote: > Hi, > > I came across this here in utils.c which is part of top: > > > /* > * How do we know that 16 will suffice? > * Because the biggest number that we > will > * ever convert will be 2^32-1, which > is 10 > * digits. > */ > > char *itoa(val) > > register int val; > > int can be 64 bits on a amd64 machine. Why is the author of this code > so sure that we will never cross the 32 bit boundary? > > Erich I thought an 'int' was a 32bit number on amd64 arch. #include #include int main (void) { printf ("%zd\n", sizeof (int)); exit (0); } Paul. -- Paul Koch | Founder, CEO AKIPS Network Monitor http://www.akips.com