summaryrefslogtreecommitdiff
path: root/lib/libc/net/getprotoent.c
diff options
context:
space:
mode:
authorHajimu UMEMOTO <ume@FreeBSD.org>2010-08-13 06:39:54 +0000
committerHajimu UMEMOTO <ume@FreeBSD.org>2010-08-13 06:39:54 +0000
commit225edeac51a6c52047ce47cd3121a3adcf83434c (patch)
tree7a80afb7fd5c19cd871455a023feca5a38817d97 /lib/libc/net/getprotoent.c
parent34d9d01f86e3070f77d65657e3879e4728835b62 (diff)
Notes
Diffstat (limited to 'lib/libc/net/getprotoent.c')
-rw-r--r--lib/libc/net/getprotoent.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c
index dda5d1895800b..ccd5e12164895 100644
--- a/lib/libc/net/getprotoent.c
+++ b/lib/libc/net/getprotoent.c
@@ -424,8 +424,10 @@ files_getprotoent_r(void *retval, void *mdata, va_list ap)
buflen = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
- if ((ped = __protoent_data_init()) == NULL)
- return (-1);
+ if ((ped = __protoent_data_init()) == NULL) {
+ *errnop = errno;
+ return (NS_NOTFOUND);
+ }
if (__getprotoent_p(&pe, ped) != 0) {
*errnop = errno;
@@ -434,7 +436,7 @@ files_getprotoent_r(void *retval, void *mdata, va_list ap)
if (__copy_protoent(&pe, pptr, buffer, buflen) != 0) {
*errnop = errno;
- return (NS_NOTFOUND);
+ return (NS_RETURN);
}
*((struct protoent **)retval) = pptr;
@@ -490,10 +492,11 @@ getprotoent_r(struct protoent *pptr, char *buffer, size_t buflen,
rv = nsdispatch(result, dtab, NSDB_PROTOCOLS, "getprotoent_r",
defaultsrc, pptr, buffer, buflen, &ret_errno);
- if (rv == NS_SUCCESS)
- return (0);
- else
- return (ret_errno);
+ if (rv != NS_SUCCESS) {
+ errno = ret_errno;
+ return ((ret_errno != 0) ? ret_errno : -1);
+ }
+ return (0);
}
void