type fixes

This commit is contained in:
Dmitry Frolov 2018-08-23 11:00:29 +03:00
parent da7eb36ffa
commit e516450fa8
4 changed files with 50 additions and 50 deletions

View File

@ -115,7 +115,7 @@ USTATUS FfsBuilder::buildRegion(const UModelIndex& index, UByteArray& reconstruc
// No action // No action
if (model->action(index) == Actions::NoAction) { if (model->action(index) == Actions::NoAction) {
reconstructed = model->header(index).append(model->body(index)); reconstructed = model->header(index) + model->body(index);
return U_SUCCESS; return U_SUCCESS;
} }
else if (model->action(index) == Actions::Remove) { else if (model->action(index) == Actions::Remove) {
@ -132,7 +132,7 @@ USTATUS FfsBuilder::buildRegion(const UModelIndex& index, UByteArray& reconstruc
result = build(index.child(i, 0), child); result = build(index.child(i, 0), child);
if (result) if (result)
return result; return result;
reconstructed.append(child); reconstructed += child;
} }
} }
// Use stored item body // Use stored item body
@ -153,7 +153,7 @@ USTATUS FfsBuilder::buildRegion(const UModelIndex& index, UByteArray& reconstruc
// Reconstruction successful // Reconstruction successful
if (includeHeader) if (includeHeader)
reconstructed = model->header(index).append(reconstructed); reconstructed = model->header(index) + reconstructed;
return U_SUCCESS; return U_SUCCESS;
} }
@ -211,7 +211,7 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
return result; return result;
} }
else else
capsule.append(imageData); capsule += imageData;
} }
else { else {
msg(UString("buildCapsule: unexpected item type ") + itemTypeToUString(model->type(imageIndex)), imageIndex); msg(UString("buildCapsule: unexpected item type ") + itemTypeToUString(model->type(imageIndex)), imageIndex);
@ -233,7 +233,7 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
else else
capsule = model->body(index); capsule = model->body(index);
// Build successful, append header and tail // Build successful, header and tail
capsule = model->header(index) + capsule + model->tail(index); capsule = model->header(index) + capsule + model->tail(index);
return U_SUCCESS; return U_SUCCESS;
} }
@ -275,7 +275,7 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
UINT8 type = model->type(currentRegion); UINT8 type = model->type(currentRegion);
if (type == Types::Padding) { if (type == Types::Padding) {
// Add padding as is // Add padding as is
intelImage.append(model->header(currentRegion) + model->body(currentRegion) + model->tail(currentRegion)); intelImage += model->header(currentRegion) + model->body(currentRegion) + model->tail(currentRegion);
continue; continue;
} }
@ -306,15 +306,15 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
case Subtypes::Reserved2Region: case Subtypes::Reserved2Region:
case Subtypes::PttRegion: case Subtypes::PttRegion:
// Add region as is // Add region as is
region = model->header(currentRegion).append(model->body(currentRegion)); region = model->header(currentRegion) + model->body(currentRegion);
break; break;
default: default:
msg(UString("buildIntelImage: unknown region type"), currentRegion); msg(UString("buildIntelImage: unknown region type"), currentRegion);
return U_UNKNOWN_ITEM_TYPE; return U_UNKNOWN_ITEM_TYPE;
} }
// Append the resulting region // the resulting region
intelImage.append(region); intelImage += region;
} }
// Check size of new image, it must be same as old one // Check size of new image, it must be same as old one
@ -329,7 +329,7 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
return U_INVALID_IMAGE; return U_INVALID_IMAGE;
} }
// Build successful, append header and tail // Build successful, header and tail
intelImage = model->header(index) + intelImage + model->tail(index); intelImage = model->header(index) + intelImage + model->tail(index);
return U_SUCCESS; return U_SUCCESS;
} }
@ -383,8 +383,8 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
msg(UString("buildRawArea: building of ") + model->name(currentChild) + UString(" failed with error ") + errorCodeToUString(result), currentChild); msg(UString("buildRawArea: building of ") + model->name(currentChild) + UString(" failed with error ") + errorCodeToUString(result), currentChild);
return result; return result;
} }
// Append current data // current data
rawArea.append(currentData); rawArea += currentData;
} }
// Check size of new raw area, it must be same as original one // Check size of new raw area, it must be same as original one
@ -489,7 +489,7 @@ USTATUS FfsBuilder::buildVolume(const UModelIndex & index, UByteArray & volume)
// No action // No action
if (model->action(index) == Actions::NoAction) { if (model->action(index) == Actions::NoAction) {
volume = model->header(index).append(model->body(index)); volume = model->header(index) + model->body(index);
return U_SUCCESS; return U_SUCCESS;
} }
else if (model->action(index) == Actions::Remove) { else if (model->action(index) == Actions::Remove) {
@ -614,7 +614,7 @@ out:
if (alignment) { if (alignment) {
alignment = 8 - alignment; alignment = 8 - alignment;
offset += alignment; offset += alignment;
volume.append(UByteArray(alignment, empty)); volume += UByteArray(alignment, empty);
} }
// Calculate file base // Calculate file base
@ -674,12 +674,12 @@ out:
if (result) if (result)
return result; return result;
// Append constructed pad file to volume body // Append constructed pad file to volume body
volume.append(pad); volume += pad;
offset += size; offset += size;
} }
// Append current file to new volume body // Append current file to new volume body
volume.append(file); volume += file;
// Change current file offset // Change current file offset
offset += file.size(); offset += file.size();
@ -731,7 +731,7 @@ out:
if (result) if (result)
return result; return result;
// Append constructed pad file to volume body // Append constructed pad file to volume body
volume.append(pad); volume += pad;
} }
// No more space left in volume // No more space left in volume
else if (offset > vtfOffset) { else if (offset > vtfOffset) {
@ -766,7 +766,7 @@ out:
} }
// Append VTF // Append VTF
volume.append(vtf); volume += vtf;
} }
else if (!nonUefiData.isEmpty()) { //Non-UEFI data found else if (!nonUefiData.isEmpty()) { //Non-UEFI data found
// No space left // No space left
@ -777,17 +777,17 @@ out:
} }
// Append additional free space // Append additional free space
else if (nonUefiDataOffset > offset) { else if (nonUefiDataOffset > offset) {
volume.append(UByteArray(nonUefiDataOffset - offset, empty)); volume += UByteArray(nonUefiDataOffset - offset, empty);
} }
// Append VTF // Append VTF
volume.append(nonUefiData); volume += nonUefiData;
} }
else { else {
// Fill the rest of volume space with empty char // Fill the rest of volume space with empty char
if (body.size() > volume.size()) { if (body.size() > volume.size()) {
// Fill volume end with empty char // Fill volume end with empty char
volume.append(UByteArray(body.size() - volume.size(), empty)); volume += UByteArray(body.size() - volume.size(), empty);
} }
else if (body.size() < volume.size()) { else if (body.size() < volume.size()) {
// Check if volume can be grown // Check if volume can be grown
@ -805,7 +805,7 @@ out:
return result; return result;
// Fill volume end with empty char // Fill volume end with empty char
volume.append(UByteArray(newSize - header.size() - volume.size(), empty)); volume += UByteArray(newSize - header.size() - volume.size(), empty);
volumeSize = newSize; volumeSize = newSize;
} }
} }
@ -825,7 +825,7 @@ out:
} }
// Reconstruction successful // Reconstruction successful
volume = header.append(volume); volume = header + volume;
// Recalculate CRC32 in ZeroVector, if needed // Recalculate CRC32 in ZeroVector, if needed
if (model->text(index).contains("AppleCRC32 ")) { if (model->text(index).contains("AppleCRC32 ")) {
@ -874,7 +874,7 @@ USTATUS FfsBuilder::buildNvramVolume(const UModelIndex & index, UByteArray & vol
// No action // No action
if (model->action(index) == Actions::NoAction) { if (model->action(index) == Actions::NoAction) {
volume = model->header(index).append(model->body(index)); volume = model->header(index) + model->body(index);
return U_SUCCESS; return U_SUCCESS;
} }
else if (model->action(index) == Actions::Remove) { else if (model->action(index) == Actions::Remove) {
@ -908,11 +908,11 @@ USTATUS FfsBuilder::buildNvramVolume(const UModelIndex & index, UByteArray & vol
return result; return result;
// Element reconstruct success // Element reconstruct success
volume.append(store); volume += store;
} }
// Volume reconstruct success // Volume reconstruct success
volume = header.append(volume); volume = header + volume;
return U_SUCCESS; return U_SUCCESS;
@ -967,7 +967,7 @@ USTATUS FfsBuilder::buildNvramStore(const UModelIndex & index, UByteArray & stor
//appleVariableHeader->DataSize = currentBody.size(); //appleVariableHeader->DataSize = currentBody.size();
} }
} }
body.append(currentHeader.append(currentBody)); body += currentHeader + currentBody;
} }
} }
} }
@ -1020,7 +1020,7 @@ USTATUS FfsBuilder::buildNvramStore(const UModelIndex & index, UByteArray & stor
} }
} }
body.append(currentHeader.append(currentBody)); body += currentHeader + currentBody;
} }
} }
} }
@ -1033,7 +1033,7 @@ USTATUS FfsBuilder::buildNvramStore(const UModelIndex & index, UByteArray & stor
// Rebuild end // Rebuild end
store.clear(); store.clear();
store = header.append(body); store = header + body;
return U_SUCCESS; return U_SUCCESS;
} }
@ -1080,13 +1080,13 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, const UINT8 revision, c
// No action // No action
if (model->action(index) == Actions::NoAction) { if (model->action(index) == Actions::NoAction) {
reconstructed = model->header(index).append(model->body(index)); reconstructed = model->header(index) + model->body(index);
const EFI_FFS_FILE_HEADER* fileHeader = (const EFI_FFS_FILE_HEADER*)model->header(index).constData(); const EFI_FFS_FILE_HEADER* fileHeader = (const EFI_FFS_FILE_HEADER*)model->header(index).constData();
// Append tail, if needed // Append tail, if needed
if (fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) { if (fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {
UINT8 ht = ~fileHeader->IntegrityCheck.Checksum.Header; UINT8 ht = ~fileHeader->IntegrityCheck.Checksum.Header;
UINT8 ft = ~fileHeader->IntegrityCheck.Checksum.File; UINT8 ft = ~fileHeader->IntegrityCheck.Checksum.File;
reconstructed.append(ht).append(ft); reconstructed += ht + ft;
} }
return U_SUCCESS; return U_SUCCESS;
} }
@ -1168,7 +1168,7 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, const UINT8 revision, c
if (alignment) { if (alignment) {
alignment = 4 - alignment; alignment = 4 - alignment;
offset += alignment; offset += alignment;
reconstructed.append(UByteArray(alignment, '\x00')); reconstructed += UByteArray(alignment, '\x00');
} }
// Calculate section base // Calculate section base
@ -1199,7 +1199,7 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, const UINT8 revision, c
continue; continue;
// Append current section to new file body // Append current section to new file body
reconstructed.append(section); reconstructed += section;
// Change current file offset // Change current file offset
offset += section.size(); offset += section.size();
@ -1243,7 +1243,7 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, const UINT8 revision, c
if (revision == 1 && fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) { if (revision == 1 && fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {
UINT8 ht = ~fileHeader->IntegrityCheck.Checksum.Header; UINT8 ht = ~fileHeader->IntegrityCheck.Checksum.Header;
UINT8 ft = ~fileHeader->IntegrityCheck.Checksum.File; UINT8 ft = ~fileHeader->IntegrityCheck.Checksum.File;
reconstructed.append(ht).append(ft); reconstructed += ht + ft;
} }
// Set file state // Set file state
@ -1253,7 +1253,7 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, const UINT8 revision, c
fileHeader->State = state; fileHeader->State = state;
// Reconstruction successful // Reconstruction successful
reconstructed = header.append(reconstructed); reconstructed = header + reconstructed;
return U_SUCCESS; return U_SUCCESS;
} }
@ -1271,7 +1271,7 @@ USTATUS FfsBuilder::buildSection(const UModelIndex & index, const UINT32 base, U
// No action // No action
if (model->action(index) == Actions::NoAction) { if (model->action(index) == Actions::NoAction) {
reconstructed = model->header(index).append(model->body(index)); reconstructed = model->header(index) + model->body(index);
return U_SUCCESS; return U_SUCCESS;
} }
else if (model->action(index) == Actions::Remove) { else if (model->action(index) == Actions::Remove) {
@ -1305,7 +1305,7 @@ USTATUS FfsBuilder::buildSection(const UModelIndex & index, const UINT32 base, U
if (alignment) { if (alignment) {
alignment = 4 - alignment; alignment = 4 - alignment;
offset += alignment; offset += alignment;
reconstructed.append(UByteArray(alignment, '\x00')); reconstructed += UByteArray(alignment, '\x00');
} }
// Reconstruct subsections // Reconstruct subsections
@ -1319,7 +1319,7 @@ USTATUS FfsBuilder::buildSection(const UModelIndex & index, const UINT32 base, U
continue; continue;
// Append current subsection to new section body // Append current subsection to new section body
reconstructed.append(section); reconstructed += section;
// Change current file offset // Change current file offset
offset += section.size(); offset += section.size();
@ -1434,7 +1434,7 @@ USTATUS FfsBuilder::buildSection(const UModelIndex & index, const UINT32 base, U
} }
// Reconstruction successful // Reconstruction successful
reconstructed = header.append(reconstructed); reconstructed = header + reconstructed;
return U_SUCCESS; return U_SUCCESS;
} }

View File

@ -29,15 +29,15 @@ USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteA
if (mode == EXTRACT_MODE_AS_IS) { if (mode == EXTRACT_MODE_AS_IS) {
// Extract as is, with header body and tail // Extract as is, with header body and tail
extracted.clear(); extracted.clear();
extracted.append(model->header(index)); extracted += model->header(index);
extracted.append(model->body(index)); extracted += model->body(index);
extracted.append(model->tail(index)); extracted += model->tail(index);
} }
else if (mode == EXTRACT_MODE_BODY) { else if (mode == EXTRACT_MODE_BODY) {
name += QObject::tr("_body"); name += QObject::tr("_body");
// Extract without header and tail // Extract without header and tail
extracted.clear(); extracted.clear();
extracted.append(model->body(index)); extracted += model->body(index);
} }
else if (mode == EXTRACT_MODE_BODY_UNCOMPRESSED) { else if (mode == EXTRACT_MODE_BODY_UNCOMPRESSED) {
name += QObject::tr("_body_unc"); name += QObject::tr("_body_unc");
@ -47,11 +47,11 @@ USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteA
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
UModelIndex childIndex = index.child(i, 0); UModelIndex childIndex = index.child(i, 0);
// Ensure 4-byte alignment of current section // Ensure 4-byte alignment of current section
extracted.append(UByteArray('\x00', ALIGN4((UINT32)extracted.size()) - (UINT32)extracted.size())); extracted += UByteArray('\x00', ALIGN4((UINT32)extracted.size()) - (UINT32)extracted.size());
// Add current section header, body and tail // Add current section header, body and tail
extracted.append(model->header(childIndex)); extracted += model->header(childIndex);
extracted.append(model->body(childIndex)); extracted += model->body(childIndex);
extracted.append(model->tail(childIndex)); extracted += model->tail(childIndex);
} }
} }
else else

