This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: search locale archive again after alias expansion
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: Roland McGrath <roland at hack dot frob dot com>, libc-alpha at sourceware dot org
- Date: Fri, 27 Feb 2015 03:45:27 -0300
- Subject: Re: search locale archive again after alias expansion
- Authentication-results: sourceware.org; auth=none
- References: <orr4dao5h6 dot fsf at livre dot home> <20130918220004 dot B23492C09F at topped-with-meat dot com> <ory56t31yv dot fsf at livre dot home> <or8uigyac8 dot fsf at free dot home> <oregr8db48 dot fsf at livre dot home> <54E796D1 dot 40502 at redhat dot com> <oregpd19rz dot fsf at livre dot home> <54EF93B1 dot 60808 at redhat dot com>
On Feb 26, 2015, "Carlos O'Donell" <carlos@redhat.com> wrote:
> On 02/26/2015 01:12 AM, Alexandre Oliva wrote:
>> Here's a follow-up patch that gets us rid of all the const-casting in
>> loc_name and *name. This ensures we won't write to stuff that should be
>> const by accident, and avoids unsafely dereferencing pointers to
>> pointers.
>>
>> Ok to install?
> Not OK, please make the patch minimal.
Please elaborate. The minimal patch is already in, but it addresses a
different problem. It fixes only the warning, by introducing yet
another unsafe cast where we had plenty. This patch that you reject
intends to REMOVE the unsafe casts and solve the violations of C
aliasing rules that they cause.
>> [BZ #15969]
>> * locale/findlocale.c (_nl_find_locale): Introduce const
>> version of loc_name and drop unsafe type casts.
> The name change from loc_name to cloc_name makes backports to release
> branches difficult as any patches applying on top of this one will
> require this patch also.
What will make backports difficult is the removal of the casts. Those
occur at every few lines in each hunk; no context diff that touched
lines containing the const char* variable would avoid having at least
one line that currently contains a faulty cast.
We need a const char* variable to avoid the casts and potential
violation of alias safety rules (writing a char const* to a char *
lvalue is not safe), and we need a char * variable after the copy,
because we write to the string. They can't both have the same name,
unless they were in different scopes, which would require reindenting,
making the differences even bigger.
Now, if I were to rename the non-const version, as Andreas suggested,
this would *increase*, rather than decrease, the patch conflict surface
area, because we'd have conflicts due to the dropped casts, in the area
where I renamed the variable, and more conflicts due to the use of the
renamed non-const char * variable after we copy the const string to a
writable region.
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer