Module Name:    src
Committed By:   dholland
Date:           Fri Sep 30 06:16:47 UTC 2016

Modified Files:
        src/lib/libc/gen: sysctlgetmibinfo.c

Log Message:
Be consistent about returning -1 on error. Don't return random errnos
instead.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/sysctlgetmibinfo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/sysctlgetmibinfo.c
diff -u src/lib/libc/gen/sysctlgetmibinfo.c:1.11 src/lib/libc/gen/sysctlgetmibinfo.c:1.12
--- src/lib/libc/gen/sysctlgetmibinfo.c:1.11	Fri May 16 12:22:32 2014
+++ src/lib/libc/gen/sysctlgetmibinfo.c	Fri Sep 30 06:16:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctlgetmibinfo.c,v 1.11 2014/05/16 12:22:32 martin Exp $ */
+/*	$NetBSD: sysctlgetmibinfo.c,v 1.12 2016/09/30 06:16:47 dholland Exp $ */
 
 /*-
  * Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.11 2014/05/16 12:22:32 martin Exp $");
+__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.12 2016/09/30 06:16:47 dholland Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -421,20 +421,27 @@ sysctlgetmibinfo_unlocked(const char *gn
 	if (rnode != NULL) {
 		if (*rnode == NULL) {
 			/* XXX later deal with dealing back a sub version */
-			if (v != SYSCTL_VERSION)
-				return (EINVAL);
+			if (v != SYSCTL_VERSION) {
+				errno = EINVAL;
+				return -1;
+			}
 
 			pnode = &sysctl_mibroot;
 		}
 		else {
 			/* this is just someone being silly */
-			if (SYSCTL_VERS((*rnode)->sysctl_flags) != (uint32_t)v)
-				return (EINVAL);
+			if (SYSCTL_VERS((*rnode)->sysctl_flags)
+			    != (uint32_t)v) {
+				errno = EINVAL;
+				return -1;
+			}
 
 			/* XXX later deal with other people's trees */
 			if (SYSCTL_VERS((*rnode)->sysctl_flags) !=
-			    SYSCTL_VERSION)
-				return (EINVAL);
+			    SYSCTL_VERSION) {
+				errno = EINVAL;
+				return -1;
+			}
 
 			pnode = *rnode;
 		}

Reply via email to