From 419d7a513820b1c09a7f9ced6a83625846e3b0c1 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 17 Oct 2018 20:07:45 -0500 Subject: [PATCH] Don't decompose shared_ptr to raw pointer for exec_job --- src/exec.cpp | 10 +++++----- src/exec.h | 2 +- src/parse_execution.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 74ffece9c..793f6b52f 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -984,8 +984,8 @@ static bool exec_process_in_job(parser_t &parser, process_t *p, job_t *j, return true; } -void exec_job(parser_t &parser, job_t *j) { - assert(j != nullptr && "null job_t passed to exec_job!"); +void exec_job(parser_t &parser, shared_ptr j) { + assert(j && "null job_t passed to exec_job!"); // Set to true if something goes wrong while exec:ing the job, in which case the cleanup code // will kick in. @@ -1012,7 +1012,7 @@ void exec_job(parser_t &parser, job_t *j) { } if (j->processes.front()->type == INTERNAL_EXEC) { - internal_exec(j, std::move(all_ios)); + internal_exec(j.get(), std::move(all_ios)); DIE("this should be unreachable"); } @@ -1025,7 +1025,7 @@ void exec_job(parser_t &parser, job_t *j) { if (!io_buffer->avoid_conflicts_with_io_chain(all_ios)) { // We could not avoid conflicts, probably due to fd exhaustion. Mark an error. exec_error = true; - job_mark_process_as_failed(j, j->processes.front().get()); + job_mark_process_as_failed(j.get(), j->processes.front().get()); break; } } @@ -1045,7 +1045,7 @@ void exec_job(parser_t &parser, job_t *j) { autoclose_fd_t pipe_next_read; for (std::unique_ptr &unique_p : j->processes) { autoclose_fd_t current_read = std::move(pipe_next_read); - if (!exec_process_in_job(parser, unique_p.get(), j, std::move(current_read), + if (!exec_process_in_job(parser, unique_p.get(), j.get(), std::move(current_read), &pipe_next_read, all_ios, stdout_read_limit)) { exec_error = true; break; diff --git a/src/exec.h b/src/exec.h index 27a5110c8..a9ae4445f 100644 --- a/src/exec.h +++ b/src/exec.h @@ -26,7 +26,7 @@ /// command-specific completions. class job_t; class parser_t; -void exec_job(parser_t &parser, job_t *j); +void exec_job(parser_t &parser, std::shared_ptr j); /// Evaluate the expression cmd in a subshell, add the outputs into the list l. On return, the /// status flag as returned bu \c proc_gfet_last_status will not be changed. diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 049980459..0872b28fd 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -1230,7 +1230,7 @@ parse_execution_result_t parse_execution_context_t::run_1_job(tnode_t jo } // Actually execute the job. - exec_job(*this->parser, job.get()); + exec_job(*this->parser, job); // Only external commands require a new fishd barrier. if (job_contained_external_command) {