diff mbox series

[9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS

Message ID 875zgadfo5.fsf@oldenburg2.str.redhat.com
State New
Headers show
Series More type safety for NSS modules | expand

Commit Message

Florian Weimer Feb. 13, 2020, 9:01 a.m. UTC
This commit removes the minor optimization based on strong aliases
because it loses type safety.

-----
 nis/nss-nis.h             |  1 +
 nis/nss_nis/nis-hosts.c   | 13 ++++++++-----
 nis/nss_nis/nis-network.c | 15 ++++++++++-----
 nis/nss_nis/nis-spwd.c    | 13 +++++++++----
 4 files changed, 28 insertions(+), 14 deletions(-)

Comments

Andreas Schwab Feb. 13, 2020, 9:16 a.m. UTC | #1
On Feb 13 2020, Florian Weimer wrote:

> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
> index 2d08076382..1ee5444cfc 100644
> --- a/nis/nss_nis/nis-hosts.c
> +++ b/nis/nss_nis/nis-hosts.c
> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>  static char *oldkey = NULL;
>  static int oldkeylen = 0;
>  
> +hidden_proto (_nss_nis_endhostent)
>  
>  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 +115,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)
> -
> +hidden_def (_nss_nis_endhostent)

Please also remove the #define/#undef above.

> diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
> index dcafd26148..511de00bd3 100644
> --- a/nis/nss_nis/nis-network.c
> +++ b/nis/nss_nis/nis-network.c
> @@ -45,10 +45,18 @@ static bool_t new_start = 1;
>  static char *oldkey;
>  static int oldkeylen;
>  
> +hidden_proto (_nss_nis_endnetent)
> +
>  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 +70,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)
> +hidden_def (_nss_nis_endnetent)

Likewise.

> diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
> index 6cd46b4022..660447b544 100644
> --- a/nis/nss_nis/nis-spwd.c
> +++ b/nis/nss_nis/nis-spwd.c
> @@ -46,8 +46,16 @@ static bool ent_adjunct_used;
>  static char *oldkey;
>  static int oldkeylen;
>  
> +hidden_proto (_nss_nis_endspent)
> +
>  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 +69,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)
> +hidden_def (_nss_nis_endspent)

Likewise.

Andreas.
Andreas Schwab Feb. 13, 2020, 9:21 a.m. UTC | #2
On Feb 13 2020, Florian Weimer wrote:

> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
> index 2d08076382..1ee5444cfc 100644
> --- a/nis/nss_nis/nis-hosts.c
> +++ b/nis/nss_nis/nis-hosts.c
> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>  static char *oldkey = NULL;
>  static int oldkeylen = 0;
>  
> +hidden_proto (_nss_nis_endhostent)

The hidden_proto should be in the header.

Andreas.
Florian Weimer Feb. 13, 2020, 9:31 a.m. UTC | #3
* Andreas Schwab:

> On Feb 13 2020, Florian Weimer wrote:
>
>> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
>> index 2d08076382..1ee5444cfc 100644
>> --- a/nis/nss_nis/nis-hosts.c
>> +++ b/nis/nss_nis/nis-hosts.c
>> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>>  static char *oldkey = NULL;
>>  static int oldkeylen = 0;
>>  
>> +hidden_proto (_nss_nis_endhostent)
>
> The hidden_proto should be in the header.

Which header?  nss_nis.h?

We don't have libnss_nis_hidden_proto yet.  Should I define that, too?

Thanks,
Florian
Andreas Schwab Feb. 13, 2020, 9:38 a.m. UTC | #4
On Feb 13 2020, Florian Weimer wrote:

> * Andreas Schwab:
>
>> On Feb 13 2020, Florian Weimer wrote:
>>
>>> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
>>> index 2d08076382..1ee5444cfc 100644
>>> --- a/nis/nss_nis/nis-hosts.c
>>> +++ b/nis/nss_nis/nis-hosts.c
>>> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>>>  static char *oldkey = NULL;
>>>  static int oldkeylen = 0;
>>>  
>>> +hidden_proto (_nss_nis_endhostent)
>>
>> The hidden_proto should be in the header.
>
> Which header?  nss_nis.h?

netdb.h, after the prototype.

Andreas.
Florian Weimer Feb. 25, 2020, 2:50 p.m. UTC | #5
* Andreas Schwab:

> On Feb 13 2020, Florian Weimer wrote:
>
>> * Andreas Schwab:
>>
>>> On Feb 13 2020, Florian Weimer wrote:
>>>
>>>> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
>>>> index 2d08076382..1ee5444cfc 100644
>>>> --- a/nis/nss_nis/nis-hosts.c
>>>> +++ b/nis/nss_nis/nis-hosts.c
>>>> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>>>>  static char *oldkey = NULL;
>>>>  static int oldkeylen = 0;
>>>>  
>>>> +hidden_proto (_nss_nis_endhostent)
>>>
>>> The hidden_proto should be in the header.
>>
>> Which header?  nss_nis.h?
>
> netdb.h, after the prototype.

Do you mean like this?

Changing DECLARE_NSS_PROTOTYPES would require updating all NSS modules
to use hidden_def because with a hidden_proto, the function definition
would only define the internal alias, and the exported function would be
gone.

Thanks,
Florian
8<------------------------------------------------------------------8<

This commit removes the minor optimization based on strong aliases
because it loses type safety.

-----
 include/netdb.h           |  7 ++++++-
 nis/nss-nis.h             |  1 +
 nis/nss_nis/nis-hosts.c   | 17 +++++++----------
 nis/nss_nis/nis-network.c | 17 ++++++++---------
 nis/nss_nis/nis-spwd.c    | 16 ++++++++--------
 5 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/include/netdb.h b/include/netdb.h
