From b677d6742888747613ebb4dbe4bbb4dbe6e07087 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 19 Jan 2003 19:22:02 +0000 Subject: Update. 2003-01-19 Ulrich Drepper * nis/nss_nis/nis-spwd.c: Make _nss_nis_endspent an alias of _nss_nis_setspent. Work around the different prototypes. * nis/nss_nis/nis-rpc.c (internal_nis_setrpcent): Use internal_nis_endrpcent. (internal_nis_endrpcent): Change return type to void. Change callers. * nis/nss_nis/nis-pwd.c: Make _nss_nis_endpwent an alias of _nss_nis_setpwent. Work around the different prototypes. * nis/nss_nis/nis-proto.c (_nss_nis_endprotoent): Split out body of the function to... (internal_nis_endprotoent): ... here. New function. (internal_nis_setprotoent): Use internal_nis_endprotoent. * nis/nss_nis/nis-network.c: Make _nss_nis_endnetent an alias of _nss_nis_setnetent. Work around the different prototypes. * nis/nss_nis/nis-netgrp.c (_nss_nis_endnetgrent): Split out body of the function to... (internal_nis_endnetgrent): ... here. New function. (_nss_nis_setnetgrent): Use internal_nis_endnetgrent. --- nis/nss_nis/nis-grp.c | 2 +- nis/nss_nis/nis-netgrp.c | 31 ++++++++++++++++--------------- nis/nss_nis/nis-network.c | 28 +++++++++------------------- nis/nss_nis/nis-proto.c | 35 ++++++++++++++++------------------- nis/nss_nis/nis-pwd.c | 28 +++++++++------------------- nis/nss_nis/nis-rpc.c | 47 +++++++++++++++++------------------------------ nis/nss_nis/nis-spwd.c | 37 ++++++++++++------------------------- 7 files changed, 80 insertions(+), 128 deletions(-) (limited to 'nis') diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index e000e6a825..c090a77266 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -64,7 +64,7 @@ _nss_nis_setgrent (int stayopen) } /* Make _nss_nis_endgrent an alias of _nss_nis_setgrent. We do this even though the prototypes don't match. The argument of setgrent - is used so this makes no difference. */ + is not used so this makes no difference. */ strong_alias (_nss_nis_setgrent, _nss_nis_endgrent) static enum nss_status diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index c9b52428c3..e9318d6e95 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996,1997,1999,2000,2002,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -42,6 +42,19 @@ extern enum nss_status _nss_netgroup_parseline (char **cursor, struct __netgrent *result, char *buffer, size_t buflen, int *errnop); + +static void +internal_nis_endnetgrent (void) +{ + if (data != NULL) + { + free (data); + data = NULL; + data_size = 0; + cursor = NULL; + } +} + enum nss_status _nss_nis_setnetgrent (const char *group, struct __netgrent *dummy) { @@ -60,13 +73,7 @@ _nss_nis_setnetgrent (const char *group, struct __netgrent *dummy) __libc_lock_lock (lock); - if (data != NULL) - { - free (data); - data = NULL; - data_size = 0; - cursor = NULL; - } + internal_nis_endnetgrent (); group_len = strlen (group); @@ -96,13 +103,7 @@ _nss_nis_endnetgrent (struct __netgrent *dummy) { __libc_lock_lock (lock); - if (data != NULL) - { - free (data); - data = NULL; - data_size = 0; - cursor = NULL; - } + internal_nis_endnetgrent (); __libc_lock_unlock (lock); diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c index 0e40b6f26c..2292aea2c0 100644 --- a/nis/nss_nis/nis-network.c +++ b/nis/nss_nis/nis-network.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2000, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -18,7 +18,11 @@ 02111-1307 USA. */ #include +/* The following is an ugly trick to avoid a prototype declaration for + _nss_nis_endgrent. */ +#define _nss_nis_endnetent _nss_nis_endnetent_XXX #include +#undef _nss_nis_endnetent #include #include #include @@ -59,24 +63,10 @@ _nss_nis_setnetent (int stayopen) return NSS_STATUS_SUCCESS; } - -enum nss_status -_nss_nis_endnetent (void) -{ - __libc_lock_lock (lock); - - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} +/* Make _nss_nis_endnetent an alias of _nss_nis_setnetent. We do this + even though the prototypes don't match. The argument of setnetent + is not used so this makes no difference. */ +strong_alias (_nss_nis_setnetent, _nss_nis_endnetent) static enum nss_status internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c index 00e86dfa6b..b8c234ed6f 100644 --- a/nis/nss_nis/nis-proto.c +++ b/nis/nss_nis/nis-proto.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,1997,1998,2000,2001,2002 Free Software Foundation, Inc. +/* Copyright (C) 1996-1998, 2000-2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -78,15 +78,9 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, return 0; } -static enum nss_status -internal_nis_setprotoent (void) +static void +internal_nis_endprotoent (void) { - char *domainname; - struct ypall_callback ypcb; - enum nss_status status; - - yp_get_default_domain (&domainname); - while (start != NULL) { if (start->val != NULL) @@ -95,7 +89,18 @@ internal_nis_setprotoent (void) start = start->next; free (next); } - start = NULL; +} + +static enum nss_status +internal_nis_setprotoent (void) +{ + char *domainname; + struct ypall_callback ypcb; + enum nss_status status; + + yp_get_default_domain (&domainname); + + internal_nis_endprotoent (); ypcb.foreach = saveit; ypcb.data = NULL; @@ -124,15 +129,7 @@ _nss_nis_endprotoent (void) { __libc_lock_lock (lock); - while (start != NULL) - { - if (start->val != NULL) - free (start->val); - next = start; - start = start->next; - free (next); - } - start = NULL; + internal_nis_endprotoent (); next = NULL; __libc_lock_unlock (lock); diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c index da5ffabff1..0f56ced014 100644 --- a/nis/nss_nis/nis-pwd.c +++ b/nis/nss_nis/nis-pwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996-1998, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -18,7 +18,11 @@ 02111-1307 USA. */ #include +/* The following is an ugly trick to avoid a prototype declaration for + _nss_nis_endpwent. */ +#define _nss_nis_endpwent _nss_nis_endpwent_XXX #include +#undef _nss_nis_endpwent #include #include #include @@ -58,24 +62,10 @@ _nss_nis_setpwent (int stayopen) return NSS_STATUS_SUCCESS; } - -enum nss_status -_nss_nis_endpwent (void) -{ - __libc_lock_lock (lock); - - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} +/* Make _nss_nis_endpwent an alias of _nss_nis_setpwent. We do this + even though the prototypes don't match. The argument of setpwent + is not used so this makes no difference. */ +strong_alias (_nss_nis_setpwent, _nss_nis_endpwent) static enum nss_status internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c index 1f9e5b4600..6e707b9d58 100644 --- a/nis/nss_nis/nis-rpc.c +++ b/nis/nss_nis/nis-rpc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996-1998, 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -86,6 +86,19 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, return 0; } +static void +internal_nis_endrpcent (intern_t *intern) +{ + while (intern->start != NULL) + { + if (intern->start->val != NULL) + free (intern->start->val); + intern->next = intern->start; + intern->start = intern->start->next; + free (intern->next); + } +} + static enum nss_status internal_nis_setrpcent (intern_t *intern) { @@ -96,15 +109,7 @@ internal_nis_setrpcent (intern_t *intern) if (yp_get_default_domain (&domainname)) return NSS_STATUS_UNAVAIL; - while (intern->start != NULL) - { - if (intern->start->val != NULL) - free (intern->start->val); - intern->next = intern->start; - intern->start = intern->start->next; - free (intern->next); - } - intern->start = NULL; + internal_nis_endrpcent (intern); ypcb.foreach = saveit; ypcb.data = (char *)intern; @@ -128,34 +133,16 @@ _nss_nis_setrpcent (int stayopen) return status; } -static enum nss_status -internal_nis_endrpcent (intern_t *intern) -{ - while (intern->start != NULL) - { - if (intern->start->val != NULL) - free (intern->start->val); - intern->next = intern->start; - intern->start = intern->start->next; - free (intern->next); - } - intern->start = NULL; - - return NSS_STATUS_SUCCESS; -} - enum nss_status _nss_nis_endrpcent (void) { - enum nss_status status; - __libc_lock_lock (lock); - status = internal_nis_endrpcent (&intern); + internal_nis_endrpcent (&intern); __libc_lock_unlock (lock); - return status; + return NSS_STATUS_SUCCESS; } static enum nss_status diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c index c06e95457e..99a9ed5f48 100644 --- a/nis/nss_nis/nis-spwd.c +++ b/nis/nss_nis/nis-spwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996-1998, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -21,7 +21,11 @@ #include #include #include +/* The following is an ugly trick to avoid a prototype declaration for + _nss_nis_endspent. */ +#define _nss_nis_endspent _nss_nis_endspent_XXX #include +#undef _nss_nis_endspent #include #include #include @@ -47,35 +51,18 @@ _nss_nis_setspent (int stayopen) __libc_lock_lock (lock); new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_endspent (void) -{ - __libc_lock_lock (lock); - - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } + free (oldkey); + oldkey = NULL; + oldkeylen = 0; __libc_lock_unlock (lock); return NSS_STATUS_SUCCESS; } +/* Make _nss_nis_endspent an alias of _nss_nis_setspent. We do this + even though the prototypes don't match. The argument of setspent + is not used so this makes no difference. */ +strong_alias (_nss_nis_setspent, _nss_nis_endspent) static enum nss_status internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen, -- cgit v1.2.3