Browse Source

Suppress warning for unused write() result

pull/2097/head
Andrew Waterman 10 months ago
parent
commit
e69c5376a5
  1. 20
      riscv/interactive.cc

20
riscv/interactive.cc

@ -72,6 +72,12 @@ processor_t *sim_t::get_core(const std::string& i)
return get_core(p);
}
static void do_write(int fd, const void* buf, size_t n)
{
auto res = write(fd, buf, n);
(void) res;
}
static void clear_str(bool noncanonical, int fd, std::string target_str)
{
if (noncanonical)
@ -83,7 +89,7 @@ static void clear_str(bool noncanonical, int fd, std::string target_str)
clear_motion += ' ';
}
clear_motion += '\r';
(void) write(fd, clear_motion.c_str(), clear_motion.size() + 1);
do_write(fd, clear_motion.c_str(), clear_motion.size() + 1);
}
}
@ -96,7 +102,7 @@ static void send_key(bool noncanonical, int fd, keybuffer_t key_code, const int
{
key_motion += (char) ((key_code >> (i * BITS_PER_CHAR)) & 0xff);
}
(void) write(fd, key_motion.c_str(), len);
do_write(fd, key_motion.c_str(), len);
}
}
@ -144,7 +150,7 @@ static std::string readline(int fd)
cursor_pos--;
s.erase(cursor_pos, 1);
if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1);
do_write(fd, s.c_str(), s.size() + 1);
// move cursor by left arrow key
for (unsigned i = 0; i < s.size() - cursor_pos; i++) {
send_key(noncanonical, fd, KEYCODE_LEFT, 3);
@ -176,7 +182,7 @@ static std::string readline(int fd)
history_index = std::min(history_commands.size(), history_index + 1);
s = history_commands[history_commands.size() - history_index];
if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1);
do_write(fd, s.c_str(), s.size() + 1);
cursor_pos = s.size();
}
key_buffer = 0;
@ -192,7 +198,7 @@ static std::string readline(int fd)
s = history_commands[history_commands.size() - history_index];
}
if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1);
do_write(fd, s.c_str(), s.size() + 1);
cursor_pos = s.size();
}
key_buffer = 0;
@ -221,7 +227,7 @@ static std::string readline(int fd)
break;
case KEYCODE_ENTER:
if (noncanonical)
(void) write(fd, &ch, 1);
do_write(fd, &ch, 1);
if (s.size() > initial_s_len && (history_commands.size() == 0 || s != history_commands[history_commands.size() - 1])) {
history_commands.push_back(s);
}
@ -236,7 +242,7 @@ static std::string readline(int fd)
s.insert(cursor_pos, 1, ch);
cursor_pos++;
if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1);
do_write(fd, s.c_str(), s.size() + 1);
// send left arrow key to move cursor
for (unsigned i = 0; i < s.size() - cursor_pos; i++) {
send_key(noncanonical, fd, KEYCODE_LEFT, 3);

Loading…
Cancel
Save