Date: Sat, 23 Feb 2008 02:37:02 -0800 From: ithilgore <ithilgore.fbsd@gmail.com> To: freebsd-net@freebsd.org Subject: Re: question about change in inet_ntoa.c Message-ID: <47BFF74E.4010608@gmail.com> In-Reply-To: <47BFF17B.5080205@gmail.com> References: <47BFF17B.5080205@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 ?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47BFF74E.4010608>