From owner-freebsd-stable@FreeBSD.ORG Sun Feb 1 13:14:31 2015 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DA12FB29 for ; Sun, 1 Feb 2015 13:14:31 +0000 (UTC) Received: from hades.sorbs.net (hades.sorbs.net [67.231.146.201]) by mx1.freebsd.org (Postfix) with ESMTP id C67E631B for ; Sun, 1 Feb 2015 13:14:31 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from isux.com (firewall.isux.com [213.165.190.213]) by hades.sorbs.net (Oracle Communications Messaging Server 7.0.5.29.0 64bit (built Jul 9 2013)) with ESMTPSA id <0NJ3005G9H03MM00@hades.sorbs.net> for freebsd-stable@freebsd.org; Sun, 01 Feb 2015 05:19:17 -0800 (PST) Message-id: <54CE26AE.10005@sorbs.net> Date: Sun, 01 Feb 2015 14:14:22 +0100 From: Michelle Sullivan User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.24) Gecko/20100301 SeaMonkey/1.1.19 To: Paul Koch Subject: Re: top, fixed buffer length in utils.c References: <20150201175159.7fa88d16@B85M-HD3-0.alogt.com> <20150201195722.68845794@akips.com> In-reply-to: <20150201195722.68845794@akips.com> Cc: freebsd-stable@freebsd.org 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 13:14:31 -0000 Paul Koch wrote: > 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. > IIRC reading at least one of the C 'standards' (don't recall if it was ANSI or C99) sizeof(int) has to be determined at runtime time because it could be 8, or 16 bit and that wasn't dependent on the arch type, it was dependent on the compiler (and maybe other factors.) Unfortunately when I queried this with a Uni Prof as to why, I was told, mostly its 16 bits but you should always check if you have something that cares (where it matters.) -- Michelle Sullivan http://www.mhix.org/