Downcast all qtsizetype to UINT32 manually, apply consistent identation

This commit is contained in:
Nikolaj Schlej 2022-08-28 12:47:01 +02:00
parent 10e2e60183
commit 4006954bc1
25 changed files with 3398 additions and 3398 deletions

View file

@ -1,15 +1,15 @@
/* fssbuilder.cpp
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ffsbuilder.h"
#include "descriptor.h"
@ -25,7 +25,7 @@ USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased)
// Sanity check
if (!index.isValid())
return U_INVALID_PARAMETER;
// Try to get emptyByte value from item's parsing data
UINT8 emptyByte = 0xFF;
if (!model->hasEmptyParsingData(index)) {
@ -38,9 +38,9 @@ USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased)
emptyByte = pdata.emptyByte;
}
}
erased = UByteArray(model->header(index).size() + model->body(index).size() + model->tail(index).size(), emptyByte);
return U_SUCCESS;
}
@ -49,7 +49,7 @@ USTATUS FfsBuilder::build(const UModelIndex & root, UByteArray & image)
// Sanity check
if (!root.isValid())
return U_INVALID_PARAMETER;
if (model->type(root) == Types::Capsule) {
return buildCapsule(root, image);
}
@ -61,7 +61,7 @@ USTATUS FfsBuilder::build(const UModelIndex & root, UByteArray & image)
return buildRawArea(root, image);
}
}
return U_NOT_IMPLEMENTED;
}
@ -70,27 +70,27 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
// Sanity check
if (!index.isValid())
return U_INVALID_PARAMETER;
// No action
if (model->action(index) == Actions::NoAction) {
// Use original item data
capsule = model->header(index) + model->body(index) + model->tail(index);
return U_SUCCESS;
}
// Rebuild or Replace
else if (model->action(index) == Actions::Rebuild
|| model->action(index) == Actions::Replace) {
|| model->action(index) == Actions::Replace) {
if (model->rowCount(index)) {
// Clear the supplied UByteArray
capsule.clear();
// Right now there is only one capsule image element supported
if (model->rowCount(index) != 1) {
msg(usprintf("buildCapsule: building of capsules with %d items is not yet supported", model->rowCount(index)), index);
return U_NOT_IMPLEMENTED;
}
// Build image
UModelIndex imageIndex = index.model()->index(0, 0, index);
UByteArray imageData;
@ -136,12 +136,12 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
}
else
capsule = model->body(index);
// Build successful, append header and tail
capsule = model->header(index) + capsule + model->tail(index);
return U_SUCCESS;
}
msg(UString("buildCapsule: unexpected action " + actionTypeToUString(model->action(index))), index);
return U_NOT_IMPLEMENTED;
}
@ -166,15 +166,15 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
else if (model->action(index) == Actions::Rebuild) {
// First child will always be descriptor for this type of image, and it's read only for now
intelImage = model->header(index.model()->index(0, 0, index)) + model->body(index.model()->index(0, 0, index)) + model->tail(index.model()->index(0, 0, index));
// Process other regions
for (int i = 1; i < model->rowCount(index); i++) {
UModelIndex currentRegion = index.model()->index(i, 0, index);
// Skip regions with Remove action
if (model->action(currentRegion) == Actions::Remove)
continue;
// Check item type to be either region or padding
UINT8 type = model->type(currentRegion);
if (type == Types::Padding) {
@ -182,41 +182,41 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
intelImage += model->header(currentRegion) + model->body(currentRegion) + model->tail(currentRegion);
continue;
}
// Check region subtype
USTATUS result;
UByteArray region;
UINT8 regionType = model->subtype(currentRegion);
switch (regionType) {
case Subtypes::BiosRegion:
case Subtypes::PdrRegion:
result = buildRawArea(currentRegion, region);
if (result) {
msg(UString("buildIntelImage: building of region ") + regionTypeToUString(regionType) + UString(" failed with error ") + errorCodeToUString(result), currentRegion);
return result;
}
break;
case Subtypes::MeRegion:
case Subtypes::GbeRegion:
case Subtypes::DevExp1Region:
case Subtypes::Bios2Region:
case Subtypes::MicrocodeRegion:
case Subtypes::EcRegion:
case Subtypes::DevExp2Region:
case Subtypes::IeRegion:
case Subtypes::Tgbe1Region:
case Subtypes::Tgbe2Region:
case Subtypes::Reserved1Region:
case Subtypes::Reserved2Region:
case Subtypes::PttRegion:
// Add region as is
region = model->header(currentRegion) + model->body(currentRegion);
break;
default:
msg(UString("buildIntelImage: unknown region type"), currentRegion);
return U_UNKNOWN_ITEM_TYPE;
case Subtypes::BiosRegion:
case Subtypes::PdrRegion:
result = buildRawArea(currentRegion, region);
if (result) {
msg(UString("buildIntelImage: building of region ") + regionTypeToUString(regionType) + UString(" failed with error ") + errorCodeToUString(result), currentRegion);
return result;
}
break;
case Subtypes::MeRegion:
case Subtypes::GbeRegion:
case Subtypes::DevExp1Region:
case Subtypes::Bios2Region:
case Subtypes::MicrocodeRegion:
case Subtypes::EcRegion:
case Subtypes::DevExp2Region:
case Subtypes::IeRegion:
case Subtypes::Tgbe1Region:
case Subtypes::Tgbe2Region:
case Subtypes::Reserved1Region:
case Subtypes::Reserved2Region:
case Subtypes::PttRegion:
// Add region as is
region = model->header(currentRegion) + model->body(currentRegion);
break;
default:
msg(UString("buildIntelImage: unknown region type"), currentRegion);
return U_UNKNOWN_ITEM_TYPE;
}
// Append the resulting region
intelImage += region;
}
@ -232,12 +232,12 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
msg(usprintf("buildIntelImage: new image size %Xh (%u) is smaller than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index);
return U_INVALID_IMAGE;
}
// Build successful, append header and tail
intelImage = model->header(index) + intelImage + model->tail(index);
return U_SUCCESS;
}
msg(UString("buildIntelImage: unexpected action " + actionTypeToUString(model->action(index))), index);
return U_NOT_IMPLEMENTED;
}
@ -247,7 +247,7 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
// Sanity check
if (!index.isValid())
return U_INVALID_PARAMETER;
// No action required
if (model->action(index) == Actions::NoAction) {
rawArea = model->header(index) + model->body(index) + model->tail(index);
@ -260,12 +260,12 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
}
// Rebuild or Replace
else if (model->action(index) == Actions::Rebuild
|| model->action(index) == Actions::Replace) {
|| model->action(index) == Actions::Replace) {
// Rebuild if there is at least 1 child
if (model->rowCount(index)) {
// Clear the supplied UByteArray
rawArea.clear();
// Build children
for (int i = 0; i < model->rowCount(index); i++) {
USTATUS result = U_SUCCESS;
@ -291,7 +291,7 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
// Append current data
rawArea += currentData;
}
// Check size of new raw area, it must be same as original one
UINT32 newSize = (UINT32)rawArea.size();
UINT32 oldSize = (UINT32)model->body(index).size();
@ -308,12 +308,12 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
else {
rawArea = model->body(index);
}
// Build successful, add header if needed
rawArea = model->header(index) + rawArea + model->tail(index);
return U_SUCCESS;
}
msg(UString("buildRawArea: unexpected action " + actionTypeToUString(model->action(index))), index);
return U_NOT_IMPLEMENTED;
}
@ -323,7 +323,7 @@ USTATUS FfsBuilder::buildPadding(const UModelIndex & index, UByteArray & padding
// Sanity check
if (!index.isValid())
return U_INVALID_PARAMETER;
// No action required
if (model->action(index) == Actions::NoAction) {
padding = model->header(index) + model->body(index) + model->tail(index);
@ -338,7 +338,7 @@ USTATUS FfsBuilder::buildPadding(const UModelIndex & index, UByteArray & padding
else if (model->action(index) == Actions::Erase) {
return erase(index, padding);
}
msg(UString("buildPadding: unexpected action " + actionTypeToUString(model->action(index))), index);
return U_NOT_IMPLEMENTED;
}
@ -348,7 +348,7 @@ USTATUS FfsBuilder::buildNonUefiData(const UModelIndex & index, UByteArray & dat
// Sanity check
if (!index.isValid())
return U_INVALID_PARAMETER;
// No action required
if (model->action(index) == Actions::NoAction) {
data = model->header(index) + model->body(index) + model->tail(index);
@ -363,9 +363,9 @@ USTATUS FfsBuilder::buildNonUefiData(const UModelIndex & index, UByteArray & dat
else if (model->action(index) == Actions::Erase) {
return erase(index, data);
}
// TODO: rebuild properly
msg(UString("buildNoUefiData: unexpected action " + actionTypeToUString(model->action(index))), index);
return U_NOT_IMPLEMENTED;
}
@ -375,7 +375,7 @@ USTATUS FfsBuilder::buildFreeSpace(const UModelIndex & index, UByteArray & freeS
// Sanity check
if (!index.isValid())
return U_INVALID_PARAMETER;
// No actions possible for free space
freeSpace = model->header(index) + model->body(index) + model->tail(index);
return U_SUCCESS;
@ -385,7 +385,7 @@ USTATUS FfsBuilder::buildVolume(const UModelIndex & index, UByteArray & volume)
{
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(volume);
return U_NOT_IMPLEMENTED;
}
@ -393,7 +393,7 @@ USTATUS FfsBuilder::buildPadFile(const UModelIndex & index, UByteArray & padFile
{
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(padFile);
return U_NOT_IMPLEMENTED;
}
@ -401,7 +401,7 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, UByteArray & file)
{
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(file);
return U_NOT_IMPLEMENTED;
}
@ -409,7 +409,7 @@ USTATUS FfsBuilder::buildSection(const UModelIndex & index, UByteArray & section
{
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(section);
return U_NOT_IMPLEMENTED;
}