This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Add macros for diagnostic control, use them in locale/weightwc.h
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Joseph Myers <joseph at codesourcery dot com>, Roland McGrath <roland at hack dot frob dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 25 Nov 2014 14:35:50 -0800
- Subject: Re: Add macros for diagnostic control, use them in locale/weightwc.h
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1411181803130 dot 11642 at digraph dot polyomino dot org dot uk> <alpine dot DEB dot 2 dot 10 dot 1411211705270 dot 2475 at digraph dot polyomino dot org dot uk> <546F79BB dot 80604 at cs dot ucla dot edu> <alpine dot DEB dot 2 dot 10 dot 1411211807540 dot 2475 at digraph dot polyomino dot org dot uk> <546F8FA5 dot 2050702 at cs dot ucla dot edu> <alpine dot DEB dot 2 dot 10 dot 1411212240570 dot 32250 at digraph dot polyomino dot org dot uk> <54701BAA dot 1030805 at cs dot ucla dot edu> <20141124234701 dot 5BB082C3B22 at topped-with-meat dot com> <alpine dot DEB dot 2 dot 10 dot 1411250106450 dot 11608 at digraph dot polyomino dot org dot uk>
On 11/24/2014 05:29 PM, Joseph Myers wrote:
We have the nscd/connections.c "ignoring return value of 'setuid', declared
with attribute warn_unused_result [-Wunused-result]" (and similar for
setgid), in a context where another id-setting call has already failed
Yes, we've run into that several times in GNU applications and we came
up with a better way to fix it, in the Gnulib ignore-value module, which
defines this:
# define ignore_value(x) \
(__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
One can then write "ignore_value (setuid (server_uid))" instead of
"setuid (server_uid)". So we shouldn't need a pragma for this one.
We have, for some
architecture/compiler combinations, "res_send.c:795:41: warning: 'resplen'
may be used uninitialized in this function [-Wmaybe-uninitialized]" (a
case where the relevant code only gets executed if the variable is
initialized - the first time round a loop will execute a different if
branch and cause it to be initialized).
Neither you nor Roland liked the IF_LINT approach that Gnulib uses for
this sort of thing, but I hope we can figure out something else to
satisfy glibc's constraints. How about something like this?
#define ASSUME_MEM_INITIALIZED(v) asm ("" : "=m" (v))
and then write "ASSUME_MEM_INITIALIZED (resplen)" after declaring resplen.
And that's it for warnings (on
x86_64 / ARM / PowerPC, in my testing) for which suppression seems a
sensible first approach.
In that case, it's not unreasonable to hope that we can avoid the
pragmas entirely.