Loading applypatch/applypatch.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -553,7 +553,7 @@ int applypatch_flash(const char* source_filename, const char* target_filename, static int GenerateTarget(const FileContents& source_file, const std::unique_ptr<Value>& patch, const std::string& target_filename, const uint8_t target_sha1[SHA_DIGEST_LENGTH], const Value* bonus_data) { if (patch->type != VAL_BLOB) { if (patch->type != Value::Type::BLOB) { LOG(ERROR) << "patch is not a blob"; return 1; } Loading applypatch/applypatch_modes.cpp +38 −39 Original line number Diff line number Diff line Loading @@ -81,16 +81,15 @@ static int FlashMode(const char* src_filename, const char* tgt_filename, } static int PatchMode(int argc, const char** argv) { FileContents bonusFc; Value bonus(VAL_INVALID, ""); std::unique_ptr<Value> bonus; if (argc >= 3 && strcmp(argv[1], "-b") == 0) { if (LoadFileContents(argv[2], &bonusFc) != 0) { FileContents bonus_fc; if (LoadFileContents(argv[2], &bonus_fc) != 0) { LOG(ERROR) << "Failed to load bonus file " << argv[2]; return 1; } bonus.type = VAL_BLOB; bonus.data = std::string(bonusFc.data.cbegin(), bonusFc.data.cend()); bonus = std::make_unique<Value>(Value::Type::BLOB, std::string(bonus_fc.data.cbegin(), bonus_fc.data.cend())); argc -= 2; argv += 2; } Loading @@ -107,7 +106,7 @@ static int PatchMode(int argc, const char** argv) { // If no <src-sha1>:<patch> is provided, it is in flash mode. if (argc == 5) { if (bonus.type != VAL_INVALID) { if (bonus) { LOG(ERROR) << "bonus file not supported in flash mode"; return 1; } Loading @@ -122,11 +121,11 @@ static int PatchMode(int argc, const char** argv) { } std::vector<std::unique_ptr<Value>> patches; for (size_t i = 0; i < files.size(); ++i) { patches.push_back(std::make_unique<Value>( VAL_BLOB, std::string(files[i].data.cbegin(), files[i].data.cend()))); for (const auto& file : files) { patches.push_back(std::make_unique<Value>(Value::Type::BLOB, std::string(file.data.cbegin(), file.data.cend()))); } return applypatch(argv[1], argv[2], argv[3], target_size, sha1s, patches, &bonus); return applypatch(argv[1], argv[2], argv[3], target_size, sha1s, patches, bonus.get()); } // This program (applypatch) applies binary patches to files in a way that Loading applypatch/imgpatch.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -151,7 +151,8 @@ static bool ApplyBSDiffPatchAndStreamOutput(const uint8_t* src_data, size_t src_ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const unsigned char* patch_data, size_t patch_size, SinkFn sink) { Value patch(VAL_BLOB, std::string(reinterpret_cast<const char*>(patch_data), patch_size)); Value patch(Value::Type::BLOB, std::string(reinterpret_cast<const char*>(patch_data), patch_size)); return ApplyImagePatch(old_data, old_size, patch, sink, nullptr); } Loading Loading @@ -246,11 +247,10 @@ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value& // Decompress the source data; the chunk header tells us exactly // how big we expect it to be when decompressed. // Note: expanded_len will include the bonus data size if // the patch was constructed with bonus data. The // deflation will come up 'bonus_size' bytes short; these // must be appended from the bonus_data value. size_t bonus_size = (i == 1 && bonus_data != NULL) ? bonus_data->data.size() : 0; // Note: expanded_len will include the bonus data size if the patch was constructed with // bonus data. The deflation will come up 'bonus_size' bytes short; these must be appended // from the bonus_data value. size_t bonus_size = (i == 1 && bonus_data != nullptr) ? bonus_data->data.size() : 0; std::vector<unsigned char> expanded_source(expanded_len); Loading Loading @@ -288,7 +288,7 @@ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value& inflateEnd(&strm); if (bonus_size) { memcpy(expanded_source.data() + (expanded_len - bonus_size), &bonus_data->data[0], memcpy(expanded_source.data() + (expanded_len - bonus_size), bonus_data->data.data(), bonus_size); } } Loading edify/expr.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ bool Evaluate(State* state, const std::unique_ptr<Expr>& expr, std::string* resu if (!v) { return false; } if (v->type != VAL_STRING) { if (v->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "expecting string, got value type %d", v->type); return false; } Loading @@ -68,7 +68,7 @@ Value* StringValue(const char* str) { if (str == nullptr) { return nullptr; } return new Value(VAL_STRING, str); return new Value(Value::Type::STRING, str); } Value* StringValue(const std::string& str) { Loading edify/include/edify/expr.h +8 −11 Original line number Diff line number Diff line Loading @@ -53,19 +53,16 @@ struct State { bool is_retry = false; }; enum ValueType { VAL_INVALID = -1, VAL_STRING = 1, VAL_BLOB = 2, struct Value { enum class Type { STRING = 1, BLOB = 2, }; struct Value { ValueType type; std::string data; Value(Type type, const std::string& str) : type(type), data(str) {} Value(ValueType type, const std::string& str) : type(type), data(str) {} Type type; std::string data; }; struct Expr; Loading Loading
applypatch/applypatch.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -553,7 +553,7 @@ int applypatch_flash(const char* source_filename, const char* target_filename, static int GenerateTarget(const FileContents& source_file, const std::unique_ptr<Value>& patch, const std::string& target_filename, const uint8_t target_sha1[SHA_DIGEST_LENGTH], const Value* bonus_data) { if (patch->type != VAL_BLOB) { if (patch->type != Value::Type::BLOB) { LOG(ERROR) << "patch is not a blob"; return 1; } Loading
applypatch/applypatch_modes.cpp +38 −39 Original line number Diff line number Diff line Loading @@ -81,16 +81,15 @@ static int FlashMode(const char* src_filename, const char* tgt_filename, } static int PatchMode(int argc, const char** argv) { FileContents bonusFc; Value bonus(VAL_INVALID, ""); std::unique_ptr<Value> bonus; if (argc >= 3 && strcmp(argv[1], "-b") == 0) { if (LoadFileContents(argv[2], &bonusFc) != 0) { FileContents bonus_fc; if (LoadFileContents(argv[2], &bonus_fc) != 0) { LOG(ERROR) << "Failed to load bonus file " << argv[2]; return 1; } bonus.type = VAL_BLOB; bonus.data = std::string(bonusFc.data.cbegin(), bonusFc.data.cend()); bonus = std::make_unique<Value>(Value::Type::BLOB, std::string(bonus_fc.data.cbegin(), bonus_fc.data.cend())); argc -= 2; argv += 2; } Loading @@ -107,7 +106,7 @@ static int PatchMode(int argc, const char** argv) { // If no <src-sha1>:<patch> is provided, it is in flash mode. if (argc == 5) { if (bonus.type != VAL_INVALID) { if (bonus) { LOG(ERROR) << "bonus file not supported in flash mode"; return 1; } Loading @@ -122,11 +121,11 @@ static int PatchMode(int argc, const char** argv) { } std::vector<std::unique_ptr<Value>> patches; for (size_t i = 0; i < files.size(); ++i) { patches.push_back(std::make_unique<Value>( VAL_BLOB, std::string(files[i].data.cbegin(), files[i].data.cend()))); for (const auto& file : files) { patches.push_back(std::make_unique<Value>(Value::Type::BLOB, std::string(file.data.cbegin(), file.data.cend()))); } return applypatch(argv[1], argv[2], argv[3], target_size, sha1s, patches, &bonus); return applypatch(argv[1], argv[2], argv[3], target_size, sha1s, patches, bonus.get()); } // This program (applypatch) applies binary patches to files in a way that Loading
applypatch/imgpatch.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -151,7 +151,8 @@ static bool ApplyBSDiffPatchAndStreamOutput(const uint8_t* src_data, size_t src_ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const unsigned char* patch_data, size_t patch_size, SinkFn sink) { Value patch(VAL_BLOB, std::string(reinterpret_cast<const char*>(patch_data), patch_size)); Value patch(Value::Type::BLOB, std::string(reinterpret_cast<const char*>(patch_data), patch_size)); return ApplyImagePatch(old_data, old_size, patch, sink, nullptr); } Loading Loading @@ -246,11 +247,10 @@ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value& // Decompress the source data; the chunk header tells us exactly // how big we expect it to be when decompressed. // Note: expanded_len will include the bonus data size if // the patch was constructed with bonus data. The // deflation will come up 'bonus_size' bytes short; these // must be appended from the bonus_data value. size_t bonus_size = (i == 1 && bonus_data != NULL) ? bonus_data->data.size() : 0; // Note: expanded_len will include the bonus data size if the patch was constructed with // bonus data. The deflation will come up 'bonus_size' bytes short; these must be appended // from the bonus_data value. size_t bonus_size = (i == 1 && bonus_data != nullptr) ? bonus_data->data.size() : 0; std::vector<unsigned char> expanded_source(expanded_len); Loading Loading @@ -288,7 +288,7 @@ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value& inflateEnd(&strm); if (bonus_size) { memcpy(expanded_source.data() + (expanded_len - bonus_size), &bonus_data->data[0], memcpy(expanded_source.data() + (expanded_len - bonus_size), bonus_data->data.data(), bonus_size); } } Loading
edify/expr.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ bool Evaluate(State* state, const std::unique_ptr<Expr>& expr, std::string* resu if (!v) { return false; } if (v->type != VAL_STRING) { if (v->type != Value::Type::STRING) { ErrorAbort(state, kArgsParsingFailure, "expecting string, got value type %d", v->type); return false; } Loading @@ -68,7 +68,7 @@ Value* StringValue(const char* str) { if (str == nullptr) { return nullptr; } return new Value(VAL_STRING, str); return new Value(Value::Type::STRING, str); } Value* StringValue(const std::string& str) { Loading
edify/include/edify/expr.h +8 −11 Original line number Diff line number Diff line Loading @@ -53,19 +53,16 @@ struct State { bool is_retry = false; }; enum ValueType { VAL_INVALID = -1, VAL_STRING = 1, VAL_BLOB = 2, struct Value { enum class Type { STRING = 1, BLOB = 2, }; struct Value { ValueType type; std::string data; Value(Type type, const std::string& str) : type(type), data(str) {} Value(ValueType type, const std::string& str) : type(type), data(str) {} Type type; std::string data; }; struct Expr; Loading