Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/lib/libc/gen Pull up revision 1.57 (requested by lukem in...



details:   https://anonhg.NetBSD.org/src/rev/dac3aadaf0ae
branches:  netbsd-3
changeset: 576580:dac3aadaf0ae
user:      tron <tron%NetBSD.org@localhost>
date:      Mon Jul 11 21:25:27 2005 +0000

description:
Pull up revision 1.57 (requested by lukem in ticket #540):
getgrent():
Return the correct result. (broken in rev 1.56 -- Hi Christos!)
getgr{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).
Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.
Per discussion with Klaus Klein.

diffstat:

 lib/libc/gen/getgrent.c |  44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 deletions(-)

diffs (128 lines):

diff -r 3fab2096a8b7 -r dac3aadaf0ae lib/libc/gen/getgrent.c
--- a/lib/libc/gen/getgrent.c   Mon Jul 11 21:24:36 2005 +0000
+++ b/lib/libc/gen/getgrent.c   Mon Jul 11 21:25:27 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getgrent.c,v 1.54.2.2 2005/07/11 21:22:33 tron Exp $   */
+/*     $NetBSD: getgrent.c,v 1.54.2.3 2005/07/11 21:25:27 tron Exp $   */
 
 /*-
  * Copyright (c) 1999-2000, 2004-2005 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
 #if 0
 static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: getgrent.c,v 1.54.2.2 2005/07/11 21:22:33 tron Exp $");
+__RCSID("$NetBSD: getgrent.c,v 1.54.2.3 2005/07/11 21:25:27 tron Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -336,7 +336,8 @@
  *     If search is zero, return the next entry.
  *     If search is non-zero, look for a specific name (if name != NULL),
  *     or a specific gid (if name == NULL).
- *     Sets *retval to the errno if the result is not NS_SUCCESS.
+ *     Sets *retval to the errno if the result is not NS_SUCCESS
+ *     or NS_NOTFOUND.
  */
 int
 __grscan_files(int *retval, struct group *grp, char *buffer, size_t buflen,
@@ -395,7 +396,7 @@
        }
 
  filesgrscan_out:
-       if (rv != NS_SUCCESS)
+       if (rv != NS_SUCCESS && rv != NS_NOTFOUND)
                *retval = errno;
        return rv;
 }
@@ -711,7 +712,7 @@
                rv = NS_UNAVAIL;
 
  dnsgrscan_out:
-       if (rv != NS_SUCCESS)
+       if (rv != NS_SUCCESS && rv != NS_NOTFOUND)
                *retval = errno;
        if (hp)
                hesiod_free_list(state->context, hp);
@@ -1051,7 +1052,7 @@
                        rv = NS_UNAVAIL;
        }
 
-       if (rv != NS_SUCCESS)
+       if (rv != NS_SUCCESS && rv != NS_NOTFOUND)
                *retval = errno;
        if (key)
                free(key);
@@ -1315,7 +1316,8 @@
  *     If search is zero, return the next entry.
  *     If search is non-zero, look for a specific name (if name != NULL),
  *     or a specific gid (if name == NULL).
- *     Sets *retval to the errno if the result is not NS_SUCCESS.
+ *     Sets *retval to the errno if the result is not NS_SUCCESS or
+ *     NS_NOTFOUND.
  *
  *     searchfunc is invoked when a compat "+" lookup is required;
  *     searchcookie is passed as the first argument to searchfunc,
@@ -1479,7 +1481,7 @@
        }
 
  compatgrscan_out:
-       if (rv != NS_SUCCESS)
+       if (rv != NS_SUCCESS && rv != NS_NOTFOUND)
                *retval = errno;
        return rv;
 }
@@ -1736,7 +1738,7 @@
        rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent", __nsdefaultcompat,
            &retval);
        mutex_unlock(&__grmutex);
-       return (rv == NS_SUCCESS) ? 0 : retval;
+       return (rv == NS_SUCCESS) ? retval : NULL;
 }
 
 int
@@ -1757,7 +1759,13 @@
        rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent_r", __nsdefaultcompat,
            &retval, grp, buffer, buflen, result);
        mutex_unlock(&__grmutex);
-       return (rv == NS_SUCCESS) ? 0 : retval;
+       switch (rv) {
+       case NS_SUCCESS:
+       case NS_NOTFOUND:
+               return 0;
+       default:
+               return retval;
+       }
 }
 
 
@@ -1806,7 +1814,13 @@
        rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", __nsdefaultcompat,
            &retval, gid, grp, buffer, buflen, result);
        mutex_unlock(&__grmutex);
-       return (rv == NS_SUCCESS) ? 0 : retval ? retval : ENOENT;
+       switch (rv) {
+       case NS_SUCCESS:
+       case NS_NOTFOUND:
+               return 0;
+       default:
+               return retval;
+       }
 }
 
 struct group *
@@ -1855,7 +1869,13 @@
        rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam_r", __nsdefaultcompat,
            &retval, name, grp, buffer, buflen, result);
        mutex_unlock(&__grmutex);
-       return (rv == NS_SUCCESS) ? 0 : retval ? retval : ENOENT;
+       switch (rv) {
+       case NS_SUCCESS:
+       case NS_NOTFOUND:
+               return 0;
+       default:
+               return retval;
+       }
 }
 
 void



Home | Main Index | Thread Index | Old Index