From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 0E42C1F619 for ; Tue, 25 Feb 2020 14:51:02 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=WMeoNy2wWZX2RfWrQA3c76xmYUD0U0L9zktxxx39ZrfG5ZOcwONeV Uf3xmbJdtuzvMORyx5yl3v8Shu3Wa4rQje4VPLWmRLMIe1LeB1LFlWj91h+RJotY OunyROTYisVLqCpcRKRvdVkpYIQItfdnHfE97AiS0YxB2kEPhquKsc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=9RGvaqs/FXL4ALE87Nej/g0Bi9M=; b=NDjPK1A8QQRVJCXpFaJIT/63aHqa VMJP4rBS2cZXr14wwaGnRmevRKlb/zMO0GatuxNmOaFAsC8vLm9UxHIwa22Se92s OsE2YoNGexK7wMSgkToQTbiQDe46NzSqyRA7o0qbj3Sz2QqAdabjl2Lo191y9iJB zxpikWwFvqT6CfI= Received: (qmail 32328 invoked by alias); 25 Feb 2020 14:50:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 32315 invoked by uid 89); 25 Feb 2020 14:50:59 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582642255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=L73uhli5BI7lVznkMUT5kc6N+PcEgxL6l4hxX/0vBTQ=; b=ZjqKCcIzoqrOsIE+jmeUeHFviEfUlIoKs7fOZkf+traeBQlg6uMXkPJAO4ZB3ZbkNJOj0X mzDwEp4BtzjugCOO+OIGhyvq72LnJpzueV+wa/ISK8Pl5X+dYlYcb8aDZ4NhVXvjhh2G0C swaXAEOK6cNiWTPzKZljJYL3pdXD68o= From: Florian Weimer To: Andreas Schwab Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS References: <875zgadfo5.fsf@oldenburg2.str.redhat.com> <871rqyde9f.fsf@oldenburg2.str.redhat.com> Date: Tue, 25 Feb 2020 15:50:44 +0100 Message-ID: <87sgiyen5n.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * 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 =3D 1; >>>> static char *oldkey =3D NULL; >>>> static int oldkeylen =3D 0; >>>> =20 >>>> +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 ## _getnetbynam= e_r=09=09 \ extern enum nss_status _nss_ ## service ## _getnetbyaddr_r=09=09 \ =09=09 (uint32_t addr, int type, struct netent *net,=09 \ =09=09=09char *buffer, size_t buflen, int *errnop,=09 \ -=09=09=09int *herrnop); +=09=09=09int *herrnop);=09=09=09=09=09 \ +extern enum nss_status _nss_ ## service ## _endspent (void); =20 DECLARE_NSS_PROTOTYPES (compat) DECLARE_NSS_PROTOTYPES (dns) @@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod) DECLARE_NSS_PROTOTYPES (nis) DECLARE_NSS_PROTOTYPES (nisplus) =20 +hidden_proto (_nss_nis_endhostent) +hidden_proto (_nss_nis_endnetent) +hidden_proto (_nss_nis_endspent) + #undef DECLARE_NSS_PROTOTYPES #endif =20 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 @@ =20 #include "nsswitch.h" =20 +NSS_DECLARE_MODULE_FUNCTIONS (nis) =20 /* 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 #include #include -/* The following is an ugly trick to avoid a prototype declaration for - _nss_nis_endgrent. */ -#define _nss_nis_endhostent _nss_nis_endhostent_XXX #include -#undef _nss_nis_endhostent #include #include #include @@ -90,9 +86,14 @@ static bool_t new_start =3D 1; static char *oldkey =3D NULL; static int oldkeylen =3D 0; =20 - enum nss_status _nss_nis_sethostent (int stayopen) +{ + return _nss_nis_endhostent (); +} + +enum nss_status +_nss_nis_endhostent (void) { __libc_lock_lock (lock); =20 @@ -108,11 +109,7 @@ _nss_nis_sethostent (int stayopen) =20 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) =20 /* 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 @@ . */ =20 #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 @@ -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); =20 new_start =3D 1; if (oldkey !=3D NULL) @@ -62,10 +64,7 @@ _nss_nis_setnetent (int stayopen) =20 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) =20 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 #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 +#include =20 #include "nss-nis.h" #include @@ -48,6 +45,12 @@ static int oldkeylen; =20 enum nss_status _nss_nis_setspent (int stayopen) +{ + return _nss_nis_endspent (); +} + +enum nss_status +_nss_nis_endspent (void) { __libc_lock_lock (lock); =20 @@ -61,10 +64,7 @@ _nss_nis_setspent (int stayopen) =20 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) =20 static enum nss_status internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,