From 3d69f0df961b8a79d247ca91dc272c60e504b538 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 20 Dec 2018 09:44:06 -0800 Subject: Clean up the arg setup for exec(3). Test: Build and boot into recovery on marlin. Factory reset. Test: Build and install a non-A/B OTA that calls format. Change-Id: I72416e775e237fc15ca5eff1036175a9eef43b76 --- roots.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'roots.cpp') diff --git a/roots.cpp b/roots.cpp index e988da0a8..6db0ca519 100644 --- a/roots.cpp +++ b/roots.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -44,6 +43,7 @@ #include #include "otautil/mounts.h" +#include "otautil/sysutil.h" static Fstab fstab; @@ -90,12 +90,8 @@ int ensure_path_unmounted(const std::string& path) { } static int exec_cmd(const std::vector& args) { - CHECK_NE(static_cast(0), args.size()); - - std::vector argv(args.size()); - std::transform(args.cbegin(), args.cend(), argv.begin(), - [](const std::string& arg) { return const_cast(arg.c_str()); }); - argv.push_back(nullptr); + CHECK(!args.empty()); + auto argv = StringVectorToNullTerminatedArray(args); pid_t child; if ((child = fork()) == 0) { -- cgit v1.2.3