From patchwork Fri Feb 27 21:18:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 444499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 89F61140119 for ; Sat, 28 Feb 2015 08:18:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=mB6/pyJJ; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=BcAhBBD73MjzT73F bo9JWwg2RkQXCeUzbpWqedgpUDIqkcpLcLm4rCg0OkknanQ6jkERzQ2hlcnru2rD CfDAEYLbg9qCgVDWaugg8WJ/hDjC4BoPIadvjwS5+c6CCNaUM8laFjF/WGx9R4ZG Oojz/+JyHCB3qlz++AgfEcF7RGg= 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:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; s=default; bh=xh3xXT065KccHB9aEBv83Q 0n/Hg=; b=mB6/pyJJLW3JGp+30FqT92W6xiGvC+xF66u+O3Fdqu5wTc82X27TAu DLievMvhw8lfBrlL9MLaNbkuPy3K+D+pM4+mlqMLrbx+xzOkRp20W2blBQv0Qb3l FpVnCImn+u/4i/RNqKQku6BdjHWkRfQtV05v0CHvJLKxr6huZbx5M= Received: (qmail 78385 invoked by alias); 27 Feb 2015 21:18:45 -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 78375 invoked by uid 89); 27 Feb 2015 21:18:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Message-ID: <54F0DF2F.9020404@redhat.com> Date: Fri, 27 Feb 2015 16:18:39 -0500 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Alexandre Oliva CC: Roland McGrath , libc-alpha@sourceware.org Subject: Re: search locale archive again after alias expansion References: <20130918220004.B23492C09F@topped-with-meat.com> <54E796D1.40502@redhat.com> <54EF93B1.60808@redhat.com> <54F0A592.7090809@redhat.com> In-Reply-To: On 02/27/2015 04:03 PM, Alexandre Oliva wrote: > On Feb 27, 2015, "Carlos O'Donell" wrote: > >> Is that minimal? Does that solve the casting issue? > > Of course not. Plenty of casts that drop const, now superfluous, remain > in place with your patch. The point of the patch was to remove them > all. Now? That is ~9 lines of changes vs. the original ~22 lines of change. --- Cheers, Carlos. diff --git a/locale/findlocale.c b/locale/findlocale.c index 5e2639b..2e98c31 100644 --- a/locale/findlocale.c +++ b/locale/findlocale.c @@ -105,7 +105,8 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, { int mask; /* Name of the locale for this category. */ - char *loc_name = (char *) *name; + const char *loc_name = *name; + char *loc_name_copy; const char *language; const char *modifier; const char *territory; @@ -124,7 +125,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, if (!name_present (loc_name)) loc_name = getenv ("LANG"); if (!name_present (loc_name)) - loc_name = (char *) _nl_C_name; + loc_name = _nl_C_name; } /* We used to fall back to the C locale if the name contains a slash @@ -136,7 +137,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, { /* We need not load anything. The needed data is contained in the library itself. */ - *name = (char *) _nl_C_name; + *name = _nl_C_name; return _nl_C[category]; } else if (!valid_locale_name (loc_name)) @@ -158,11 +159,10 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, /* Nothing in the archive with the given name. Expanding it as an alias and retry. */ - loc_name = (char *) _nl_expand_alias (*name); + loc_name = _nl_expand_alias (*name); if (loc_name != NULL) { - data = _nl_load_locale_from_archive (category, - (const char **) &loc_name); + data = _nl_load_locale_from_archive (category, &loc_name); if (__builtin_expect (data != NULL, 1)) return data; } @@ -175,14 +175,14 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, /* We really have to load some data. First see whether the name is an alias. Please note that this makes it impossible to have "C" or "POSIX" as aliases. */ - loc_name = (char *) _nl_expand_alias (*name); + loc_name = _nl_expand_alias (*name); if (loc_name == NULL) /* It is no alias. */ - loc_name = (char *) *name; + loc_name = *name; /* Make a writable copy of the locale name. */ - loc_name = strdupa (loc_name); + loc_name_copy = strdupa (loc_name); /* LOCALE can consist of up to four recognized parts for the XPG syntax: @@ -197,7 +197,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, (3) territory (4) modifier */ - mask = _nl_explode_name (loc_name, &language, &modifier, &territory, + mask = _nl_explode_name (loc_name_copy, &language, &modifier, &territory, &codeset, &normalized_codeset); if (mask == -1) /* Memory allocate problem. */