Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Oct 2010 00:30:02 +0900
From:      Hajimu UMEMOTO <ume@freebsd.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r211276 - head/lib/libc/net
Message-ID:  <yge62xivuv9.wl%ume@mahoroba.org>
In-Reply-To: <20101003184925.GA87647@deviant.kiev.zoral.com.ua>
References:  <201008130639.o7D6dsk1022779@svn.freebsd.org> <20101003184925.GA87647@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

>>>>> On Sun, 3 Oct 2010 21:49:26 +0300
>>>>> Kostik Belousov <kostikbel@gmail.com> said:

kostikbel> I suspect there is some subtle issue with the commit present.
kostikbel> When getprotobyname_r() is unable to find the protocol, it seems
kostikbel> that established behaviour is to return 0 and set *protoent to NULL.

The behavior you mentioned is questionable to me.  Though I cannot
find the manpage of getprotobyname_r(3), there is following
description in the manpage of gethostbyname_r(3) on CentOS:

	Glibc2 also has reentrant versions gethostbyname_r() and
	gethostbyname2_r().  These return 0 on success and non-zero on
	error.

When getprotobyname_r(3) is unable to find the protocol, it should be
treated as error, IMHO.  My intention is that when getprotobyname_r(3)
ends up with error but errno is zero, the return code should be
non-zero (-1).

kostikbel> The getprotobyname_r() in HEAD and stable/8, when the protocol
kostikbel> cannot be found, return whatever value was present in errno at the time
kostikbel> of the call.

In anyway, errno should be cleared.  I've just committed to clear
errno for each method dispatch.

kostikbel> When run with the argument "tcp1" on Linux, I get
kostikbel> 	Res 0 errno 0 Success pres (nil)
kostikbel> On the recent FreeBSD I get
kostikbel> 	Res 25 errno 25 Inappropriate ioctl for device pres 0x0
kostikbel> (ENOTTY is from stdio).

Now, it shows:

	Res -1 errno 22 Unknown error: 0 pres 0x0

(When strerror(3) is called with 0 for its argument, it set errno to
EINVAL.)

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?yge62xivuv9.wl%ume>