CLEANUP: remove a few warning about unchecked return values in debug code

There were a few unchecked write() calls in the debug code that cause
gcc 4.x to emit warnings on recent libc. We don't want to check them
as we can't make anything from the result, let's simply surround them
with an empty if statement.

Note that one of the warnings was for chdir("/") which normally cannot
fail since it follows a successful chroot (which means the perms are
necessarily there). Anyway let's move the call uppe to protect it too.
This commit is contained in:
Willy Tarreau 2012-04-29 14:11:38 +02:00
parent 9a7bea52b1
commit 21337825c0
5 changed files with 7 additions and 8 deletions

View File

@ -103,7 +103,7 @@ static struct task *appsession_refresh(struct task *t)
*/
len = sprintf(trash, "appsession_refresh: cleaning up expired Session '%s' on Server %s\n",
element->sessid, element->serverid?element->serverid:"(null)");
write(1, trash, len);
if (write(1, trash, len) < 0) /* shut gcc warning */;
}
/* delete the expired element from within the hash table */
LIST_DEL(&element->hash_list);

View File

@ -181,7 +181,7 @@ int frontend_accept(struct session *s)
break;
}
write(1, trash, len);
if (write(1, trash, len) < 0) /* shut gcc warning */;
}
if (s->fe->mode == PR_MODE_HTTP)

View File

@ -1292,14 +1292,13 @@ int main(int argc, char **argv)
/* chroot if needed */
if (global.chroot != NULL) {
if (chroot(global.chroot) == -1) {
if (chroot(global.chroot) == -1 || chdir("/") == -1) {
Alert("[%s.main()] Cannot chroot(%s).\n", argv[0], global.chroot);
if (nb_oldpids)
tell_old_pids(SIGTTIN);
protocol_unbind_all();
exit(1);
}
chdir("/");
}
if (nb_oldpids)

View File

@ -7347,7 +7347,7 @@ void debug_hdr(const char *dir, struct session *t, const char *start, const char
UBOUND(max, sizeof(trash) - len - 1);
len += strlcpy2(trash + len, start, max + 1);
trash[len++] = '\n';
write(1, trash, len);
if (write(1, trash, len) < 0) /* shut gcc warning */;
}
/*

View File

@ -2063,7 +2063,7 @@ struct task *process_session(struct task *t)
s->uniq_id, s->be->id,
(unsigned short)s->si[0].fd,
(unsigned short)s->si[1].fd);
write(1, trash, len);
if (write(1, trash, len) < 0) /* shut gcc warning */;
}
if (s->si[0].state == SI_ST_CLO &&
@ -2072,7 +2072,7 @@ struct task *process_session(struct task *t)
s->uniq_id, s->be->id,
(unsigned short)s->si[0].fd,
(unsigned short)s->si[1].fd);
write(1, trash, len);
if (write(1, trash, len) < 0) /* shut gcc warning */;
}
}
@ -2179,7 +2179,7 @@ struct task *process_session(struct task *t)
len = sprintf(trash, "%08x:%s.closed[%04x:%04x]\n",
s->uniq_id, s->be->id,
(unsigned short)s->req->prod->fd, (unsigned short)s->req->cons->fd);
write(1, trash, len);
if (write(1, trash, len) < 0) /* shut gcc warning */;
}
s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);