Browse Source

Fix strange uninit-usage warning

default_compile_flags
vector-of-bool 4 years ago
parent
commit
517a4ef8a7
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      src/dds/proc.nix.cpp

+ 9
- 3
src/dds/proc.nix.cpp View File



using namespace std::chrono_literals; using namespace std::chrono_literals;


auto timeout = opts.timeout;
/// Quirk: We _could_ just use opts.timeout.value_or, but it seems like something
/// is weird in GCC 9's data flow analysis and it will warn that `timeout` is
/// used uninitialized when its value is passed to poll() ??
auto timeout = -1ms;
if (opts.timeout) {
timeout = *opts.timeout;
}
while (true) { while (true) {
rc = ::poll(&stdio_fd, 1, static_cast<int>(timeout.value_or(-1ms).count()));
rc = ::poll(&stdio_fd, 1, static_cast<int>(timeout.count()));
if (rc && errno == EINTR) { if (rc && errno == EINTR) {
errno = 0; errno = 0;
continue; continue;
if (rc == 0) { if (rc == 0) {
// Timeout! // Timeout!
::kill(child, SIGINT); ::kill(child, SIGINT);
timeout = std::nullopt;
timeout = -1ms;
res.timed_out = true; res.timed_out = true;
spdlog::debug("Subprocess [{}] timed out", quote_command(opts.command)); spdlog::debug("Subprocess [{}] timed out", quote_command(opts.command));
continue; continue;

Loading…
Cancel
Save