This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Avoid -Wno-write-strings for k_standard.c [committed]
- From: Chris Metcalf <cmetcalf at ezchip dot com>
- To: Joseph Myers <joseph at codesourcery dot com>, <libc-alpha at sourceware dot org>
- Date: Thu, 26 Feb 2015 19:12:57 -0500
- Subject: Re: Avoid -Wno-write-strings for k_standard.c [committed]
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;
- References: <alpine dot DEB dot 2 dot 10 dot 1502262251180 dot 11532 at digraph dot polyomino dot org dot uk>
On 2/26/2015 5:51 PM, Joseph Myers wrote:
We want to avoid -Wno- options in makefiles as far as possible, by
cleaning up the underlying issues if possible or failing that by using
diagnostic pragmas. This patch eliminates the use of
-Wno-write-strings for sysdeps/ieee754/k_standard.c by using casts in
the source file to cast away const; those casts are encapsulated in a
macro that also deals with the choice of strings for float / double /
long double functions (for which the logic was previously replicated
many times).
+#define CSTR(func) ((char *) (type < 100 \
+ ? func \
+ : (type < 200 ? func "f" : func "l")))
+
Nice cleanup.
It seems like this code would benefit from a comment as to why it makes
sense here to cast away const from a truly const string. It wasn't true in
the original either, but now the cast is further from the assignment to exc.name,
so it seems like it would be helpful now to document.
--
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com