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: Add macros for diagnostic control, use them in locale/weightwc.h


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.


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