Sfoglia il codice sorgente

Fix strange uninit-usage warning

default_compile_flags
vector-of-bool 4 anni fa
parent
commit
517a4ef8a7
1 ha cambiato i file con 9 aggiunte e 3 eliminazioni
  1. +9
    -3
      src/dds/proc.nix.cpp

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

@@ -83,9 +83,15 @@ proc_result dds::run_proc(const proc_options& opts) {

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) {
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) {
errno = 0;
continue;
@@ -93,7 +99,7 @@ proc_result dds::run_proc(const proc_options& opts) {
if (rc == 0) {
// Timeout!
::kill(child, SIGINT);
timeout = std::nullopt;
timeout = -1ms;
res.timed_out = true;
spdlog::debug("Subprocess [{}] timed out", quote_command(opts.command));
continue;

Loading…
Annulla
Salva