aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2018-01-28 17:37:48 -0600
committerTianjie Xu2018-01-29 13:42:59 -0600
commit5ad802839d84f7bcdfbb8aa5c48cb56b303ce5f0 (patch)
treeb52bbabcabdaa04949c90465f07d937328970d64 /edify/expr.cpp
parent80ccac2fffc09ef0b8a1fe43c096788e12359a1d (diff)
downloadplatform-bootable-recovery-5ad802839d84f7bcdfbb8aa5c48cb56b303ce5f0.tar.gz
platform-bootable-recovery-5ad802839d84f7bcdfbb8aa5c48cb56b303ce5f0.tar.xz
platform-bootable-recovery-5ad802839d84f7bcdfbb8aa5c48cb56b303ce5f0.zip
Avoid overwrite of the error message in AbortFn
The AbortFn() used to overwrite the error message, hiding the real failure reported in ErrorAbort(). And we will miss the failure in the script patterns like 'blockimageupdate() || abort()' We will ensure there's one line break at the end of ErrorAbort's error message; and append to the existing error message when calling abort(). Test: Message from ErrorAbort shows up in the log Change-Id: I3aebd06629c5129330250c7fe5e8cdead2ae85bc
Diffstat (limited to 'edify/expr.cpp')
-rw-r--r--edify/expr.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/edify/expr.cpp b/edify/expr.cpp
index 1b8623f0..6823b733 100644
--- a/edify/expr.cpp
+++ b/edify/expr.cpp
@@ -114,9 +114,9 @@ Value* IfElseFn(const char* name, State* state, const std::vector<std::unique_pt
114Value* AbortFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { 114Value* AbortFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
115 std::string msg; 115 std::string msg;
116 if (!argv.empty() && Evaluate(state, argv[0], &msg)) { 116 if (!argv.empty() && Evaluate(state, argv[0], &msg)) {
117 state->errmsg = msg; 117 state->errmsg += msg;
118 } else { 118 } else {
119 state->errmsg = "called abort()"; 119 state->errmsg += "called abort()";
120 } 120 }
121 return nullptr; 121 return nullptr;
122} 122}
@@ -410,12 +410,15 @@ Value* ErrorAbort(State* state, const char* format, ...) {
410} 410}
411 411
412Value* ErrorAbort(State* state, CauseCode cause_code, const char* format, ...) { 412Value* ErrorAbort(State* state, CauseCode cause_code, const char* format, ...) {
413 va_list ap; 413 std::string err_message;
414 va_start(ap, format); 414 va_list ap;
415 android::base::StringAppendV(&state->errmsg, format, ap); 415 va_start(ap, format);
416 va_end(ap); 416 android::base::StringAppendV(&err_message, format, ap);
417 state->cause_code = cause_code; 417 va_end(ap);
418 return nullptr; 418 // Ensure that there's exactly one line break at the end of the error message.
419 state->errmsg = android::base::Trim(err_message) + "\n";
420 state->cause_code = cause_code;
421 return nullptr;
419} 422}
420 423
421State::State(const std::string& script, void* cookie) 424State::State(const std::string& script, void* cookie)