diff options
author | Tao Bao <tbao@google.com> | 2018-07-10 18:50:33 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-07-10 18:50:33 +0200 |
commit | d8a2c2682a87dcd0d77708333a46a0472b403c9b (patch) | |
tree | 28768203f70081c7d5a76e872618ac0da67b735d /updater | |
parent | Merge "applypatch: Restrict applypatch_check to eMMC targets." (diff) | |
parent | Merge "edify: Remove VAL_INVALID and move ValueType into Value class." (diff) | |
download | android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.tar android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.tar.gz android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.tar.bz2 android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.tar.lz android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.tar.xz android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.tar.zst android_bootable_recovery-d8a2c2682a87dcd0d77708333a46a0472b403c9b.zip |
Diffstat (limited to 'updater')
-rw-r--r-- | updater/blockimg.cpp | 21 | ||||
-rw-r--r-- | updater/install.cpp | 22 |
2 files changed, 22 insertions, 21 deletions
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index fc713859b..6a6236b1b 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1403,7 +1403,8 @@ static int PerformCommandDiff(CommandParameters& params) { if (status == 0) { LOG(INFO) << "patching " << blocks << " blocks to " << tgt.blocks(); Value patch_value( - VAL_BLOB, std::string(reinterpret_cast<const char*>(params.patch_start + offset), len)); + Value::Type::BLOB, + std::string(reinterpret_cast<const char*>(params.patch_start + offset), len)); RangeSinkWriter writer(params.fd, tgt); if (params.cmdname[0] == 'i') { // imgdiff @@ -1531,19 +1532,19 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, const std::unique_ptr<Value>& new_data_fn = args[2]; const std::unique_ptr<Value>& patch_data_fn = args[3]; - if (blockdev_filename->type != VAL_STRING) { + if (blockdev_filename->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "blockdev_filename argument to %s must be string", name); return StringValue(""); } - if (transfer_list_value->type != VAL_BLOB) { + if (transfer_list_value->type != Value::Type::BLOB) { ErrorAbort(state, kArgsParsingFailure, "transfer_list argument to %s must be blob", name); return StringValue(""); } - if (new_data_fn->type != VAL_STRING) { + if (new_data_fn->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "new_data_fn argument to %s must be string", name); return StringValue(""); } - if (patch_data_fn->type != VAL_STRING) { + if (patch_data_fn->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "patch_data_fn argument to %s must be string", name); return StringValue(""); } @@ -1944,11 +1945,11 @@ Value* RangeSha1Fn(const char* name, State* state, const std::vector<std::unique const std::unique_ptr<Value>& blockdev_filename = args[0]; const std::unique_ptr<Value>& ranges = args[1]; - if (blockdev_filename->type != VAL_STRING) { + if (blockdev_filename->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "blockdev_filename argument to %s must be string", name); return StringValue(""); } - if (ranges->type != VAL_STRING) { + if (ranges->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "ranges argument to %s must be string", name); return StringValue(""); } @@ -2010,7 +2011,7 @@ Value* CheckFirstBlockFn(const char* name, State* state, const std::unique_ptr<Value>& arg_filename = args[0]; - if (arg_filename->type != VAL_STRING) { + if (arg_filename->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "filename argument to %s must be string", name); return StringValue(""); } @@ -2065,11 +2066,11 @@ Value* BlockImageRecoverFn(const char* name, State* state, const std::unique_ptr<Value>& filename = args[0]; const std::unique_ptr<Value>& ranges = args[1]; - if (filename->type != VAL_STRING) { + if (filename->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "filename argument to %s must be string", name); return StringValue(""); } - if (ranges->type != VAL_STRING) { + if (ranges->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "ranges argument to %s must be string", name); return StringValue(""); } diff --git a/updater/install.cpp b/updater/install.cpp index 5ebdab49d..75e805224 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -191,7 +191,7 @@ Value* PackageExtractFileFn(const char* name, State* state, zip_path.c_str(), buffer.size(), ErrorCodeString(ret)); } - return new Value(VAL_BLOB, buffer); + return new Value(Value::Type::BLOB, buffer); } } @@ -238,10 +238,10 @@ Value* ApplyPatchFn(const char* name, State* state, } for (int i = 0; i < patchcount; ++i) { - if (arg_values[i * 2]->type != VAL_STRING) { + if (arg_values[i * 2]->type != Value::Type::STRING) { return ErrorAbort(state, kArgsParsingFailure, "%s(): sha-1 #%d is not string", name, i * 2); } - if (arg_values[i * 2 + 1]->type != VAL_BLOB) { + if (arg_values[i * 2 + 1]->type != Value::Type::BLOB) { return ErrorAbort(state, kArgsParsingFailure, "%s(): patch #%d is not blob", name, i * 2 + 1); } } @@ -739,8 +739,8 @@ Value* RunProgramFn(const char* name, State* state, const std::vector<std::uniqu return StringValue(std::to_string(status)); } -// Read a local file and return its contents (the Value* returned -// is actually a FileContents*). +// read_file(filename) +// Reads a local file 'filename' and returns its contents as a Value string. Value* ReadFileFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { if (argv.size() != 1) { return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size()); @@ -748,18 +748,18 @@ Value* ReadFileFn(const char* name, State* state, const std::vector<std::unique_ std::vector<std::string> args; if (!ReadArgs(state, argv, &args)) { - return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name); + return ErrorAbort(state, kArgsParsingFailure, "%s(): Failed to parse the argument(s)", name); } const std::string& filename = args[0]; - Value* v = new Value(VAL_INVALID, ""); - FileContents fc; if (LoadFileContents(filename.c_str(), &fc) == 0) { - v->type = VAL_BLOB; - v->data = std::string(fc.data.begin(), fc.data.end()); + return new Value(Value::Type::BLOB, std::string(fc.data.cbegin(), fc.data.cend())); } - return v; + + // Leave it to caller to handle the failure. + LOG(ERROR) << name << ": Failed to read " << filename; + return StringValue(""); } // write_value(value, filename) |