[PATCH v2] nss: Remove effectively unused __nss_*_database variables

Collin Funk collin.funk1@gmail.com
Tue Nov 18 19:01:20 GMT 2025


Florian Weimer <fweimer@redhat.com> writes:

> Use of this cache was removed in commit f8847d83e17774ed5e9c0f75ef693
> ("nsswitch: use new internal API (core)").
>
> ---
>  nss/XXX-lookup.c    | 10 +++-------
>  nss/nsswitch.c      |  8 --------
>  nss/nsswitch.h      |  7 +++----
>  nss/tst-rfc3484-2.c |  2 --
>  nss/tst-rfc3484-3.c |  2 --
>  nss/tst-rfc3484.c   |  2 --
>  6 files changed, 6 insertions(+), 25 deletions(-)
>
> diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
> index 525b4d6304..6f5ea35d29 100644
> --- a/nss/XXX-lookup.c
> +++ b/nss/XXX-lookup.c
> @@ -41,19 +41,15 @@
>  #define CONCAT2_1(Pre, Name) CONCAT2_2 (Pre, Name)
>  #define CONCAT2_2(Pre, Name) Pre##Name
>  
> -#define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
> -#define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
> -#define STRINGIFY1(Name) STRINGIFY2 (Name)
> -#define STRINGIFY2(Name) #Name
> -
>  int
>  DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name,
>  	       void **fctp)
>  {
> -  if (! __nss_database_get (DATABASE_NAME_ID, &DATABASE_NAME_SYMBOL))
> +  nss_action_list actions;
> +  if (! __nss_database_get (DATABASE_NAME_ID, &actions))
>      return -1;
>  
> -  *ni = DATABASE_NAME_SYMBOL;
> +  *ni = actions;
>  
>    /* We want to know about it if we've somehow got a NULL action list;
>     in the past, we had bad state if seccomp interfered with setup. */
> diff --git a/nss/nsswitch.c b/nss/nsswitch.c
> index d1bff6721d..b23bb4c2c1 100644
> --- a/nss/nsswitch.c
> +++ b/nss/nsswitch.c
> @@ -42,14 +42,6 @@
>  #include <sysdep.h>
>  #include <config.h>
>  
> -/* Declare external database variables.  */
> -#define DEFINE_DATABASE(name)						      \
> -  nss_action_list __nss_##name##_database attribute_hidden;		      \
> -  weak_extern (__nss_##name##_database)
> -#include "databases.def"
> -#undef DEFINE_DATABASE
> -
> -
>  #ifdef USE_NSCD
>  /* Flags whether custom rules for database is set.  */
>  bool __nss_database_custom[NSS_DBSIDX_max];
> diff --git a/nss/nsswitch.h b/nss/nsswitch.h
> index fd37379377..9799627aa2 100644
> --- a/nss/nsswitch.h
> +++ b/nss/nsswitch.h
> @@ -184,10 +184,9 @@ libc_hidden_proto (__nss_hostname_digits_dots)
>  #define MAX_NR_ADDRS    48
>  
>  /* Prototypes for __nss_*_lookup2 functions.  */
> -#define DEFINE_DATABASE(arg)						      \
> -  extern struct nss_action *__nss_##arg##_database attribute_hidden;		      \
> -  int __nss_##arg##_lookup2 (struct nss_action **, const char *,		      \
> -			     const char *, void **);			      \
> +#define DEFINE_DATABASE(arg)						\
> +  int __nss_##arg##_lookup2 (struct nss_action **, const char *,	\
> +			     const char *, void **);			\
>    libc_hidden_proto (__nss_##arg##_lookup2)
>  #include "databases.def"
>  #undef DEFINE_DATABASE
> diff --git a/nss/tst-rfc3484-2.c b/nss/tst-rfc3484-2.c
> index a5f8f82c04..7f89e1527c 100644
> --- a/nss/tst-rfc3484-2.c
> +++ b/nss/tst-rfc3484-2.c
> @@ -59,8 +59,6 @@ _res_hconf_init (void)
>  #undef	USE_NSCD
>  #include "getaddrinfo.c"
>  
> -nss_action_list __nss_hosts_database attribute_hidden;
> -
>  /* This is the beginning of the real test code.  The above defines
>     (among other things) the function rfc3484_sort.  */
>  
> diff --git a/nss/tst-rfc3484-3.c b/nss/tst-rfc3484-3.c
> index edf0b7db2e..23aebfd54a 100644
> --- a/nss/tst-rfc3484-3.c
> +++ b/nss/tst-rfc3484-3.c
> @@ -59,8 +59,6 @@ _res_hconf_init (void)
>  #undef	USE_NSCD
>  #include "getaddrinfo.c"
>  
> -nss_action_list __nss_hosts_database attribute_hidden;
> -
>  /* This is the beginning of the real test code.  The above defines
>     (among other things) the function rfc3484_sort.  */
>  
> diff --git a/nss/tst-rfc3484.c b/nss/tst-rfc3484.c
> index 5b4a0c5b82..f882f95f84 100644
> --- a/nss/tst-rfc3484.c
> +++ b/nss/tst-rfc3484.c
> @@ -59,8 +59,6 @@ _res_hconf_init (void)
>  #undef	USE_NSCD
>  #include "getaddrinfo.c"
>  
> -nss_action_list __nss_hosts_database attribute_hidden;
> -
>  /* This is the beginning of the real test code.  The above defines
>     (among other things) the function rfc3484_sort.  */
>  
>
> base-commit: a025a9deef8ad0034e88785a6999014fa2808e12

Looks good, thanks.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin


More information about the Libc-alpha mailing list