View File

@ -332,7 +332,7 @@ USTATUS decompress(const UByteArray & compressedData, const UINT8 compressionTyp
} }
} }
UINT8 compress(const UByteArray & data, const UINT8 algorithm, UByteArray & compressedData) USTATUS compress(const UByteArray & data, const UINT8 algorithm, UByteArray & compressedData)
{ {
UINT8* compressed; UINT8* compressed;
@ -453,7 +453,7 @@ UINT8 compress(const UByteArray & data, const UINT8 algorithm, UByteArray & comp
delete[] compressed; delete[] compressed;
return U_CUSTOMIZED_COMPRESSION_FAILED; return U_CUSTOMIZED_COMPRESSION_FAILED;
} }
compressedData = header.append(UByteArray((const char*)compressed, compressedSize)); compressedData = header + UByteArray((const char*)compressed, compressedSize);
delete[] compressed; delete[] compressed;
return U_SUCCESS; return U_SUCCESS;
} }

View File

@ -31,7 +31,7 @@ UString errorCodeToUString(USTATUS errorCode);
USTATUS decompress(const UByteArray & compressed, const UINT8 compressionType, UINT8 & algorithm, UByteArray & decompressed, UByteArray & efiDecompressed); USTATUS decompress(const UByteArray & compressed, const UINT8 compressionType, UINT8 & algorithm, UByteArray & decompressed, UByteArray & efiDecompressed);
// Compression routine // Compression routine
UINT8 compress(const UByteArray & data, const UINT8 algorithm, UByteArray & compressedData); USTATUS compress(const UByteArray & data, const UINT8 algorithm, UByteArray & compressedData);
//USTATUS compress(const UByteArray & decompressed, UByteArray & compressed, const UINT8 & algorithm); //USTATUS compress(const UByteArray & decompressed, UByteArray & compressed, const UINT8 & algorithm);
// CRC32 calculation routine // CRC32 calculation routine