summaryrefslogtreecommitdiff
path: root/init/service_parser.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2019-07-31 13:59:15 -0700
committerTom Cherry <tomcherry@google.com>2019-08-01 10:34:58 -0700
commitc5cf85db23ac8c8a0206e911d73ef1c42ad66ed6 (patch)
tree5e940c776939c3d175bf50cbbd1ea92d5840d39a /init/service_parser.cpp
parent244d9b8fb968b9f0289ac69d723a4f760d1c1b91 (diff)
init: don't log in expand_props directly
It's better to pass the error message to the caller to determine how best to print the error. Test: build Change-Id: Id8857c459df2f26c031650166609608d20e4d051
Diffstat (limited to 'init/service_parser.cpp')
-rw-r--r--init/service_parser.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/init/service_parser.cpp b/init/service_parser.cpp
index 65d96c665..e45e80415 100644
--- a/init/service_parser.cpp
+++ b/init/service_parser.cpp
@@ -193,9 +193,9 @@ Result<void> ServiceParser::ParseIoprio(std::vector<std::string>&& args) {
Result<void> ServiceParser::ParseKeycodes(std::vector<std::string>&& args) {
auto it = args.begin() + 1;
if (args.size() == 2 && StartsWith(args[1], "$")) {
- std::string expanded;
- if (!expand_props(args[1], &expanded)) {
- return Error() << "Could not expand property '" << args[1] << "'";
+ auto expanded = ExpandProps(args[1]);
+ if (!expanded) {
+ return expanded.error();
}
// If the property is not set, it defaults to none, in which case there are no keycodes
@@ -204,7 +204,7 @@ Result<void> ServiceParser::ParseKeycodes(std::vector<std::string>&& args) {
return {};
}
- args = Split(expanded, ",");
+ args = Split(*expanded, ",");
it = args.begin();
}
@@ -422,9 +422,11 @@ Result<void> ServiceParser::ParseFile(std::vector<std::string>&& args) {
FileDescriptor file;
file.type = args[2];
- if (!expand_props(args[1], &file.name)) {
- return Error() << "Could not expand property in file path '" << args[1] << "'";
+ auto file_name = ExpandProps(args[1]);
+ if (!file_name) {
+ return Error() << "Could not expand file path ': " << file_name.error();
}
+ file.name = *file_name;
if (file.name[0] != '/' || file.name.find("../") != std::string::npos) {
return Error() << "file name must not be relative";
}