From d81b8e3d775743dbc2ce49b805cbce6fcc0ea617 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 17 Dec 2018 14:29:06 -0800 Subject: roots.cpp: convert to C++ Fstab Convert code to use C++ Fstab struct and C++ std::strings. Bug: 62292478 Bug: 118634720 Test: boots Change-Id: Ibdc1df5831bc885d7c1574419f41af026e49a137 --- install.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'install.cpp') diff --git a/install.cpp b/install.cpp index 680937dd1..ce3d4f6ad 100644 --- a/install.cpp +++ b/install.cpp @@ -595,9 +595,9 @@ static int really_install_package(const std::string& path, bool* wipe_cache, boo if (needs_mount) { if (path[0] == '@') { - ensure_path_mounted(path.substr(1).c_str()); + ensure_path_mounted(path.substr(1)); } else { - ensure_path_mounted(path.c_str()); + ensure_path_mounted(path); } } -- cgit v1.2.3 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 --- install.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'install.cpp') diff --git a/install.cpp b/install.cpp index ce3d4f6ad..9d8943f7d 100644 --- a/install.cpp +++ b/install.cpp @@ -395,12 +395,8 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b // update attempt. // - // Convert the vector to a NULL-terminated char* array suitable for execv. - const char* chr_args[args.size() + 1]; - chr_args[args.size()] = nullptr; - for (size_t i = 0; i < args.size(); i++) { - chr_args[i] = args[i].c_str(); - } + // Convert the std::string vector to a NULL-terminated char* vector suitable for execv. + auto chr_args = StringVectorToNullTerminatedArray(args); pid_t pid = fork(); @@ -415,7 +411,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b if (pid == 0) { umask(022); close(pipefd[0]); - execv(chr_args[0], const_cast(chr_args)); + execv(chr_args[0], chr_args.data()); // Bug: 34769056 // We shouldn't use LOG/PLOG in the forked process, since they may cause // the child process to hang. This deadlock results from an improperly -- cgit v1.2.3