]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
authorFlorian Weimer <fweimer@redhat.com>
Tue, 25 Feb 2020 15:15:09 +0000 (16:15 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 25 Feb 2020 15:15:09 +0000 (16:15 +0100)
This commit removes the minor optimization based on strong aliases
because it loses type safety.

include/libc-symbols.h
include/netdb.h
nis/nss-nis.h
nis/nss_nis/nis-hosts.c
nis/nss_nis/nis-network.c
nis/nss_nis/nis-spwd.c

index 33e2d34c532ed7a46276f67736df621b4a50c009..b0b75a087ee02c9ea3ba347bc70a5a324fb32d96 100644 (file)
@@ -835,6 +835,29 @@ for linking")
 # define libnsl_hidden_data_ver(local, name)
 #endif
 
+#if IS_IN (libnss_nis)
+# define libnss_nis_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
+# define libnss_nis_hidden_tls_proto(name, attrs...) \
+  hidden_tls_proto (name, ##attrs)
+# define libnss_nis_hidden_def(name) hidden_def (name)
+# define libnss_nis_hidden_weak(name) hidden_weak (name)
+# define libnss_nis_hidden_ver(local, name) hidden_ver (local, name)
+# define libnss_nis_hidden_data_def(name) hidden_data_def (name)
+# define libnss_nis_hidden_tls_def(name) hidden_tls_def (name)
+# define libnss_nis_hidden_data_weak(name) hidden_data_weak (name)
+# define libnss_nis_hidden_data_ver(local, name) hidden_data_ver (local, name)
+#else
+# define libnss_nis_hidden_proto(name, attrs...)
+# define libnss_nis_hidden_tls_proto(name, attrs...)
+# define libnss_nis_hidden_def(name)
+# define libnss_nis_hidden_weak(name)
+# define libnss_nis_hidden_ver(local, name)
+# define libnss_nis_hidden_data_def(name)
+# define libnss_nis_hidden_tls_def(name)
+# define libnss_nis_hidden_data_weak(name)
+# define libnss_nis_hidden_data_ver(local, name)
+#endif
+
 #if IS_IN (libnss_nisplus)
 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
 # define libnss_nisplus_hidden_tls_proto(name, attrs...) \
index e230b1f4fc72dc7b8570a3620467f71c6c869fba..3c78da60c56cb4bb9a636086a2061aba7ff69252 100644 (file)
@@ -279,7 +279,8 @@ extern enum nss_status _nss_ ## service ## _getnetbyname_r                \
 extern enum nss_status _nss_ ## service ## _getnetbyaddr_r                   \
                       (uint32_t addr, int type, struct netent *net,          \
                        char *buffer, size_t buflen, int *errnop,             \
-                       int *herrnop);
+                       int *herrnop);                                        \
+extern enum nss_status _nss_ ## service ## _endspent (void);
 
 DECLARE_NSS_PROTOTYPES (compat)
 DECLARE_NSS_PROTOTYPES (dns)
@@ -289,6 +290,11 @@ DECLARE_NSS_PROTOTYPES (nis)
 DECLARE_NSS_PROTOTYPES (nisplus)
 
 #undef DECLARE_NSS_PROTOTYPES
+
+libnss_nis_hidden_proto (_nss_nis_endhostent)
+libnss_nis_hidden_proto (_nss_nis_endnetent)
+libnss_nis_hidden_proto (_nss_nis_endspent)
+
 #endif
 
 #endif /* !_NETDB_H */
index dc091d1a203228b16f3c30d9cfab912db44f5185..7c009d7e8762bf19cbed71286d8e2a5c614bf95b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "nsswitch.h"
 
+NSS_DECLARE_MODULE_FUNCTIONS (nis)
 
 /* Convert YP error number to NSS error number.  */
 extern const enum nss_status __yperr2nss_tab[] attribute_hidden;
index 2d08076382bb24bedc80dd1c59e7e3e60a747d4a..eb074783f71e97b6a1e4801af4ae425bbfd1b548 100644 (file)
 #include <assert.h>
 #include <nss.h>
 #include <ctype.h>
-/* The following is an ugly trick to avoid a prototype declaration for
-   _nss_nis_endgrent.  */
-#define _nss_nis_endhostent _nss_nis_endhostent_XXX
 #include <netdb.h>
-#undef _nss_nis_endhostent
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -90,9 +86,14 @@ static bool_t new_start = 1;
 static char *oldkey = NULL;
 static int oldkeylen = 0;
 
-
 enum nss_status
 _nss_nis_sethostent (int stayopen)
+{
+  return _nss_nis_endhostent ();
+}
+
+enum nss_status
+_nss_nis_endhostent (void)
 {
   __libc_lock_lock (lock);
 
@@ -108,11 +109,7 @@ _nss_nis_sethostent (int stayopen)
 
   return NSS_STATUS_SUCCESS;
 }
-/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent.  We do this
-   even though the prototypes don't match.  The argument of sethostent
-   is used so this makes no difference.  */
-strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
-
+libnss_nis_hidden_def (_nss_nis_endhostent)
 
 /* The calling function always need to get a lock first. */
 static enum nss_status
index dcafd26148dc99a81df159c4ff68b648db145dc3..8d87c69d8e1757088dfeffa8cff3bef18e003613 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <nss.h>
-/* The following is an ugly trick to avoid a prototype declaration for
-   _nss_nis_endgrent.  */
-#define _nss_nis_endnetent _nss_nis_endnetent_XXX
 #include <netdb.h>
-#undef _nss_nis_endnetent
 #include <ctype.h>
 #include <errno.h>
 #include <stdint.h>
@@ -48,7 +44,13 @@ static int oldkeylen;
 enum nss_status
 _nss_nis_setnetent (int stayopen)
 {
-  __libc_lock_lock (lock);
+  return _nss_nis_endnetent ();
+}
+
+enum nss_status
+_nss_nis_endnetent (void)
+{
+__libc_lock_lock (lock);
 
   new_start = 1;
   if (oldkey != NULL)
@@ -62,10 +64,7 @@ _nss_nis_setnetent (int stayopen)
 
   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)
+libnss_nis_hidden_def (_nss_nis_endnetent)
 
 static enum nss_status
 internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
index 6cd46b4022845a67f5ad3a7817361aee92ff090a..9790dd41040db1be8f0d858d8b836886ff8e39e2 100644 (file)
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
-/* The following is an ugly trick to avoid a prototype declaration for
-   _nss_nis_endspent.  */
-#define _nss_nis_endspent _nss_nis_endspent_XXX
 #include <shadow.h>
-#undef _nss_nis_endspent
 #include <libc-lock.h>
 #include <rpcsvc/yp.h>
 #include <rpcsvc/ypclnt.h>
+#include <netdb.h>
 
 #include "nss-nis.h"
 #include <libnsl.h>
@@ -48,6 +45,12 @@ static int oldkeylen;
 
 enum nss_status
 _nss_nis_setspent (int stayopen)
+{
+  return _nss_nis_endspent ();
+}
+
+enum nss_status
+_nss_nis_endspent (void)
 {
   __libc_lock_lock (lock);
 
@@ -61,10 +64,7 @@ _nss_nis_setspent (int stayopen)
 
   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)
+libnss_nis_hidden_def (_nss_nis_endspent)
 
 static enum nss_status
 internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,