git: b392a90ba4e5 - main - kyua: Switch from std::auto_ptr<> to std::unique_ptr<>
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 28 Apr 2025 17:02:48 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=b392a90ba4e5ea07d8a88a834fd102191d1967bf
commit b392a90ba4e5ea07d8a88a834fd102191d1967bf
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-04-28 17:01:32 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-04-28 17:01:32 +0000
kyua: Switch from std::auto_ptr<> to std::unique_ptr<>
A few places were assigning auto_ptr<>s depending on the ownership
handoff. These now use an explicit std::move() as required by
unique_ptr<>.
Reviewed by: ngie, emaste
Differential Revision: https://reviews.freebsd.org/D49790
---
contrib/kyua/cli/cmd_report.cpp | 2 +-
contrib/kyua/cli/cmd_report_junit.cpp | 2 +-
contrib/kyua/cli/common.hpp | 2 +-
contrib/kyua/cli/main.cpp | 4 +-
contrib/kyua/engine/config.cpp | 2 +-
contrib/kyua/engine/scheduler.cpp | 4 +-
contrib/kyua/model/metadata.cpp | 8 ++--
contrib/kyua/model/metadata.hpp | 2 +-
contrib/kyua/model/test_program.hpp | 2 +-
contrib/kyua/os/freebsd/utils/jail.cpp | 4 +-
contrib/kyua/utils/auto_array.hpp | 4 +-
contrib/kyua/utils/cmdline/commands_map.hpp | 2 +-
contrib/kyua/utils/config/lua_module_test.cpp | 2 +-
contrib/kyua/utils/config/nodes.cpp | 18 ++++-----
contrib/kyua/utils/config/parser.hpp | 2 +-
contrib/kyua/utils/config/tree_test.cpp | 2 +-
contrib/kyua/utils/format/formatter.cpp | 2 +-
contrib/kyua/utils/fs/directory.cpp | 2 +-
contrib/kyua/utils/logging/operations.cpp | 2 +-
contrib/kyua/utils/process/child.cpp | 26 ++++++-------
contrib/kyua/utils/process/child.hpp | 14 +++----
contrib/kyua/utils/process/child.ipp | 8 ++--
contrib/kyua/utils/process/child_test.cpp | 44 +++++++++++-----------
.../kyua/utils/process/deadline_killer_test.cpp | 4 +-
contrib/kyua/utils/process/executor.cpp | 8 ++--
contrib/kyua/utils/process/executor.hpp | 4 +-
contrib/kyua/utils/process/executor.ipp | 8 ++--
contrib/kyua/utils/process/fdstream.hpp | 2 +-
contrib/kyua/utils/process/isolation_test.cpp | 2 +-
contrib/kyua/utils/process/operations_test.cpp | 8 ++--
contrib/kyua/utils/process/systembuf.hpp | 2 +-
contrib/kyua/utils/signals/interrupts.cpp | 18 ++++-----
contrib/kyua/utils/signals/interrupts_test.cpp | 4 +-
contrib/kyua/utils/signals/misc_test.cpp | 4 +-
contrib/kyua/utils/signals/programmer.hpp | 2 +-
contrib/kyua/utils/signals/timer.cpp | 4 +-
contrib/kyua/utils/signals/timer.hpp | 2 +-
contrib/kyua/utils/stream.cpp | 4 +-
contrib/kyua/utils/stream.hpp | 2 +-
contrib/kyua/utils/stream_test.cpp | 6 +--
usr.bin/kyua/Makefile | 3 --
41 files changed, 122 insertions(+), 125 deletions(-)
diff --git a/contrib/kyua/cli/cmd_report.cpp b/contrib/kyua/cli/cmd_report.cpp
index 27827e893de7..1bf2b425236f 100644
--- a/contrib/kyua/cli/cmd_report.cpp
+++ b/contrib/kyua/cli/cmd_report.cpp
@@ -404,7 +404,7 @@ cmd_report::run(cmdline::ui* ui,
const cmdline::parsed_cmdline& cmdline,
const config::tree& /* user_config */)
{
- std::auto_ptr< std::ostream > output = utils::open_ostream(
+ std::unique_ptr< std::ostream > output = utils::open_ostream(
cmdline.get_option< cmdline::path_option >("output"));
const fs::path results_file = layout::find_results(
diff --git a/contrib/kyua/cli/cmd_report_junit.cpp b/contrib/kyua/cli/cmd_report_junit.cpp
index c4846c8795f2..acbda414d2e7 100644
--- a/contrib/kyua/cli/cmd_report_junit.cpp
+++ b/contrib/kyua/cli/cmd_report_junit.cpp
@@ -77,7 +77,7 @@ cmd_report_junit::run(cmdline::ui* /* ui */,
const fs::path results_file = layout::find_results(
results_file_open(cmdline));
- std::auto_ptr< std::ostream > output = utils::open_ostream(
+ std::unique_ptr< std::ostream > output = utils::open_ostream(
cmdline.get_option< cmdline::path_option >("output"));
drivers::report_junit_hooks hooks(*output.get());
diff --git a/contrib/kyua/cli/common.hpp b/contrib/kyua/cli/common.hpp
index 15a7e9fa3344..65aadcf326b6 100644
--- a/contrib/kyua/cli/common.hpp
+++ b/contrib/kyua/cli/common.hpp
@@ -68,7 +68,7 @@ typedef utils::cmdline::base_command< utils::config::tree > cli_command;
/// Scoped, strictly owned pointer to a cli_command.
-typedef std::auto_ptr< cli_command > cli_command_ptr;
+typedef std::unique_ptr< cli_command > cli_command_ptr;
/// Collection of result types.
diff --git a/contrib/kyua/cli/main.cpp b/contrib/kyua/cli/main.cpp
index 531c252b0a75..dd7ce939e162 100644
--- a/contrib/kyua/cli/main.cpp
+++ b/contrib/kyua/cli/main.cpp
@@ -198,7 +198,7 @@ safe_main(cmdline::ui* ui, int argc, const char* const argv[],
commands.insert(new cli::cmd_report_junit(), "Reporting");
if (mock_command.get() != NULL)
- commands.insert(mock_command);
+ commands.insert(std::move(mock_command));
const cmdline::parsed_cmdline cmdline = cmdline::parse(argc, argv, options);
@@ -277,7 +277,7 @@ cli::main(cmdline::ui* ui, const int argc, const char* const* const argv,
cli_command_ptr mock_command)
{
try {
- const int exit_code = safe_main(ui, argc, argv, mock_command);
+ const int exit_code = safe_main(ui, argc, argv, std::move(mock_command));
// Codes above 1 are reserved to report conditions captured as
// exceptions below.
diff --git a/contrib/kyua/engine/config.cpp b/contrib/kyua/engine/config.cpp
index a7c418e3164c..d53e9936ba91 100644
--- a/contrib/kyua/engine/config.cpp
+++ b/contrib/kyua/engine/config.cpp
@@ -141,7 +141,7 @@ public:
config::detail::base_node*
engine::user_node::deep_copy(void) const
{
- std::auto_ptr< user_node > new_node(new user_node());
+ std::unique_ptr< user_node > new_node(new user_node());
new_node->_value = _value;
return new_node.release();
}
diff --git a/contrib/kyua/engine/scheduler.cpp b/contrib/kyua/engine/scheduler.cpp
index d4507a247323..5179436073b8 100644
--- a/contrib/kyua/engine/scheduler.cpp
+++ b/contrib/kyua/engine/scheduler.cpp
@@ -1567,12 +1567,12 @@ scheduler::scheduler_handle::debug_test(
// file, waiting for further output to appear... as this only works on pipes
// or sockets. We need a better interface for this whole thing.
{
- std::auto_ptr< std::ostream > output = utils::open_ostream(
+ std::unique_ptr< std::ostream > output = utils::open_ostream(
stdout_target);
*output << utils::read_file(result_handle->stdout_file());
}
{
- std::auto_ptr< std::ostream > output = utils::open_ostream(
+ std::unique_ptr< std::ostream > output = utils::open_ostream(
stderr_target);
*output << utils::read_file(result_handle->stderr_file());
}
diff --git a/contrib/kyua/model/metadata.cpp b/contrib/kyua/model/metadata.cpp
index 26b7f7322c6e..85248d596727 100644
--- a/contrib/kyua/model/metadata.cpp
+++ b/contrib/kyua/model/metadata.cpp
@@ -76,7 +76,7 @@ public:
virtual base_node*
deep_copy(void) const
{
- std::auto_ptr< bytes_node > new_node(new bytes_node());
+ std::unique_ptr< bytes_node > new_node(new bytes_node());
new_node->_value = _value;
return new_node.release();
}
@@ -106,7 +106,7 @@ public:
virtual base_node*
deep_copy(void) const
{
- std::auto_ptr< delta_node > new_node(new delta_node());
+ std::unique_ptr< delta_node > new_node(new delta_node());
new_node->_value = _value;
return new_node.release();
}
@@ -166,7 +166,7 @@ class user_node : public config::string_node {
virtual base_node*
deep_copy(void) const
{
- std::auto_ptr< user_node > new_node(new user_node());
+ std::unique_ptr< user_node > new_node(new user_node());
new_node->_value = _value;
return new_node.release();
}
@@ -197,7 +197,7 @@ class paths_set_node : public config::base_set_node< fs::path > {
virtual base_node*
deep_copy(void) const
{
- std::auto_ptr< paths_set_node > new_node(new paths_set_node());
+ std::unique_ptr< paths_set_node > new_node(new paths_set_node());
new_node->_value = _value;
return new_node.release();
}
diff --git a/contrib/kyua/model/metadata.hpp b/contrib/kyua/model/metadata.hpp
index 83bc5348774a..263ecc86106d 100644
--- a/contrib/kyua/model/metadata.hpp
+++ b/contrib/kyua/model/metadata.hpp
@@ -95,7 +95,7 @@ class metadata_builder : utils::noncopyable {
struct impl;
/// Pointer to the shared internal implementation.
- std::auto_ptr< impl > _pimpl;
+ std::unique_ptr< impl > _pimpl;
public:
metadata_builder(void);
diff --git a/contrib/kyua/model/test_program.hpp b/contrib/kyua/model/test_program.hpp
index 974ec2a12d19..ab00dbeb44e4 100644
--- a/contrib/kyua/model/test_program.hpp
+++ b/contrib/kyua/model/test_program.hpp
@@ -87,7 +87,7 @@ class test_program_builder : utils::noncopyable {
struct impl;
/// Pointer to the shared internal implementation.
- std::auto_ptr< impl > _pimpl;
+ std::unique_ptr< impl > _pimpl;
public:
test_program_builder(const std::string&, const utils::fs::path&,
diff --git a/contrib/kyua/os/freebsd/utils/jail.cpp b/contrib/kyua/os/freebsd/utils/jail.cpp
index b39761f28e51..d2f320d1f460 100644
--- a/contrib/kyua/os/freebsd/utils/jail.cpp
+++ b/contrib/kyua/os/freebsd/utils/jail.cpp
@@ -213,7 +213,7 @@ jail::create(const std::string& jail_name,
av.push_back("persist");
// invoke jail
- std::auto_ptr< process::child > child = child::fork_capture(
+ std::unique_ptr< process::child > child = child::fork_capture(
run(fs::path("/usr/sbin/jail"), av));
process::status status = child->wait();
@@ -288,7 +288,7 @@ jail::remove(const std::string& jail_name)
av.push_back(jail_name);
// invoke jail
- std::auto_ptr< process::child > child = child::fork_capture(
+ std::unique_ptr< process::child > child = child::fork_capture(
run(fs::path("/usr/sbin/jail"), av));
process::status status = child->wait();
diff --git a/contrib/kyua/utils/auto_array.hpp b/contrib/kyua/utils/auto_array.hpp
index 0cc3d0e0afd5..93b3e20223cf 100644
--- a/contrib/kyua/utils/auto_array.hpp
+++ b/contrib/kyua/utils/auto_array.hpp
@@ -66,8 +66,8 @@ public:
/// A simple smart pointer for arrays providing strict ownership semantics.
///
-/// This class is the counterpart of std::auto_ptr for arrays. The semantics of
-/// the API of this class are the same as those of std::auto_ptr.
+/// This class is the counterpart of std::unique_ptr for arrays. The semantics of
+/// the API of this class are the same as those of std::unique_ptr.
///
/// The wrapped pointer must be NULL or must have been allocated using operator
/// new[].
diff --git a/contrib/kyua/utils/cmdline/commands_map.hpp b/contrib/kyua/utils/cmdline/commands_map.hpp
index 5378a6f2c471..d5933cc31e33 100644
--- a/contrib/kyua/utils/cmdline/commands_map.hpp
+++ b/contrib/kyua/utils/cmdline/commands_map.hpp
@@ -72,7 +72,7 @@ public:
~commands_map(void);
/// Scoped, strictly-owned pointer to a command from this map.
- typedef typename std::auto_ptr< BaseCommand > command_ptr;
+ typedef typename std::unique_ptr< BaseCommand > command_ptr;
void insert(command_ptr, const std::string& = "");
void insert(BaseCommand*, const std::string& = "");
diff --git a/contrib/kyua/utils/config/lua_module_test.cpp b/contrib/kyua/utils/config/lua_module_test.cpp
index 484d129c4021..d5d0bfc1a1f2 100644
--- a/contrib/kyua/utils/config/lua_module_test.cpp
+++ b/contrib/kyua/utils/config/lua_module_test.cpp
@@ -67,7 +67,7 @@ public:
virtual base_node*
deep_copy(void) const
{
- std::auto_ptr< custom_node > new_node(new custom_node());
+ std::unique_ptr< custom_node > new_node(new custom_node());
new_node->_value = _value;
return new_node.release();
}
diff --git a/contrib/kyua/utils/config/nodes.cpp b/contrib/kyua/utils/config/nodes.cpp
index 1c6e848daf07..2747c11989ad 100644
--- a/contrib/kyua/utils/config/nodes.cpp
+++ b/contrib/kyua/utils/config/nodes.cpp
@@ -110,7 +110,7 @@ config::detail::inner_node::combine_children_into(
continue;
}
- std::auto_ptr< base_node > new_node;
+ std::unique_ptr< base_node > new_node;
children_map::const_iterator iter2 = c2.find(name);
if (iter2 == c2.end()) {
@@ -296,7 +296,7 @@ config::detail::static_inner_node::static_inner_node(void) :
config::detail::base_node*
config::detail::static_inner_node::deep_copy(void) const
{
- std::auto_ptr< inner_node > new_node(new static_inner_node());
+ std::unique_ptr< inner_node > new_node(new static_inner_node());
copy_into(new_node.get());
return new_node.release();
}
@@ -314,7 +314,7 @@ config::detail::base_node*
config::detail::static_inner_node::combine(const tree_key& key,
const base_node* other) const
{
- std::auto_ptr< inner_node > new_node(new static_inner_node());
+ std::unique_ptr< inner_node > new_node(new static_inner_node());
combine_into(key, other, new_node.get());
return new_node.release();
}
@@ -377,7 +377,7 @@ config::detail::dynamic_inner_node::dynamic_inner_node(void) :
config::detail::base_node*
config::detail::dynamic_inner_node::deep_copy(void) const
{
- std::auto_ptr< inner_node > new_node(new dynamic_inner_node());
+ std::unique_ptr< inner_node > new_node(new dynamic_inner_node());
copy_into(new_node.get());
return new_node.release();
}
@@ -395,7 +395,7 @@ config::detail::base_node*
config::detail::dynamic_inner_node::combine(const tree_key& key,
const base_node* other) const
{
- std::auto_ptr< inner_node > new_node(new dynamic_inner_node());
+ std::unique_ptr< inner_node > new_node(new dynamic_inner_node());
combine_into(key, other, new_node.get());
return new_node.release();
}
@@ -441,7 +441,7 @@ config::leaf_node::combine(const detail::tree_key& key,
config::detail::base_node*
config::bool_node::deep_copy(void) const
{
- std::auto_ptr< bool_node > new_node(new bool_node());
+ std::unique_ptr< bool_node > new_node(new bool_node());
new_node->_value = _value;
return new_node.release();
}
@@ -480,7 +480,7 @@ config::bool_node::set_lua(lutok::state& state, const int value_index)
config::detail::base_node*
config::int_node::deep_copy(void) const
{
- std::auto_ptr< int_node > new_node(new int_node());
+ std::unique_ptr< int_node > new_node(new int_node());
new_node->_value = _value;
return new_node.release();
}
@@ -532,7 +532,7 @@ config::positive_int_node::validate(const value_type& new_value) const
config::detail::base_node*
config::string_node::deep_copy(void) const
{
- std::auto_ptr< string_node > new_node(new string_node());
+ std::unique_ptr< string_node > new_node(new string_node());
new_node->_value = _value;
return new_node.release();
}
@@ -571,7 +571,7 @@ config::string_node::set_lua(lutok::state& state, const int value_index)
config::detail::base_node*
config::strings_set_node::deep_copy(void) const
{
- std::auto_ptr< strings_set_node > new_node(new strings_set_node());
+ std::unique_ptr< strings_set_node > new_node(new strings_set_node());
new_node->_value = _value;
return new_node.release();
}
diff --git a/contrib/kyua/utils/config/parser.hpp b/contrib/kyua/utils/config/parser.hpp
index cb69e756cbe8..a0496f0bda40 100644
--- a/contrib/kyua/utils/config/parser.hpp
+++ b/contrib/kyua/utils/config/parser.hpp
@@ -66,7 +66,7 @@ public:
private:
/// Pointer to the internal implementation.
- std::auto_ptr< impl > _pimpl;
+ std::unique_ptr< impl > _pimpl;
/// Hook to initialize the tree keys before reading the file.
///
diff --git a/contrib/kyua/utils/config/tree_test.cpp b/contrib/kyua/utils/config/tree_test.cpp
index b6efd64a84a6..328b8b59a785 100644
--- a/contrib/kyua/utils/config/tree_test.cpp
+++ b/contrib/kyua/utils/config/tree_test.cpp
@@ -76,7 +76,7 @@ public:
virtual base_node*
deep_copy(void) const
{
- std::auto_ptr< wrapped_int_node > new_node(new wrapped_int_node());
+ std::unique_ptr< wrapped_int_node > new_node(new wrapped_int_node());
new_node->_value = _value;
return new_node.release();
}
diff --git a/contrib/kyua/utils/format/formatter.cpp b/contrib/kyua/utils/format/formatter.cpp
index 99cfd40f03ab..1746f6cbd332 100644
--- a/contrib/kyua/utils/format/formatter.cpp
+++ b/contrib/kyua/utils/format/formatter.cpp
@@ -118,7 +118,7 @@ to_int(const std::string& format, const std::string& str, const char* what)
static std::ostringstream*
new_ostringstream(const std::string& format)
{
- std::auto_ptr< std::ostringstream > output(new std::ostringstream());
+ std::unique_ptr< std::ostringstream > output(new std::ostringstream());
if (format.length() <= 2) {
// If the format is empty, we create a new stream so that we don't have
diff --git a/contrib/kyua/utils/fs/directory.cpp b/contrib/kyua/utils/fs/directory.cpp
index ff7ad5e34357..c8cd5e008490 100644
--- a/contrib/kyua/utils/fs/directory.cpp
+++ b/contrib/kyua/utils/fs/directory.cpp
@@ -138,7 +138,7 @@ struct utils::fs::detail::directory_iterator::impl : utils::noncopyable {
/// This is separate from _dirent because this is the type we return to the
/// user. We must keep this as a pointer so that we can support the common
/// operators (* and ->) over iterators.
- std::auto_ptr< directory_entry > _entry;
+ std::unique_ptr< directory_entry > _entry;
/// Constructs an iterator pointing to the "end" of the directory.
impl(void) : _path("invalid-directory-entry"), _dirp(NULL)
diff --git a/contrib/kyua/utils/logging/operations.cpp b/contrib/kyua/utils/logging/operations.cpp
index 88f25361fa18..ce86183910b2 100644
--- a/contrib/kyua/utils/logging/operations.cpp
+++ b/contrib/kyua/utils/logging/operations.cpp
@@ -105,7 +105,7 @@ struct global_state {
std::vector< std::pair< logging::level, std::string > > backlog;
/// Stream to the currently open log file.
- std::auto_ptr< std::ostream > logfile;
+ std::unique_ptr< std::ostream > logfile;
global_state() :
log_level(logging::level_debug),
diff --git a/contrib/kyua/utils/process/child.cpp b/contrib/kyua/utils/process/child.cpp
index fef09ccaad3b..bfde8159d5c8 100644
--- a/contrib/kyua/utils/process/child.cpp
+++ b/contrib/kyua/utils/process/child.cpp
@@ -65,7 +65,7 @@ struct child::impl : utils::noncopyable {
pid_t _pid;
/// The input stream for the process' stdout and stderr. May be NULL.
- std::auto_ptr< process::ifdstream > _output;
+ std::unique_ptr< process::ifdstream > _output;
/// Initializes private implementation data.
///
@@ -192,7 +192,7 @@ process::child::~child(void)
/// noncopyable. In the case of the child, a NULL pointer.
///
/// \throw process::system_error If the calls to pipe(2) or fork(2) fail.
-std::auto_ptr< process::child >
+std::unique_ptr< process::child >
process::child::fork_capture_aux(void)
{
std::cout.flush();
@@ -202,7 +202,7 @@ process::child::fork_capture_aux(void)
if (detail::syscall_pipe(fds) == -1)
throw process::system_error("pipe(2) failed", errno);
- std::auto_ptr< signals::interrupts_inhibiter > inhibiter(
+ std::unique_ptr< signals::interrupts_inhibiter > inhibiter(
new signals::interrupts_inhibiter);
pid_t pid = detail::syscall_fork();
if (pid == -1) {
@@ -223,13 +223,13 @@ process::child::fork_capture_aux(void)
std::cerr << F("Failed to set up subprocess: %s\n") % e.what();
std::abort();
}
- return std::auto_ptr< process::child >(NULL);
+ return std::unique_ptr< process::child >(NULL);
} else {
::close(fds[1]);
LD(F("Spawned process %s: stdout and stderr inherited") % pid);
signals::add_pid_to_kill(pid);
inhibiter.reset(NULL); // Unblock signals.
- return std::auto_ptr< process::child >(
+ return std::unique_ptr< process::child >(
new process::child(new impl(pid, new process::ifdstream(fds[0]))));
}
}
@@ -252,14 +252,14 @@ process::child::fork_capture_aux(void)
/// noncopyable. In the case of the child, a NULL pointer.
///
/// \throw process::system_error If the call to fork(2) fails.
-std::auto_ptr< process::child >
+std::unique_ptr< process::child >
process::child::fork_files_aux(const fs::path& stdout_file,
const fs::path& stderr_file)
{
std::cout.flush();
std::cerr.flush();
- std::auto_ptr< signals::interrupts_inhibiter > inhibiter(
+ std::unique_ptr< signals::interrupts_inhibiter > inhibiter(
new signals::interrupts_inhibiter);
pid_t pid = detail::syscall_fork();
if (pid == -1) {
@@ -284,13 +284,13 @@ process::child::fork_files_aux(const fs::path& stdout_file,
std::cerr << F("Failed to set up subprocess: %s\n") % e.what();
std::abort();
}
- return std::auto_ptr< process::child >(NULL);
+ return std::unique_ptr< process::child >(NULL);
} else {
LD(F("Spawned process %s: stdout=%s, stderr=%s") % pid % stdout_file %
stderr_file);
signals::add_pid_to_kill(pid);
inhibiter.reset(NULL); // Unblock signals.
- return std::auto_ptr< process::child >(
+ return std::unique_ptr< process::child >(
new process::child(new impl(pid, NULL)));
}
}
@@ -309,10 +309,10 @@ process::child::fork_files_aux(const fs::path& stdout_file,
///
/// \throw process::system_error If the process cannot be spawned due to a
/// system call error.
-std::auto_ptr< process::child >
+std::unique_ptr< process::child >
process::child::spawn_capture(const fs::path& program, const args_vector& args)
{
- std::auto_ptr< child > child = fork_capture_aux();
+ std::unique_ptr< child > child = fork_capture_aux();
if (child.get() == NULL)
exec(program, args);
log_exec(program, args);
@@ -335,13 +335,13 @@ process::child::spawn_capture(const fs::path& program, const args_vector& args)
///
/// \throw process::system_error If the process cannot be spawned due to a
/// system call error.
-std::auto_ptr< process::child >
+std::unique_ptr< process::child >
process::child::spawn_files(const fs::path& program,
const args_vector& args,
const fs::path& stdout_file,
const fs::path& stderr_file)
{
- std::auto_ptr< child > child = fork_files_aux(stdout_file, stderr_file);
+ std::unique_ptr< child > child = fork_files_aux(stdout_file, stderr_file);
if (child.get() == NULL)
exec(program, args);
log_exec(program, args);
diff --git a/contrib/kyua/utils/process/child.hpp b/contrib/kyua/utils/process/child.hpp
index 2c9450f6500a..3e00cea8752c 100644
--- a/contrib/kyua/utils/process/child.hpp
+++ b/contrib/kyua/utils/process/child.hpp
@@ -76,11 +76,11 @@ class child : noncopyable {
struct impl;
/// Pointer to the shared internal implementation.
- std::auto_ptr< impl > _pimpl;
+ std::unique_ptr< impl > _pimpl;
- static std::auto_ptr< child > fork_capture_aux(void);
+ static std::unique_ptr< child > fork_capture_aux(void);
- static std::auto_ptr< child > fork_files_aux(const fs::path&,
+ static std::unique_ptr< child > fork_files_aux(const fs::path&,
const fs::path&);
explicit child(impl *);
@@ -89,16 +89,16 @@ public:
~child(void);
template< typename Hook >
- static std::auto_ptr< child > fork_capture(Hook);
+ static std::unique_ptr< child > fork_capture(Hook);
std::istream& output(void);
template< typename Hook >
- static std::auto_ptr< child > fork_files(Hook, const fs::path&,
+ static std::unique_ptr< child > fork_files(Hook, const fs::path&,
const fs::path&);
- static std::auto_ptr< child > spawn_capture(
+ static std::unique_ptr< child > spawn_capture(
const fs::path&, const args_vector&);
- static std::auto_ptr< child > spawn_files(
+ static std::unique_ptr< child > spawn_files(
const fs::path&, const args_vector&, const fs::path&, const fs::path&);
int pid(void) const;
diff --git a/contrib/kyua/utils/process/child.ipp b/contrib/kyua/utils/process/child.ipp
index aa90373652fd..beb2ea3b0b0a 100644
--- a/contrib/kyua/utils/process/child.ipp
+++ b/contrib/kyua/utils/process/child.ipp
@@ -52,11 +52,11 @@ namespace process {
/// \throw process::system_error If the process cannot be spawned due to a
/// system call error.
template< typename Hook >
-std::auto_ptr< child >
+std::unique_ptr< child >
child::fork_files(Hook hook, const fs::path& stdout_file,
const fs::path& stderr_file)
{
- std::auto_ptr< child > child = fork_files_aux(stdout_file, stderr_file);
+ std::unique_ptr< child > child = fork_files_aux(stdout_file, stderr_file);
if (child.get() == NULL) {
try {
hook();
@@ -85,10 +85,10 @@ child::fork_files(Hook hook, const fs::path& stdout_file,
/// \throw process::system_error If the process cannot be spawned due to a
/// system call error.
template< typename Hook >
-std::auto_ptr< child >
+std::unique_ptr< child >
child::fork_capture(Hook hook)
{
- std::auto_ptr< child > child = fork_capture_aux();
+ std::unique_ptr< child > child = fork_capture_aux();
if (child.get() == NULL) {
try {
hook();
diff --git a/contrib/kyua/utils/process/child_test.cpp b/contrib/kyua/utils/process/child_test.cpp
index 69de9991ae13..68911ae04660 100644
--- a/contrib/kyua/utils/process/child_test.cpp
+++ b/contrib/kyua/utils/process/child_test.cpp
@@ -292,7 +292,7 @@ do_inherit_test(const char* fork_stdout, const char* fork_stderr,
::close(fd);
}
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_simple_function< 123, 'Z' >,
fs::path(fork_stdout), fs::path(fork_stderr));
const process::status status = child->wait();
@@ -323,7 +323,7 @@ child__fork_capture__ok(Hook hook)
{
std::cout << "This unflushed message should not propagate to the child";
std::cerr << "This unflushed message should not propagate to the child";
- std::auto_ptr< process::child > child = process::child::fork_capture(hook);
+ std::unique_ptr< process::child > child = process::child::fork_capture(hook);
std::cout.flush();
std::cerr.flush();
@@ -365,7 +365,7 @@ ATF_TEST_CASE_BODY(child__fork_capture__ok_functor)
ATF_TEST_CASE_WITHOUT_HEAD(child__fork_capture__catch_exceptions);
ATF_TEST_CASE_BODY(child__fork_capture__catch_exceptions)
{
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_throw_exception);
std::string message;
@@ -383,7 +383,7 @@ ATF_TEST_CASE_BODY(child__fork_capture__catch_exceptions)
ATF_TEST_CASE_WITHOUT_HEAD(child__fork_capture__new_session);
ATF_TEST_CASE_BODY(child__fork_capture__new_session)
{
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_check_own_session);
const process::status status = child->wait();
ATF_REQUIRE(status.exited());
@@ -411,7 +411,7 @@ ATF_TEST_CASE_BODY(child__fork_capture__fork_cannot_exit)
const pid_t parent_pid = ::getpid();
atf::utils::create_file("to-not-be-deleted", "");
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_return);
if (::getpid() != parent_pid) {
// If we enter this clause, it is because the hook returned.
@@ -431,7 +431,7 @@ ATF_TEST_CASE_BODY(child__fork_capture__fork_cannot_unwind)
const pid_t parent_pid = ::getpid();
atf::utils::create_file("to-not-be-deleted", "");
try {
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_raise_exception< int, 123 >);
const process::status status = child->wait();
ATF_REQUIRE(status.signaled());
@@ -467,7 +467,7 @@ ATF_TEST_CASE_BODY(child__fork_files__ok_function)
const fs::path file1("file1.txt");
const fs::path file2("file2.txt");
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_simple_function< 15, 'Z' >, file1, file2);
const process::status status = child->wait();
ATF_REQUIRE(status.exited());
@@ -490,7 +490,7 @@ ATF_TEST_CASE_BODY(child__fork_files__ok_functor)
atf::utils::create_file(filea.str(), "Initial stdout\n");
atf::utils::create_file(fileb.str(), "Initial stderr\n");
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_simple_functor(16, "a functor"), filea, fileb);
const process::status status = child->wait();
ATF_REQUIRE(status.exited());
@@ -513,7 +513,7 @@ ATF_TEST_CASE_BODY(child__fork_files__ok_functor)
ATF_TEST_CASE_WITHOUT_HEAD(child__fork_files__catch_exceptions);
ATF_TEST_CASE_BODY(child__fork_files__catch_exceptions)
{
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_throw_exception,
fs::path("unused.out"), fs::path("stderr"));
@@ -528,7 +528,7 @@ ATF_TEST_CASE_BODY(child__fork_files__catch_exceptions)
ATF_TEST_CASE_WITHOUT_HEAD(child__fork_files__new_session);
ATF_TEST_CASE_BODY(child__fork_files__new_session)
{
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_check_own_session,
fs::path("unused.out"), fs::path("unused.err"));
const process::status status = child->wait();
@@ -557,7 +557,7 @@ ATF_TEST_CASE_BODY(child__fork_files__fork_cannot_exit)
const pid_t parent_pid = ::getpid();
atf::utils::create_file("to-not-be-deleted", "");
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_return, fs::path("out"), fs::path("err"));
if (::getpid() != parent_pid) {
// If we enter this clause, it is because the hook returned.
@@ -577,7 +577,7 @@ ATF_TEST_CASE_BODY(child__fork_files__fork_cannot_unwind)
const pid_t parent_pid = ::getpid();
atf::utils::create_file("to-not-be-deleted", "");
try {
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_raise_exception< int, 123 >, fs::path("out"),
fs::path("err"));
const process::status status = child->wait();
@@ -615,7 +615,7 @@ ATF_TEST_CASE_WITHOUT_HEAD(child__fork_files__create_stdout_fail);
ATF_TEST_CASE_BODY(child__fork_files__create_stdout_fail)
{
process::detail::syscall_open = open_fail< ENOENT >;
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_simple_function< 1, 'A' >, fs::path("raise-error"),
fs::path("created"));
const process::status status = child->wait();
@@ -630,7 +630,7 @@ ATF_TEST_CASE_WITHOUT_HEAD(child__fork_files__create_stderr_fail);
ATF_TEST_CASE_BODY(child__fork_files__create_stderr_fail)
{
process::detail::syscall_open = open_fail< ENOENT >;
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_simple_function< 1, 'A' >, fs::path("created"),
fs::path("raise-error"));
const process::status status = child->wait();
@@ -650,7 +650,7 @@ ATF_TEST_CASE_BODY(child__spawn__absolute_path)
const fs::path program = get_helpers(this);
INV(program.is_absolute());
- std::auto_ptr< process::child > child = process::child::spawn_files(
+ std::unique_ptr< process::child > child = process::child::spawn_files(
program, args, fs::path("out"), fs::path("err"));
const process::status status = child->wait();
@@ -669,7 +669,7 @@ ATF_TEST_CASE_BODY(child__spawn__relative_path)
ATF_REQUIRE(::mkdir("root", 0755) != -1);
ATF_REQUIRE(::symlink(get_helpers(this).c_str(), "root/helpers") != -1);
- std::auto_ptr< process::child > child = process::child::spawn_files(
+ std::unique_ptr< process::child > child = process::child::spawn_files(
fs::path("root/helpers"), args, fs::path("out"), fs::path("err"));
const process::status status = child->wait();
@@ -687,7 +687,7 @@ ATF_TEST_CASE_BODY(child__spawn__basename_only)
ATF_REQUIRE(::symlink(get_helpers(this).c_str(), "helpers") != -1);
- std::auto_ptr< process::child > child = process::child::spawn_files(
+ std::unique_ptr< process::child > child = process::child::spawn_files(
fs::path("helpers"), args, fs::path("out"), fs::path("err"));
const process::status status = child->wait();
@@ -707,7 +707,7 @@ ATF_TEST_CASE_BODY(child__spawn__no_path)
const fs::path helpers = get_helpers(this);
utils::setenv("PATH", helpers.branch_path().c_str());
- std::auto_ptr< process::child > child = process::child::spawn_capture(
+ std::unique_ptr< process::child > child = process::child::spawn_capture(
fs::path(helpers.leaf_name()), args);
std::string line;
@@ -725,7 +725,7 @@ ATF_TEST_CASE_WITHOUT_HEAD(child__spawn__no_args);
ATF_TEST_CASE_BODY(child__spawn__no_args)
{
std::vector< std::string > args;
- std::auto_ptr< process::child > child = process::child::spawn_capture(
+ std::unique_ptr< process::child > child = process::child::spawn_capture(
get_helpers(this), args);
std::string line;
@@ -746,7 +746,7 @@ ATF_TEST_CASE_BODY(child__spawn__some_args)
args.push_back("print-args");
args.push_back("foo");
args.push_back(" bar baz ");
- std::auto_ptr< process::child > child = process::child::spawn_capture(
+ std::unique_ptr< process::child > child = process::child::spawn_capture(
get_helpers(this), args);
std::string line;
@@ -772,7 +772,7 @@ ATF_TEST_CASE_WITHOUT_HEAD(child__spawn__missing_program);
ATF_TEST_CASE_BODY(child__spawn__missing_program)
{
std::vector< std::string > args;
- std::auto_ptr< process::child > child = process::child::spawn_capture(
+ std::unique_ptr< process::child > child = process::child::spawn_capture(
fs::path("a/b/c"), args);
std::string line;
@@ -790,7 +790,7 @@ ATF_TEST_CASE_BODY(child__spawn__missing_program)
ATF_TEST_CASE_WITHOUT_HEAD(child__pid);
ATF_TEST_CASE_BODY(child__pid)
{
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_write_pid);
const int pid = child->pid();
diff --git a/contrib/kyua/utils/process/deadline_killer_test.cpp b/contrib/kyua/utils/process/deadline_killer_test.cpp
index 06c89660ac31..56ac31d3dda0 100644
--- a/contrib/kyua/utils/process/deadline_killer_test.cpp
+++ b/contrib/kyua/utils/process/deadline_killer_test.cpp
@@ -66,7 +66,7 @@ child_sleep(void)
ATF_TEST_CASE_WITHOUT_HEAD(activation);
ATF_TEST_CASE_BODY(activation)
{
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_sleep< 60 >);
datetime::timestamp start = datetime::timestamp::now();
@@ -85,7 +85,7 @@ ATF_TEST_CASE_BODY(activation)
ATF_TEST_CASE_WITHOUT_HEAD(no_activation);
ATF_TEST_CASE_BODY(no_activation)
{
- std::auto_ptr< process::child > child = process::child::fork_capture(
+ std::unique_ptr< process::child > child = process::child::fork_capture(
child_sleep< 1 >);
datetime::timestamp start = datetime::timestamp::now();
diff --git a/contrib/kyua/utils/process/executor.cpp b/contrib/kyua/utils/process/executor.cpp
index b73a86b9c1b9..843c9d862304 100644
--- a/contrib/kyua/utils/process/executor.cpp
+++ b/contrib/kyua/utils/process/executor.cpp
@@ -541,10 +541,10 @@ struct utils::process::executor::executor_handle::impl : utils::noncopyable {
size_t last_subprocess;
/// Interrupts handler.
- std::auto_ptr< signals::interrupts_handler > interrupts_handler;
+ std::unique_ptr< signals::interrupts_handler > interrupts_handler;
/// Root work directory for all executed subprocesses.
- std::auto_ptr< fs::auto_directory > root_work_directory;
+ std::unique_ptr< fs::auto_directory > root_work_directory;
/// Mapping of PIDs to the data required at run time.
exec_handles_map all_exec_handles;
@@ -807,7 +807,7 @@ executor::executor_handle::spawn_post(
const fs::path& stderr_file,
const datetime::delta& timeout,
const optional< passwd::user > unprivileged_user,
- std::auto_ptr< process::child > child)
+ std::unique_ptr< process::child > child)
{
const exec_handle handle(std::shared_ptr< exec_handle::impl >(
new exec_handle::impl(
@@ -853,7 +853,7 @@ executor::exec_handle
executor::executor_handle::spawn_followup_post(
const exit_handle& base,
const datetime::delta& timeout,
- std::auto_ptr< process::child > child)
+ std::unique_ptr< process::child > child)
{
INV(*base.state_owners() > 0);
const exec_handle handle(std::shared_ptr< exec_handle::impl >(
diff --git a/contrib/kyua/utils/process/executor.hpp b/contrib/kyua/utils/process/executor.hpp
index 01a17ff8c681..efc541d304b3 100644
--- a/contrib/kyua/utils/process/executor.hpp
+++ b/contrib/kyua/utils/process/executor.hpp
@@ -187,12 +187,12 @@ class executor_handle {
const utils::fs::path&,
const utils::datetime::delta&,
const utils::optional< utils::passwd::user >,
- std::auto_ptr< utils::process::child >);
+ std::unique_ptr< utils::process::child >);
void spawn_followup_pre(void);
exec_handle spawn_followup_post(const exit_handle&,
const utils::datetime::delta&,
- std::auto_ptr< utils::process::child >);
+ std::unique_ptr< utils::process::child >);
public:
~executor_handle(void);
diff --git a/contrib/kyua/utils/process/executor.ipp b/contrib/kyua/utils/process/executor.ipp
index e91f994673d7..0fc8cd943da5 100644
--- a/contrib/kyua/utils/process/executor.ipp
+++ b/contrib/kyua/utils/process/executor.ipp
@@ -129,7 +129,7 @@ executor::executor_handle::spawn(
const fs::path stderr_path = stderr_target ?
stderr_target.get() : (unique_work_directory / detail::stderr_name);
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
detail::run_child< Hook >(hook,
unique_work_directory,
unique_work_directory / detail::work_subdir,
@@ -137,7 +137,7 @@ executor::executor_handle::spawn(
stdout_path, stderr_path);
return spawn_post(unique_work_directory, stdout_path, stderr_path,
- timeout, unprivileged_user, child);
+ timeout, unprivileged_user, std::move(child));
}
@@ -165,14 +165,14 @@ executor::executor_handle::spawn_followup(Hook hook,
{
spawn_followup_pre();
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
detail::run_child< Hook >(hook,
base.control_directory(),
base.work_directory(),
base.unprivileged_user()),
base.stdout_file(), base.stderr_file());
- return spawn_followup_post(base, timeout, child);
+ return spawn_followup_post(base, timeout, std::move(child));
}
diff --git a/contrib/kyua/utils/process/fdstream.hpp b/contrib/kyua/utils/process/fdstream.hpp
index e785b0ac4282..bfcb16ec439e 100644
--- a/contrib/kyua/utils/process/fdstream.hpp
+++ b/contrib/kyua/utils/process/fdstream.hpp
@@ -52,7 +52,7 @@ class ifdstream : public std::istream, noncopyable
struct impl;
/// Pointer to the shared internal implementation.
- std::auto_ptr< impl > _pimpl;
+ std::unique_ptr< impl > _pimpl;
public:
explicit ifdstream(const int);
diff --git a/contrib/kyua/utils/process/isolation_test.cpp b/contrib/kyua/utils/process/isolation_test.cpp
index dc723cc65c88..44aa4729d51c 100644
--- a/contrib/kyua/utils/process/isolation_test.cpp
+++ b/contrib/kyua/utils/process/isolation_test.cpp
@@ -78,7 +78,7 @@ template< typename Hook >
static process::status
fork_and_run(Hook hook)
{
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
hook, fs::path("subprocess.stdout"), fs::path("subprocess.stderr"));
const process::status status = child->wait();
diff --git a/contrib/kyua/utils/process/operations_test.cpp b/contrib/kyua/utils/process/operations_test.cpp
index e9c1ebb65a3d..d30dc890abd2 100644
--- a/contrib/kyua/utils/process/operations_test.cpp
+++ b/contrib/kyua/utils/process/operations_test.cpp
@@ -161,7 +161,7 @@ write_loop(const int fd)
static void
check_exec_no_args(const atf::tests::tc* tc, const exec_function do_exec)
{
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_exec(do_exec, get_helpers(tc), process::args_vector()),
fs::path("stdout"), fs::path("stderr"));
const process::status status = child->wait();
@@ -183,7 +183,7 @@ check_exec_some_args(const atf::tests::tc* tc, const exec_function do_exec)
args.push_back("foo");
args.push_back("bar");
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_exec(do_exec, get_helpers(tc), args),
fs::path("stdout"), fs::path("stderr"));
const process::status status = child->wait();
@@ -214,7 +214,7 @@ ATF_TEST_CASE_BODY(exec__fail)
{
utils::avoid_coredump_on_crash();
- std::auto_ptr< process::child > child = process::child::fork_files(
+ std::unique_ptr< process::child > child = process::child::fork_files(
child_exec(process::exec, fs::path("non-existent"),
*** 228 LINES SKIPPED ***