Silence unused result warnings on newer compilers

Newer versions of GCC and Clang are not satisfied by a cast to void,
this fix is adapted from glibc's solution.

New wrapper function ignore_result should be used when a function with
explicit _unused_attribute_ wrapper is called whose result will not be
handled.
This commit is contained in:
Mahmoud Al-Qudsi
2017-08-12 09:54:26 -05:00
committed by Kurtis Rader
parent 5356384d0a
commit e6bb7fc973
6 changed files with 25 additions and 12 deletions

View File

@@ -1207,7 +1207,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t {
// would cause us to hang!
size_t read_amt = 64 * 1024;
void *buff = malloc(read_amt);
(void)read(this->pipe_fd, buff, read_amt);
ignore_result(read(this->pipe_fd, buff, read_amt));
free(buff);
}
@@ -1306,7 +1306,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t {
while (this->readback_amount > 0) {
char buff[64];
size_t amt_to_read = mini(this->readback_amount, sizeof buff);
(void)read(this->pipe_fd, buff, amt_to_read);
ignore_result(read(this->pipe_fd, buff, amt_to_read));
this->readback_amount -= amt_to_read;
}
assert(this->readback_amount == 0);