From owner-freebsd-net@FreeBSD.ORG Sat Feb 23 00:41:04 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D461F16A40F for ; Sat, 23 Feb 2008 00:41:04 +0000 (UTC) (envelope-from ithilgore.fbsd@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by mx1.freebsd.org (Postfix) with ESMTP id 68D0313C461 for ; Sat, 23 Feb 2008 00:41:03 +0000 (UTC) (envelope-from ithilgore.fbsd@gmail.com) Received: by fg-out-1718.google.com with SMTP id 16so452538fgg.35 for ; Fri, 22 Feb 2008 16:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=HTsvMszYtZG451YXzWYf+mtIARope6MYcLs782PTpJk=; b=N7F0S7K4fU4MTKMnxa3PczbVuFVO6BGFITEU1ytC3DoRFI/QpW7YroPQZkQZ/zLMEzn/GCD20uIJZ0aouW7vDHNWpZ/AesB/8g0aQFLSn2IcD4QLSOJliYhjvw0mBuo2jfRkrKeWRIFmvFDlsKfaL3kKH8tvGEt9fiv41jbWYUA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=RZnXSa0NJZk9KkoH0S9mLtz5w1bBp+k9kUjUECEn5FqMhEOtpKGHtWDivk06TAoHhKakf3J0UKZvJS+rmYtkdBDDjXloZh95M9EEjurFhssWWB0XxSPOcyN8xcm13F8aMRvvSrCzUfmwquhek1SzeQe5fybPjWbaUMSMKdN1eTw= Received: by 10.86.72.15 with SMTP id u15mr649584fga.21.1203727262764; Fri, 22 Feb 2008 16:41:02 -0800 (PST) Received: from ?10.0.0.12? ( [62.1.229.152]) by mx.google.com with ESMTPS id 4sm1987837fge.3.2008.02.22.16.41.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 22 Feb 2008 16:41:01 -0800 (PST) Message-ID: <47BFF74E.4010608@gmail.com> Date: Sat, 23 Feb 2008 02:37:02 -0800 From: ithilgore User-Agent: Thunderbird 2.0.0.9 (X11/20071212) MIME-Version: 1.0 To: freebsd-net@freebsd.org References: <47BFF17B.5080205@gmail.com> In-Reply-To: <47BFF17B.5080205@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: question about change in inet_ntoa.c X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Feb 2008 00:41:04 -0000 ithilgore wrote: > > I was looking at the differences between some old FreeBSD code > and the one of 7.0-RC1 and was wondering about a change > in inet_ntoa.c > > /***** 7.0-RC1 **************/ > > sprintf(buf, "%d.%d.%d.%d", > ucp[0] & 0xff, > ucp[1] & 0xff, > ucp[2] & 0xff, > ucp[3] & 0xff); > > > /****** 4.11-RELEASE ***********/ > > > static const char fmt[] = "%u.%u.%u%u"; > if ((size_t)snprintf(dst, size, fmt, src[0], src[1], src[2], src[3]) > >= size) { > .... > .... > > Was there a specific purpose of changing the more easy and simple way > of %u instead of the combination of %d and and-ing with 0xff ?? > It essentially gives the same result but increases overhead (i think) > in the more > recent version. > > I just noticed I made a mistake. The second code is libc's version of inet_ntoa. But the question still counts. Why not use the plain simpler version of libc ?