From patchwork Thu Feb 9 15:17:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 19190 Received: (qmail 106683 invoked by alias); 9 Feb 2017 15:17:50 -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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 106377 invoked by uid 89); 9 Feb 2017 15:17:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 spammy=canon, 1317, *string, 34, 7 X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: Re: [PATCH] Rename strdup uses Date: Thu, 9 Feb 2017 15:17:35 +0000 Message-ID: References: In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-office365-filtering-correlation-id: 05dff20c-5c38-440c-cae9-08d450fec74c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:AM5PR0802MB2611; x-microsoft-exchange-diagnostics: 1; AM5PR0802MB2611; 7:pWopzt0XA58NWCenxC1rLfOJImvGDSiR6owR3QLOjyMRSGFHH4nTyX4sNTZqm1cREkWx8G09rUv+YhZb+sfuk2xwSROzmUUI+0uXjMHbk9QtcxRvV9w7HOVuG1EBsrv/e7cFdcE7Z0PU48Ui+uGExXKzxrz73fzBJYQn/4VmZDqo1YbTbCgDYkVwRaIfa3Qk7ZdBoLz0Oe8GBQVd8jyyxm2PEQpHlL5lQjoArHG/UtIwdLrFIFciXRiCoknDVPakF4Y/MGSQGdIxxmktQYxLFSk3pjR90c+Rox3tRPGsP0+do/Uyv6oRFhjG7flfb/fKMV8G5acO87HRpPMZFhub26YT3xvn5Qb/j1T1uJqYvqtvFd02k7hIaUmQOXAA1nJhw2vVvdHLS8UsTnd0/33cvRThhuwaaWgnwkH42mbmjY4Nuvr7EWh9HbP987PzVOcPJ5bNYB/Z0TxZjKfel9kaJz4KVz2A1DDI+v5XCWU5T5Dvnck1NFrqON8p5lQu/0crkIiHjWvEhjwo4dqoAo5M6A== nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6072148); SRVR:AM5PR0802MB2611; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2611; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39450400003)(39410400002)(39850400002)(39860400002)(39840400002)(54534003)(189002)(199003)(377424004)(97736004)(66066001)(105586002)(229853002)(74316002)(2906002)(5660300001)(4326007)(33656002)(25786008)(9686003)(3660700001)(55016002)(77096006)(6436002)(99286003)(3280700002)(68736007)(6506006)(7736002)(305945005)(2501003)(92566002)(575784001)(86362001)(101416001)(6246003)(53546003)(38730400002)(110136004)(2900100001)(106116001)(2351001)(53936002)(5640700003)(8936002)(2950100002)(8676002)(6916009)(106356001)(81166006)(189998001)(450100001)(122556002)(81156014)(54356999)(6116002)(3846002)(50986999)(102836003)(7696004)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2611; H:AM5PR0802MB2610.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Feb 2017 15:17:35.9164 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2611 ping (added mention of BZ tickets) From: Wilco Dijkstra Sent: 11 January 2017 16:02 To: libc-alpha@sourceware.org Cc: nd Subject: [PATCH] Rename strdup uses   Rename existing uses of str(n)dup to __str(n)dup so it no longer needs to be redirected to a builtin.  Also building GLIBC with -Os now no longer shows localplt or linkname space failures (partial fix for BZ #15105 and BZ #19463).  Although this means a loss of inlining (based on current committed headers) in 2 cases, these are both error messages so not performance critical. ChangeLog: 2017-01-11  Wilco Dijkstra  [BZ #15105] [BZ #19463]         * elf/dl-cache.c (_dl_load_cache_lookup): Use __strdup.         * inet/rcmd.c (rcmd_af): Likewise.         * inet/rexec.c   (rexec_af): Likewise.         * intl/dcigettext.c (_LIBC): Likewise.         * intl/finddomain.c (_nl_find_domain): Use strdup expansion.         * locale/loadarchive.c (_nl_load_locale_from_archive):         Use __strdup.         * locale/setlocale.c (setlocale): Likewise.         * posix/spawn_faction_addopen.c         (posix_spawn_file_actions_addopen): Likewise.         * stdlib/putenv.c (putenv): Use __strndup.         * sunrpc/svc_simple.c (__registerrpc): Use __strdup.         * sysdeps/posix/getaddrinfo.c (gaih_inet): Use __strdup/__strndup. diff --git a/elf/dl-cache.c b/elf/dl-cache.c index cfa335eb326cd04f3892a09d4c00cef8208a2f33..4c8afd0684b96b44ec069f907b9537d4fc2ff6d2 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -302,7 +302,7 @@ _dl_load_cache_lookup (const char *name)    char *temp;    temp = alloca (strlen (best) + 1);    strcpy (temp, best); -  return strdup (temp); +  return __strdup (temp);  }    #ifndef MAP_COPY diff --git a/inet/rcmd.c b/inet/rcmd.c index 8613d96764b08cc8fe3d988a0f38125a0cd54d04..b7cc7a82ba0ac1b39ccf03c589e00114b0bc79a5 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -149,7 +149,7 @@ rcmd_af (char **ahost, u_short rport, const char *locuser, const char *remuser,            if (res->ai_canonname){                  free (ahostbuf); -               ahostbuf = strdup (res->ai_canonname); +               ahostbuf = __strdup (res->ai_canonname);                  if (ahostbuf == NULL) {                          __fxprintf(NULL, "%s",                                     _("rcmd: Cannot allocate memory\n")); diff --git a/inet/rexec.c b/inet/rexec.c index 24ac4b11b6d745aa53a80bd0f7bd10924246b526..43fb67bcf2c6d4fdff9e8dcd053786ab523f7aa1 100644 --- a/inet/rexec.c +++ b/inet/rexec.c @@ -73,7 +73,7 @@ rexec_af (char **ahost, int rport, const char *name, const char *pass,            if (res0->ai_canonname){                  free (ahostbuf); -               ahostbuf = strdup (res0->ai_canonname); +               ahostbuf = __strdup (res0->ai_canonname);                  if (ahostbuf == NULL) {                          perror ("rexec: strdup");                          return (-1); diff --git a/intl/dcigettext.c b/intl/dcigettext.c index dd0db4e6b299d1339a1224c99367525c9e7c00d3..39699fe05e58d2405be0a5ac3fd9b57983608be3 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -131,6 +131,7 @@ extern int errno;  /* Rename the non ANSI C functions.  This is required by the standard     because some ANSI C functions will require linking with this object     file and the name space must not be polluted.  */ +# define strdup __strdup  # define getcwd __getcwd  # ifndef stpcpy  #  define stpcpy __stpcpy diff --git a/intl/finddomain.c b/intl/finddomain.c index 2c3348ab54ff5f1d888bfa333cea0de3f4848252..e6d816120a90776ce2d5f2bb646e8ff582e4bb5a 100644 --- a/intl/finddomain.c +++ b/intl/finddomain.c @@ -124,18 +124,12 @@ _nl_find_domain (const char *dirname, char *locale,    alias_value = _nl_expand_alias (locale);    if (alias_value != NULL)      { -#if defined _LIBC || defined HAVE_STRDUP -      locale = strdup (alias_value); -      if (locale == NULL) -       return NULL; -#else        size_t len = strlen (alias_value) + 1;        locale = (char *) malloc (len);        if (locale == NULL)          return NULL;          memcpy (locale, alias_value, len); -#endif      }      /* Now we determine the single parts of the locale name.  First diff --git a/locale/loadarchive.c b/locale/loadarchive.c index 0ac11afa4ad6fa1e1037b3803a1aeabf43da63c4..6c785c9dc0326a6443852f1f38b3fca790057fa2 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -462,7 +462,7 @@ _nl_load_locale_from_archive (int category, const char **namep)    if (__glibc_unlikely (lia == NULL))      return NULL;   -  lia->name = strdup (*namep); +  lia->name = __strdup (*namep);    if (__glibc_unlikely (lia->name == NULL))      {        free (lia); diff --git a/locale/setlocale.c b/locale/setlocale.c index 69b314134bc6213fe92247af012fb4a07ac59a90..1c0c7fc5be41532abf22f98c89180d91b179f536 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -283,7 +283,7 @@ setlocale (int category, const char *locale)        if (__glibc_unlikely (strchr (locale, ';') != NULL))          {            /* This is a composite name.  Make a copy and split it up.  */ -         locale_copy = strdup (locale); +         locale_copy = __strdup (locale);            if (__glibc_unlikely (locale_copy == NULL))              {                __libc_rwlock_unlock (__libc_setlocale_lock); diff --git a/posix/spawn_faction_addopen.c b/posix/spawn_faction_addopen.c index 4f37d0b8478c3c883150534922550aa13cfcac8e..6f8d3497d6333a0c04a6647154f334a93a55568e 100644 --- a/posix/spawn_faction_addopen.c +++ b/posix/spawn_faction_addopen.c @@ -34,7 +34,7 @@ posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions,    if (!__spawn_valid_fd (fd))      return EBADF;   -  char *path_copy = strdup (path); +  char *path_copy = __strdup (path);    if (path_copy == NULL)      return ENOMEM;   diff --git a/stdlib/putenv.c b/stdlib/putenv.c index 71b9ab1d8c40e7505868c7d0bada186d96f71ae5..c7a0a442b9d871fd442b58a144e3c49c35f5e0d8 100644 --- a/stdlib/putenv.c +++ b/stdlib/putenv.c @@ -60,7 +60,7 @@ putenv (char *string)        int use_malloc = !__libc_use_alloca (name_end - string + 1);        if (__builtin_expect (use_malloc, 0))          { -         name = strndup (string, name_end - string); +         name = __strndup (string, name_end - string);            if (name == NULL)              return -1;          } diff --git a/sunrpc/svc_simple.c b/sunrpc/svc_simple.c index baa177eec0f1fea3306e056033be29cee42fe132..acc9b9db14fa24b4b04e4ddca7d10980e661fe88 100644 --- a/sunrpc/svc_simple.c +++ b/sunrpc/svc_simple.c @@ -87,7 +87,7 @@ __registerrpc (u_long prognum, u_long versnum, u_long procnum,        transp = svcudp_create (RPC_ANYSOCK);        if (transp == NULL)          { -         buf = strdup (_("couldn't create an rpc server\n")); +         buf = __strdup (_("couldn't create an rpc server\n"));            goto err_out;          }      } @@ -103,7 +103,7 @@ __registerrpc (u_long prognum, u_long versnum, u_long procnum,    pl = (struct proglst_ *) malloc (sizeof (struct proglst_));    if (pl == NULL)      { -      buf = strdup (_("registerrpc: out of memory\n")); +      buf = __strdup (_("registerrpc: out of memory\n"));        goto err_out;      }    pl->p_progname = progname; diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 740e9555d5c836c02a329b39540fb367ee8f8a4e..24d6d471710f5db3670b94056c5a0150c4742a47 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -536,7 +536,7 @@ gaih_inet (const char *name, const struct gaih_service *service,                        }                      else                        { -                       namebuf = strndup (name, scope_delim - name); +                       namebuf = __strndup (name, scope_delim - name);                          if (namebuf == NULL)                            {                              assert (!malloc_name); @@ -1139,7 +1139,7 @@ gaih_inet (const char *name, const struct gaih_service *service,                    malloc_canonbuf = false;                  else                    { -                   canon = strdup (canon); +                   canon = __strdup (canon);                      if (canon == NULL)                        {                          result = -EAI_MEMORY;