summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getprotoname.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/net/getprotoname.c')
-rw-r--r--lib/libc/net/getprotoname.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/libc/net/getprotoname.c b/lib/libc/net/getprotoname.c
index bead63a..08822c1 100644
--- a/lib/libc/net/getprotoname.c
+++ b/lib/libc/net/getprotoname.c
@@ -33,6 +33,7 @@ static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <netdb.h>
#include <nsswitch.h>
#include <string.h>
@@ -75,7 +76,7 @@ files_getprotobyname(void *retval, void *mdata, va_list ap)
if ((ped = __protoent_data_init()) == NULL) {
- *errnop = -1;
+ *errnop = errno;
return (NS_NOTFOUND);
}
@@ -91,12 +92,12 @@ found:
if (!ped->stayopen)
__endprotoent_p(ped);
if (error != 0) {
- *errnop = -1;
+ *errnop = errno;
return (NS_NOTFOUND);
}
if (__copy_protoent(&pe, pptr, buffer, buflen) != 0) {
- *errnop = -1;
- return (NS_NOTFOUND);
+ *errnop = errno;
+ return (NS_RETURN);
}
*((struct protoent **)retval) = pptr;
@@ -128,10 +129,11 @@ getprotobyname_r(const char *name, struct protoent *pptr, char *buffer,
rv = nsdispatch(result, dtab, NSDB_PROTOCOLS, "getprotobyname_r",
defaultsrc, name, 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);
}
struct protoent *
OpenPOWER on IntegriCloud