From owner-freebsd-net@FreeBSD.ORG Tue Feb 26 04:18:18 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 D3E7916A408 for ; Tue, 26 Feb 2008 04:18:18 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 29B9513C478 for ; Tue, 26 Feb 2008 04:18:17 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl92-189.kln.forthnet.gr [77.49.59.189]) (authenticated bits=0) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id m1Q44dQU016718; Tue, 26 Feb 2008 06:04:45 +0200 Received: by kobe.laptop (Postfix, from userid 1000) id 90D5522802; Tue, 26 Feb 2008 06:04:38 +0200 (EET) Date: Tue, 26 Feb 2008 06:04:38 +0200 From: Giorgos Keramidas To: ithilgore Message-ID: <20080226040438.GA2676@kobe.laptop> References: <47BFF17B.5080205@gmail.com> <47BFF74E.4010608@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47BFF74E.4010608@gmail.com> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.925, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.47, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-net@freebsd.org 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: Tue, 26 Feb 2008 04:18:18 -0000 On 2008-02-23 02:37, ithilgore wrote: >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 ? I don't see ucp[] in RELENG_6, RELENG_7 or CURRENT. Where did you get the version shown as `7.0-RC1' above?