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

@@ -696,14 +696,14 @@ void reader_write_title(const wcstring &cmd, bool reset_cursor_position) {
for (size_t i = 0; i < lst.size(); i++) {
fputws(lst.at(i).c_str(), stdout);
}
(void)write(STDOUT_FILENO, "\a", 1);
ignore_result(write(STDOUT_FILENO, "\a", 1));
}
proc_pop_interactive();
set_color(rgb_color_t::reset(), rgb_color_t::reset());
if (reset_cursor_position && !lst.empty()) {
// Put the cursor back at the beginning of the line (issue #2453).
(void)write(STDOUT_FILENO, "\r", 1);
ignore_result(write(STDOUT_FILENO, "\r", 1));
}
}
@@ -1291,7 +1291,7 @@ static void reader_flash() {
}
reader_repaint();
(void)write(STDOUT_FILENO, "\a", 1);
ignore_result(write(STDOUT_FILENO, "\a", 1));
pollint.tv_sec = 0;
pollint.tv_nsec = 100 * 1000000;
@@ -3236,7 +3236,7 @@ const wchar_t *reader_readline(int nchars) {
reader_repaint_if_needed();
}
(void)write(STDOUT_FILENO, "\n", 1);
ignore_result(write(STDOUT_FILENO, "\n", 1));
// Ensure we have no pager contents when we exit.
if (!data->pager.empty()) {