diff options
author | Wei Wang <wvw@google.com> | 2016-11-16 19:19:49 -0800 |
---|---|---|
committer | Wei Wang <wvw@google.com> | 2016-11-16 22:24:43 -0800 |
commit | 93df4e18a255262595acb862ab870e9fed721fb8 (patch) | |
tree | d6358f49fc8da2802f1ae93812df199efefb979e /init/action.cpp | |
parent | d67a4abc647d5ed7235ff7ee1695b31340e63a1c (diff) | |
download | core-93df4e18a255262595acb862ab870e9fed721fb8.tar.gz core-93df4e18a255262595acb862ab870e9fed721fb8.tar.bz2 core-93df4e18a255262595acb862ab870e9fed721fb8.zip |
init: move empty string check to InitTriggers
Test: mma
Bug: 32838381
Change-Id: I69203734ef7d3640da75f3e3cbe9254bf468d916
Diffstat (limited to 'init/action.cpp')
-rw-r--r-- | init/action.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/init/action.cpp b/init/action.cpp index acbb12e8e..0ea7e1479 100644 --- a/init/action.cpp +++ b/init/action.cpp @@ -157,6 +157,11 @@ bool Action::ParsePropertyTrigger(const std::string& trigger, std::string* err) bool Action::InitTriggers(const std::vector<std::string>& args, std::string* err) { const static std::string prop_str("property:"); for (std::size_t i = 0; i < args.size(); ++i) { + if (args[i].empty()) { + *err = "empty trigger is not valid"; + return false; + } + if (i % 2) { if (args[i] != "&&") { *err = "&& is the only symbol allowed to concatenate actions"; @@ -186,7 +191,11 @@ bool Action::InitTriggers(const std::vector<std::string>& args, std::string* err bool Action::InitSingleTrigger(const std::string& trigger) { std::vector<std::string> name_vector{trigger}; std::string err; - return InitTriggers(name_vector, &err); + bool ret = InitTriggers(name_vector, &err); + if (!ret) { + LOG(ERROR) << "InitSingleTrigger failed due to: " << err; + } + return ret; } // This function checks that all property triggers are satisfied, that is @@ -252,9 +261,7 @@ std::string Action::BuildTriggersString() const { result += event_trigger_; result += ' '; } - if (!result.empty()) { - result.pop_back(); - } + result.pop_back(); return result; } |