This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Avoid -Wno-write-strings for k_standard.c [committed]


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]