Loading init/keychords_test.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ #include <vector> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <gtest/gtest.h> Loading init/keyword_map.h +8 −15 Original line number Diff line number Diff line Loading @@ -14,14 +14,11 @@ * limitations under the License. */ #ifndef _INIT_KEYWORD_MAP_H_ #define _INIT_KEYWORD_MAP_H_ #pragma once #include <map> #include <string> #include <android-base/stringprintf.h> #include "result.h" namespace android { Loading @@ -37,8 +34,6 @@ class KeywordMap { } const Result<Function> FindFunction(const std::vector<std::string>& args) const { using android::base::StringPrintf; if (args.empty()) return Error() << "Keyword needed, but not provided"; auto& keyword = args[0]; Loading @@ -46,7 +41,7 @@ class KeywordMap { auto function_info_it = map().find(keyword); if (function_info_it == map().end()) { return Error() << StringPrintf("Invalid keyword '%s'", keyword.c_str()); return Errorf("Invalid keyword '{}'", keyword); } auto function_info = function_info_it->second; Loading @@ -54,17 +49,17 @@ class KeywordMap { auto min_args = std::get<0>(function_info); auto max_args = std::get<1>(function_info); if (min_args == max_args && num_args != min_args) { return Error() << StringPrintf("%s requires %zu argument%s", keyword.c_str(), min_args, return Errorf("{} requires {} argument{}", keyword, min_args, (min_args > 1 || min_args == 0) ? "s" : ""); } if (num_args < min_args || num_args > max_args) { if (max_args == std::numeric_limits<decltype(max_args)>::max()) { return Error() << StringPrintf("%s requires at least %zu argument%s", keyword.c_str(), min_args, min_args > 1 ? "s" : ""); return Errorf("{} requires at least {} argument{}", keyword, min_args, min_args > 1 ? "s" : ""); } else { return Error() << StringPrintf("%s requires between %zu and %zu arguments", keyword.c_str(), min_args, max_args); return Errorf("{} requires between {} and {} arguments", keyword, min_args, max_args); } } Loading @@ -79,5 +74,3 @@ class KeywordMap { } // namespace init } // namespace android #endif init/reboot.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <android-base/logging.h> #include <android-base/macros.h> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <bootloader_message/bootloader_message.h> Loading @@ -62,7 +61,6 @@ using android::base::GetBoolProperty; using android::base::Split; using android::base::StringPrintf; using android::base::Timer; using android::base::unique_fd; using android::base::WriteStringToFile; Loading init/result.h +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <android-base/result.h> using android::base::ErrnoError; using android::base::ErrnoErrorf; using android::base::Error; using android::base::Errorf; using android::base::Result; using android::base::ResultError; init/service.cpp +4 −5 Original line number Diff line number Diff line Loading @@ -332,12 +332,11 @@ Result<void> Service::ParseCapabilities(std::vector<std::string>&& args) { const std::string& arg = args[i]; int res = LookupCap(arg); if (res < 0) { return Error() << StringPrintf("invalid capability '%s'", arg.c_str()); return Errorf("invalid capability '{}'", arg); } unsigned int cap = static_cast<unsigned int>(res); // |res| is >= 0. if (cap > last_valid_cap) { return Error() << StringPrintf("capability '%s' not supported by the kernel", arg.c_str()); return Errorf("capability '{}' not supported by the kernel", arg); } (*capabilities_)[cap] = true; } Loading Loading @@ -402,8 +401,8 @@ Result<void> Service::ParsePriority(std::vector<std::string>&& args) { if (!ParseInt(args[1], &proc_attr_.priority, static_cast<int>(ANDROID_PRIORITY_HIGHEST), // highest is negative static_cast<int>(ANDROID_PRIORITY_LOWEST))) { return Error() << StringPrintf("process priority value must be range %d - %d", ANDROID_PRIORITY_HIGHEST, ANDROID_PRIORITY_LOWEST); return Errorf("process priority value must be range {} - {}", ANDROID_PRIORITY_HIGHEST, ANDROID_PRIORITY_LOWEST); } return {}; } Loading Loading
init/keychords_test.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ #include <vector> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <gtest/gtest.h> Loading
init/keyword_map.h +8 −15 Original line number Diff line number Diff line Loading @@ -14,14 +14,11 @@ * limitations under the License. */ #ifndef _INIT_KEYWORD_MAP_H_ #define _INIT_KEYWORD_MAP_H_ #pragma once #include <map> #include <string> #include <android-base/stringprintf.h> #include "result.h" namespace android { Loading @@ -37,8 +34,6 @@ class KeywordMap { } const Result<Function> FindFunction(const std::vector<std::string>& args) const { using android::base::StringPrintf; if (args.empty()) return Error() << "Keyword needed, but not provided"; auto& keyword = args[0]; Loading @@ -46,7 +41,7 @@ class KeywordMap { auto function_info_it = map().find(keyword); if (function_info_it == map().end()) { return Error() << StringPrintf("Invalid keyword '%s'", keyword.c_str()); return Errorf("Invalid keyword '{}'", keyword); } auto function_info = function_info_it->second; Loading @@ -54,17 +49,17 @@ class KeywordMap { auto min_args = std::get<0>(function_info); auto max_args = std::get<1>(function_info); if (min_args == max_args && num_args != min_args) { return Error() << StringPrintf("%s requires %zu argument%s", keyword.c_str(), min_args, return Errorf("{} requires {} argument{}", keyword, min_args, (min_args > 1 || min_args == 0) ? "s" : ""); } if (num_args < min_args || num_args > max_args) { if (max_args == std::numeric_limits<decltype(max_args)>::max()) { return Error() << StringPrintf("%s requires at least %zu argument%s", keyword.c_str(), min_args, min_args > 1 ? "s" : ""); return Errorf("{} requires at least {} argument{}", keyword, min_args, min_args > 1 ? "s" : ""); } else { return Error() << StringPrintf("%s requires between %zu and %zu arguments", keyword.c_str(), min_args, max_args); return Errorf("{} requires between {} and {} arguments", keyword, min_args, max_args); } } Loading @@ -79,5 +74,3 @@ class KeywordMap { } // namespace init } // namespace android #endif
init/reboot.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <android-base/logging.h> #include <android-base/macros.h> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <bootloader_message/bootloader_message.h> Loading @@ -62,7 +61,6 @@ using android::base::GetBoolProperty; using android::base::Split; using android::base::StringPrintf; using android::base::Timer; using android::base::unique_fd; using android::base::WriteStringToFile; Loading
init/result.h +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <android-base/result.h> using android::base::ErrnoError; using android::base::ErrnoErrorf; using android::base::Error; using android::base::Errorf; using android::base::Result; using android::base::ResultError;
init/service.cpp +4 −5 Original line number Diff line number Diff line Loading @@ -332,12 +332,11 @@ Result<void> Service::ParseCapabilities(std::vector<std::string>&& args) { const std::string& arg = args[i]; int res = LookupCap(arg); if (res < 0) { return Error() << StringPrintf("invalid capability '%s'", arg.c_str()); return Errorf("invalid capability '{}'", arg); } unsigned int cap = static_cast<unsigned int>(res); // |res| is >= 0. if (cap > last_valid_cap) { return Error() << StringPrintf("capability '%s' not supported by the kernel", arg.c_str()); return Errorf("capability '{}' not supported by the kernel", arg); } (*capabilities_)[cap] = true; } Loading Loading @@ -402,8 +401,8 @@ Result<void> Service::ParsePriority(std::vector<std::string>&& args) { if (!ParseInt(args[1], &proc_attr_.priority, static_cast<int>(ANDROID_PRIORITY_HIGHEST), // highest is negative static_cast<int>(ANDROID_PRIORITY_LOWEST))) { return Error() << StringPrintf("process priority value must be range %d - %d", ANDROID_PRIORITY_HIGHEST, ANDROID_PRIORITY_LOWEST); return Errorf("process priority value must be range {} - {}", ANDROID_PRIORITY_HIGHEST, ANDROID_PRIORITY_LOWEST); } return {}; } Loading