Repository: mesos Updated Branches: refs/heads/master f9c2604ea -> de7fb43a0
Replaced C-style varargs for 'shell' with variadic templates. Review: https://reviews.apache.org/r/37968 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/de7fb43a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/de7fb43a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/de7fb43a Branch: refs/heads/master Commit: de7fb43a06ad57061dbd2c02b11c13be3e51fc05 Parents: f9c2604 Author: Guangya Liu <[email protected]> Authored: Thu Sep 10 00:24:58 2015 -0700 Committer: Michael Park <[email protected]> Committed: Thu Sep 10 00:31:07 2015 -0700 ---------------------------------------------------------------------- .../libprocess/3rdparty/stout/include/stout/format.hpp | 1 + .../3rdparty/stout/include/stout/os/posix/shell.hpp | 13 ++++--------- .../3rdparty/stout/include/stout/os/windows/shell.hpp | 3 ++- 3 files changed, 7 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/de7fb43a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp index 1cf6dd1..642bd4c 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp @@ -82,6 +82,7 @@ inline Try<std::string> format(const std::string& fmt, va_list args) // NOTE: 'fmt' cannot be 'const std::string&' because passing an // argument of reference type as the second argument of 'va_start' // results in undefined behavior. +// Refer to http://stackoverflow.com/a/222314 for further details. inline Try<std::string> format(const std::string fmt, ...) { va_list args; http://git-wip-us.apache.org/repos/asf/mesos/blob/de7fb43a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp index 68fc1fd..de45e16 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp @@ -45,20 +45,15 @@ namespace os { * * @param fmt the formatting string that contains the command to execute * in the underlying shell. - * @param varargs optional arguments for `fmt`. + * @param t optional arguments for `fmt`. * * @return the output from running the specified command with the shell; or * an error message if the command's exit code is non-zero. */ -inline Try<std::string> shell(const std::string fmt, ...) +template <typename... T> +Try<std::string> shell(const std::string& fmt, const T&... t) { - va_list args; - va_start(args, fmt); - - const Try<std::string> command = strings::internal::format(fmt, args); - - va_end(args); - + const Try<std::string> command = strings::internal::format(fmt, t...); if (command.isError()) { return Error(command.error()); } http://git-wip-us.apache.org/repos/asf/mesos/blob/de7fb43a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp index 01e59de..d402f17 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp @@ -27,7 +27,8 @@ namespace os { // Runs a shell command formatted with varargs and return the return value // of the command. Optionally, the output is returned via an argument. // TODO(vinod): Pass an istream object that can provide input to the command. -inline Try<std::string> shell(const std::string fmt, ...) +template <typename... T> +Try<std::string> shell(const std::string& fmt, const T&... t) { UNIMPLEMENTED; }