index e230b1f4fc..a2bd5eef44 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -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)
@@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod)
 DECLARE_NSS_PROTOTYPES (nis)
 DECLARE_NSS_PROTOTYPES (nisplus)
 
+hidden_proto (_nss_nis_endhostent)
+hidden_proto (_nss_nis_endnetent)
+hidden_proto (_nss_nis_endspent)
+
 #undef DECLARE_NSS_PROTOTYPES
 #endif
 
diff --git a/nis/nss-nis.h b/nis/nss-nis.h
index dc091d1a20..7c009d7e87 100644
--- a/nis/nss-nis.h
+++ b/nis/nss-nis.h
@@ -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;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 2d08076382..7c28580659 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -19,11 +19,7 @@
 #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)
-
+hidden_def (_nss_nis_endhostent)
 
 /* The calling function always need to get a lock first. */
 static enum nss_status
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index dcafd26148..23975cb93f 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -17,11 +17,7 @@
    <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)
+hidden_def (_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-spwd.c b/nis/nss_nis/nis-spwd.c
index 6cd46b4022..be882431d7 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -20,14 +20,11 @@
 #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)
+hidden_def (_nss_nis_endspent)
 
 static enum nss_status
 internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
Andreas Schwab Feb. 25, 2020, 3:09 p.m. UTC | #6
On Feb 25 2020, Florian Weimer wrote:

> @@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod)
>  DECLARE_NSS_PROTOTYPES (nis)
>  DECLARE_NSS_PROTOTYPES (nisplus)
>  
> +hidden_proto (_nss_nis_endhostent)
> +hidden_proto (_nss_nis_endnetent)
> +hidden_proto (_nss_nis_endspent)
> +

The hidden_proto should only exist if IS_IN(libnss_nis).

Andreas.
Florian Weimer Feb. 25, 2020, 4:10 p.m. UTC | #7
* Andreas Schwab:

> On Feb 25 2020, Florian Weimer wrote:
>
>> @@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod)
>>  DECLARE_NSS_PROTOTYPES (nis)
>>  DECLARE_NSS_PROTOTYPES (nisplus)
>>  
>> +hidden_proto (_nss_nis_endhostent)
>> +hidden_proto (_nss_nis_endnetent)
>> +hidden_proto (_nss_nis_endspent)
>> +
>
> The hidden_proto should only exist if IS_IN(libnss_nis).

Okay, then let's add the infrastructure for this.  What about the patch
below?

Thanks,
Florian
8<------------------------------------------------------------------8<

This commit removes the minor optimization based on strong aliases
because it loses type safety.

-----
 include/libc-symbols.h    | 23 +++++++++++++++++++++++
 include/netdb.h           |  8 +++++++-
 nis/nss-nis.h             |  1 +
 nis/nss_nis/nis-hosts.c   | 17 +++++++----------
 nis/nss_nis/nis-network.c | 17 ++++++++---------
 nis/nss_nis/nis-spwd.c    | 16 ++++++++--------
 6 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 33e2d34c53..b0b75a087e 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -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...) \
diff --git a/include/netdb.h b/include/netdb.h
index e230b1f4fc..3c78da60c5 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -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 */
diff --git a/nis/nss-nis.h b/nis/nss-nis.h
index dc091d1a20..7c009d7e87 100644
--- a/nis/nss-nis.h
+++ b/nis/nss-nis.h
@@ -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;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 2d08076382..eb074783f7 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -19,11 +19,7 @@
 #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
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index dcafd26148..8d87c69d8e 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -17,11 +17,7 @@
    <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,
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 6cd46b4022..9790dd4104 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -20,14 +20,11 @@
 #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,
Andreas Schwab Feb. 25, 2020, 4:41 p.m. UTC | #8
On Feb 25 2020, Florian Weimer wrote:

> This commit removes the minor optimization based on strong aliases
> because it loses type safety.

Ok.

Andreas.
Florian Weimer Feb. 25, 2020, 4:44 p.m. UTC | #9
* Andreas Schwab:

> On Feb 25 2020, Florian Weimer wrote:
>
>> This commit removes the minor optimization based on strong aliases
>> because it loses type safety.
>
> Ok.

Thanks, pushed.

Florian
diff mbox series

Patch

diff --git a/nis/nss-nis.h b/nis/nss-nis.h
index dc091d1a20..7c009d7e87 100644
--- a/nis/nss-nis.h
+++ b/nis/nss-nis.h
@@ -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;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 2d08076382..1ee5444cfc 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -90,9 +90,16 @@  static bool_t new_start = 1;
 static char *oldkey = NULL;
 static int oldkeylen = 0;
 
+hidden_proto (_nss_nis_endhostent)
 
 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 +115,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)
-
+hidden_def (_nss_nis_endhostent)
 
 /* The calling function always need to get a lock first. */
 static enum nss_status
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index dcafd26148..511de00bd3 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -45,10 +45,18 @@  static bool_t new_start = 1;
 static char *oldkey;
 static int oldkeylen;
 
+hidden_proto (_nss_nis_endnetent)
+
 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 +70,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)
+hidden_def (_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-spwd.c b/nis/nss_nis/nis-spwd.c
index 6cd46b4022..660447b544 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -46,8 +46,16 @@  static bool ent_adjunct_used;
 static char *oldkey;
 static int oldkeylen;
 
+hidden_proto (_nss_nis_endspent)
+
 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 +69,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)
+hidden_def (_nss_nis_endspent)
 
 static enum nss_status
 internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,