diff options
Diffstat (limited to 'lib/libc/net/getprotoent.c')
-rw-r--r-- | lib/libc/net/getprotoent.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c index dda5d18..ccd5e12 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 |