Avoid compiler warnings due to ignored write return values

Glibc (at least) provides the warn_unused_result attribute on write,
(if optimizing and _FORTIFY_SOURCE is defined). So we explicitly
ignore the return value in our signal handler, where we couldn't do
anything anyway.

Compile with:

	make CFLAGS="-O -D_FORTIFY_SOURCE"

before this commit to see the warning.
This commit is contained in:
Dirk-Jan C. Binnema 2009-11-23 08:03:35 +02:00 committed by Carl Worth
parent 55559ea409
commit 5f0b2ece16
2 changed files with 6 additions and 2 deletions

View file

@ -35,8 +35,10 @@ static volatile sig_atomic_t interrupted;
static void
handle_sigint (unused (int sig))
{
ssize_t ignored;
static char msg[] = "Stopping... \n";
write(2, msg, sizeof(msg)-1);
ignored = write(2, msg, sizeof(msg)-1);
interrupted = 1;
}

View file

@ -25,8 +25,10 @@ static volatile sig_atomic_t interrupted;
static void
handle_sigint (unused (int sig))
{
ssize_t ignored;
static char msg[] = "Stopping... \n";
write(2, msg, sizeof(msg)-1);
ignored = write(2, msg, sizeof(msg)-1);
interrupted = 1;
}