some style check

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2022-01-25 20:07:33 +03:00
parent b65ace3b58
commit 80a7bd0b7a
21 changed files with 110 additions and 109 deletions

View File

@ -1852,7 +1852,7 @@ AcpiTableAcpiTableConstructor (
// at the beginning of the list of tables. Some OS don't seem
// to find it correctly if it is too far down the list.
//
AcpiTableInstance->Rsdt1->SignatureCommon.Signature = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Rsdt1->Signature = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Rsdt1->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiTableInstance->Rsdt1->Revision = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;
CopyMem(AcpiTableInstance->Rsdt1->OemId, EFI_ACPI_OEM_ID, 6);
@ -1867,7 +1867,7 @@ AcpiTableAcpiTableConstructor (
AcpiTableInstance->NumberOfTableEntries1 = 1;
AcpiTableInstance->Rsdt1->Length = AcpiTableInstance->Rsdt1->Length + sizeof(UINT32);
AcpiTableInstance->Rsdt3->SignatureCommon.Signature = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Rsdt3->Signature = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Rsdt3->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiTableInstance->Rsdt3->Revision = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;
CopyMem(AcpiTableInstance->Rsdt3->OemId, EFI_ACPI_OEM_ID, 6);
@ -1885,7 +1885,7 @@ AcpiTableAcpiTableConstructor (
//
// Initialize Xsdt
//
AcpiTableInstance->Xsdt->SignatureCommon.Signature = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Xsdt->Signature = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Xsdt->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiTableInstance->Xsdt->Revision = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION;
CopyMem(AcpiTableInstance->Xsdt->OemId, EFI_ACPI_OEM_ID, 6);

View File

@ -138,7 +138,7 @@ ScanTableInRSDT (
EntryPtr = &Rsdt->Entry;
for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));
if (Table->SignatureCommon.Signature == Signature) {
if (Table->Signature == Signature) {
*FoundTable = Table;
break;
}
@ -168,7 +168,7 @@ ScanTableInXSDT (
for (Index = 0; Index < EntryCount; Index ++) {
CopyMem(&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));
Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));
if (Table->SignatureCommon.Signature == Signature) {
if (Table->Signature == Signature) {
*FoundTable = Table;
break;
}

View File

@ -778,7 +778,7 @@ HdaCodecDisableWidgetPath(
{
// Create variables.
EFI_STATUS Status;
EFI_HDA_IO_PROTOCOL *HdaIo = HdaWidget->FuncGroup->HdaCodecDev->HdaIo;
EFI_HDA_IO_PROTOCOL *HdaIo;
UINT32 Response = 0;
//DEBUG((DEBUG_INFO, "HdaCodecDisableWidgetPath(): start\n"));
@ -787,6 +787,8 @@ HdaCodecDisableWidgetPath(
if (HdaWidget == NULL)
return EFI_INVALID_PARAMETER;
HdaIo = HdaWidget->FuncGroup->HdaCodecDev->HdaIo;
// Crawl through widget path.
while (HdaWidget != NULL) {
// If Output, disable stream.
@ -823,7 +825,7 @@ HdaCodecEnableWidgetPath(
{
// Create variables.
EFI_STATUS Status;
EFI_HDA_IO_PROTOCOL *HdaIo = HdaWidget->FuncGroup->HdaCodecDev->HdaIo;
EFI_HDA_IO_PROTOCOL *HdaIo;
UINT32 Response = 0;
//DEBUG((DEBUG_INFO, "HdaCodecEnableWidgetPath(): start\n"));
@ -832,6 +834,8 @@ HdaCodecEnableWidgetPath(
if ((HdaWidget == NULL) || (Volume > EFI_AUDIO_IO_PROTOCOL_MAX_VOLUME))
return EFI_INVALID_PARAMETER;
HdaIo = HdaWidget->FuncGroup->HdaCodecDev->HdaIo;
// Crawl through widget path.
while (HdaWidget != NULL) {
DEBUG((DEBUG_INFO, "Widget @ 0x%X setting up\n", HdaWidget->NodeId));

View File

@ -749,13 +749,13 @@ BdsSetConsoleMode (
NewRows = mBootTextModeRow;
}
if (GraphicsOutput != NULL) {
// if (GraphicsOutput != NULL) {
MaxGopMode = GraphicsOutput->Mode->MaxMode;
}
// }
if (SimpleTextOut != NULL) {
// if (SimpleTextOut != NULL) {
MaxTextMode = SimpleTextOut->Mode->MaxMode;
}
// }
//
// 1. If current video resolution is same with required video resolution,

View File

@ -928,7 +928,7 @@ AhciDmaTransfer (
}
gBS->RestoreTPL (OldTpl);
if ((Task == NULL) || ((Task != NULL) && (!Task->IsStart))) {
if ((Task == NULL) || !Task->IsStart) {
//
// Mark the Task to indicate that it has been started.
//
@ -1039,7 +1039,7 @@ Exit:
// context cleanup, then set the packet's Asb status.
//
if (Task == NULL ||
((Task != NULL) && (Status != EFI_NOT_READY))
(Status != EFI_NOT_READY)
) {
AhciStopCommand (
PciIo,
@ -1402,8 +1402,6 @@ AhciAtaSmartReturnStatusCheck (
{
EFI_STATUS Status;
EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
UINT8 LBAMid;
UINT8 LBAHigh;
UINTN FisBaseAddr;
UINT32 Value;
@ -1431,44 +1429,44 @@ AhciAtaSmartReturnStatusCheck (
);
if (EFI_ERROR(Status)) {
REPORT_STATUS_CODE (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLED)
);
// REPORT_STATUS_CODE (
// EFI_ERROR_CODE | EFI_ERROR_MINOR,
// (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLED)
// );
return EFI_DEVICE_ERROR;
}
REPORT_STATUS_CODE (
EFI_PROGRESS_CODE,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_ENABLE)
);
// REPORT_STATUS_CODE (
// EFI_PROGRESS_CODE,
// (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_ENABLE)
// );
FisBaseAddr = (UINTN)AhciRegisters->AhciRFis + Port * sizeof (EFI_AHCI_RECEIVED_FIS);
Value = *(UINT32 *) (FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET);
if ((Value & EFI_AHCI_FIS_TYPE_MASK) == EFI_AHCI_FIS_REGISTER_D2H) {
LBAMid = ((UINT8 *)(UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[5];
LBAHigh = ((UINT8 *)(UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[6];
UINT8 LBAMid = ((UINT8 *)(UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[5];
UINT8 LBAHigh = ((UINT8 *)(UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[6];
if ((LBAMid == 0x4f) && (LBAHigh == 0xc2)) {
//
// The threshold exceeded condition is not detected by the device
//
DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n"));
REPORT_STATUS_CODE (
EFI_PROGRESS_CODE,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
);
// DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n"));
// REPORT_STATUS_CODE (
// EFI_PROGRESS_CODE,
// (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
// );
} else if ((LBAMid == 0xf4) && (LBAHigh == 0x2c)) {
//
// The threshold exceeded condition is detected by the device
//
DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n"));
REPORT_STATUS_CODE (
EFI_PROGRESS_CODE,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
);
// DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n"));
// REPORT_STATUS_CODE (
// EFI_PROGRESS_CODE,
// (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
// );
}
}

View File

@ -24,10 +24,7 @@ typedef struct {
/// The common ACPI description table header. This structure prefaces most ACPI tables.
///
typedef struct {
union {
UINT32 Signature;
CHAR8 SignatureAs4Char[4];
} SignatureCommon;
UINT32 Signature;
UINT32 Length;
UINT8 Revision;
UINT8 Checksum;

@ -1 +1 @@
Subproject commit 718db6190f93bacd4a4e19c96baed3cfd8070286
Subproject commit f7dceb2b4c839595e8bd83902cc331a57087d9dd

View File

@ -573,9 +573,7 @@ void Inflator_inflateHuffmanBlock(VECTOR_8 *out, const UINT8 *in, UINT32 *bp, UI
vector8_resize(out, (*pos + 1) * 2); // reserve more room
out->data[(*pos)++] = (UINT8) code;
}
else
if (code >= 257 && code <= 285)
else if (code <= 285)
{ // length code
UINT32 length = LENBASE[code - 257], numextrabits = LENEXTRA[code - 257];
UINT32 codeD;

View File

@ -67,13 +67,12 @@ KeyMapBubbleSort (
UINTN Index;
UINTN NoRemainingChilds2;
UINT16 *OperandPtr;
UINT16 FirstChild;
if (!Operand || !NoChilds) {
return;
}
if (Operand != NULL) {
++Operand;
NoRemainingChilds = (NoChilds - 1);
Index = 1;
@ -84,7 +83,7 @@ KeyMapBubbleSort (
if (Index < NoChilds) {
do {
FirstChild = Operand[-1];
UINT16 FirstChild = Operand[-1];
if (FirstChild > *OperandPtr) {
Operand[-1] = *OperandPtr;
@ -99,7 +98,7 @@ KeyMapBubbleSort (
++Index;
++Operand;
} while ((NoRemainingChilds--) > 0);
}
}
EFI_STATUS

View File

@ -432,7 +432,8 @@ GetIndexFromSupportedLangCodes(
//
// Skip ';' characters in SupportedLang
//
for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);
//for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);
while (*SupportedLang == ';') SupportedLang++; //no sense to check \0
//
// Determine the length of the next language code in SupportedLang
//
@ -530,7 +531,8 @@ GetLangFromSupportedLangCodes (
//
// Skip ';' characters in Supported
//
for (; *Supported != '\0' && *Supported == ';'; Supported++);
//for (; *Supported != '\0' && *Supported == ';'; Supported++);
while (*Supported == ';') Supported++;
}
}
}
@ -622,7 +624,8 @@ VariableGetBestLanguage (
//
// Skip ';' characters in Supported
//
for (; *Supported != '\0' && *Supported == ';'; Supported++);
//for (; *Supported != '\0' && *Supported == ';'; Supported++);
while (*Supported == ';') Supported++;
//
// Determine the length of the next language code in Supported
//

View File

@ -1773,7 +1773,7 @@ UINT32 FixADP1 (UINT8* dsdt, UINT32 len)
return len;
}
UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuffer<UINT8> ToReplace)
UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace)
{
size_t sizeoffset;
INT32 adr;

View File

@ -50,7 +50,7 @@ FindBin (
INT32 FindBin (UINT8 *dsdt, size_t len, const XBuffer<UINT8>& bin);
UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuffer<UINT8> ToReplace);
UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace);
UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& TgtBrgName, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace);

View File

@ -383,7 +383,7 @@ EFI_STATUS SaveHdaDumpBin()
continue;
HdaCodecDev = AudioIoPrivateData->HdaCodecDev;
if(!HdaCodecDev || !HdaCodecDev->AudioFuncGroup)
if(!HdaCodecDev->AudioFuncGroup)
continue;
// HdaCodecInfo = &HdaCodecDev->HdaCodecInfoData->HdaCodecInfo;

View File

@ -80,7 +80,6 @@ XString8 get_pci_dev_path(pci_dt_t *PciDt)
return NullXString8;
returnValue = FileDevicePathToXStringW(DevicePath);
return returnValue;
}
UINT32 pci_config_read32(pci_dt_t *PciDt, UINT8 reg)
@ -342,6 +341,8 @@ void devprop_free_string(DevPropString *StringBuf)
// StringBuf = NULL;
}
static UINT8 builtin = 0x0;
// Ethernet built-in device injection
XBool set_eth_props(pci_dt_t *eth_dev)
{
@ -349,7 +350,6 @@ XBool set_eth_props(pci_dt_t *eth_dev)
// CHAR8 *devicepath;
#endif
DevPropDevice *device = NULL;
UINT8 builtin = 0x0;
XBool Injected = false;
UINTN i;
CHAR8 compatible[64];
@ -422,8 +422,6 @@ XBool set_eth_props(pci_dt_t *eth_dev)
#define PCI_IF_XHCI 0x30
static UINT8 clock_id = 0;
static UINT8 builtin = 0x0;
static UINT16 current_available = 1200; //mA
static UINT16 current_extra = 700;
static UINT16 current_in_sleep = 1000;

View File

@ -66,13 +66,14 @@ XBool AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& _LoaderTit
// INTN i;
DBG(" AddLegacyEntry:\n");
if (Volume == NULL) {
DBG(" Volume==0\n");
return false;
}
DBG(" FullTitle=%ls\n", FullTitle.wc_str());
DBG(" LoaderTitle=%ls\n", _LoaderTitle.wc_str());
DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
if (Volume == NULL) {
return false;
}
// Ignore this loader if it's device path is already present in another loader
for (UINTN i = 0; i < MainMenu.Entries.size(); ++i) {
REFIT_ABSTRACT_MENU_ENTRY& MainEntry = MainMenu.Entries[i];

View File

@ -268,8 +268,9 @@ UINT8 GetOSTypeFromPath(IN CONST XStringW& Path)
( Path.isEqualIC(OSXInstallerPaths[2])) ||
( Path.isEqualIC(OSXInstallerPaths[3])) ||
( Path.isEqualIC(OSXInstallerPaths[4])) ||
( Path.isEqualIC(RockBoot)) || ( Path.isEqualIC(PaperBoot)) || ( Path.isEqualIC(ScissorBoot)) ||
(! Path.isEqualIC(L"\\.IABootFiles\\boot.efi") && Path.isEqualIC(L"\\.IAPhysicalMedia") && Path.isEqualIC(MACOSX_LOADER_PATH))
( Path.isEqualIC(RockBoot)) || ( Path.isEqualIC(PaperBoot)) || ( Path.isEqualIC(ScissorBoot)) /* ||
(! Path.isEqualIC(L"\\.IABootFiles\\boot.efi") &&
Path.isEqualIC(L"\\.IAPhysicalMedia")) */ //what is it???
) {
return OSTYPE_OSX_INSTALLER;
} else if ( Path.isEqualIC(L"\\com.apple.recovery.boot\\boot.efi")) {

View File

@ -24,7 +24,7 @@ float CeilF(float X);
float FloorF(float X);
float ModF(float X, float Y);
float AcosF(float X);
float Atan2F(float X, float Y);
float Atan2F(float Y, float X); //y=sin(A), x=cos(A), atan2(y,x) == A
float FabsF(float X);
float rndf(void); //random number from 0 to 1.0f
int dither(float x, int level);

View File

@ -140,7 +140,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage*
else {
SVGimage->shapes = shapeNext;
}
shapePrev->next = shapeNext;
// shapePrev->next = shapeNext; //already done or null pointer
} //the shape in the group
else {
shapePrev = shape;

View File

@ -840,9 +840,9 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
unsigned tablelen = maxlen - FIRSTBITS;
unsigned start = tree->table_value[index]; /*starting index in secondary table*/
unsigned num = 1u << (tablelen - (l - FIRSTBITS)); /*amount of entries of this symbol in secondary table*/
unsigned j;
if(maxlen < l) return 55; /*invalid tree: long symbol shares prefix with short symbol*/
for(j = 0; j < num; ++j) {
for(unsigned j = 0; j < num; ++j) {
unsigned reverse2 = reverse >> FIRSTBITS; /* l - FIRSTBITS bits */
unsigned index2 = start + (reverse2 | (j << (l - FIRSTBITS)));
tree->table_len[index2] = l;
@ -889,7 +889,6 @@ static unsigned HuffmanTree_makeFromLengths2(HuffmanTree* tree) {
unsigned* blcount;
unsigned* nextcode;
unsigned error = 0;
unsigned bits, n;
tree->codes = (unsigned*)lodepng_malloc(tree->numcodes * sizeof(unsigned));
blcount = (unsigned*)lodepng_malloc((tree->maxbitlen + 1) * sizeof(unsigned));
@ -899,13 +898,13 @@ static unsigned HuffmanTree_makeFromLengths2(HuffmanTree* tree) {
if(!error) {
// for(n = 0; n != tree->maxbitlen + 1; n++) blcount[n] = nextcode[n] = 0; //already zero
/*step 1: count number of instances of each code length*/
for(bits = 0; bits != tree->numcodes; ++bits) ++blcount[tree->lengths[bits]];
for(unsigned bits = 0; bits != tree->numcodes; ++bits) ++blcount[tree->lengths[bits]];
/*step 2: generate the nextcode values*/
for(bits = 1; bits <= tree->maxbitlen; ++bits) {
for(unsigned bits = 1; bits <= tree->maxbitlen; ++bits) {
nextcode[bits] = (nextcode[bits - 1] + blcount[bits - 1]) << 1u;
}
/*step 3: generate all the codes*/
for(n = 0; n != tree->numcodes; ++n) {
for(unsigned n = 0; n != tree->numcodes; ++n) {
if(tree->lengths[n] != 0) {
tree->codes[n] = nextcode[tree->lengths[n]]++;
/*remove superfluous bits from the code*/
@ -966,22 +965,22 @@ typedef struct BPMLists {
} BPMLists;
/*creates a new chain node with the given parameters, from the memory in the lists */
static BPMNode* bpmnode_create(BPMLists* lists, int weight, unsigned index, BPMNode* tail) {
unsigned i;
static BPMNode* bpmnode_create(BPMLists* lists, int weight, unsigned index, BPMNode* tail)
{
BPMNode* result;
/*memory full, so garbage collect*/
if(lists->nextfree >= lists->numfree) {
/*mark only those that are in use*/
for(i = 0; i != lists->memsize; ++i) lists->memory[i].in_use = 0;
for(i = 0; i != lists->listsize; ++i) {
for(unsigned i = 0; i != lists->memsize; ++i) lists->memory[i].in_use = 0;
for(unsigned i = 0; i != lists->listsize; ++i) {
BPMNode* node;
for(node = lists->chains0[i]; node != 0; node = node->tail) node->in_use = 1;
for(node = lists->chains1[i]; node != 0; node = node->tail) node->in_use = 1;
}
/*collect those that are free*/
lists->numfree = 0;
for(i = 0; i != lists->memsize; ++i) {
for(unsigned i = 0; i != lists->memsize; ++i) {
if(!lists->memory[i].in_use) lists->freelist[lists->numfree++] = &lists->memory[i];
}
lists->nextfree = 0;
@ -1060,7 +1059,7 @@ static void boundaryPM(BPMLists* lists, BPMNode* leaves, size_t numpresent, int
unsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequencies,
size_t numcodes, unsigned maxbitlen) {
unsigned error = 0;
unsigned i;
// unsigned i;
size_t numpresent = 0; /*number of symbols with non-zero frequency*/
BPMNode* leaves; /*the symbols, only those with > 0 frequency*/
@ -1070,7 +1069,7 @@ unsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequen
leaves = (BPMNode*)lodepng_malloc(numcodes * sizeof(*leaves));
if(!leaves) return 83; /*alloc fail*/
for(i = 0; i != numcodes; ++i) {
for(unsigned i = 0; i != numcodes; ++i) {
if(frequencies[i] > 0) {
leaves[numpresent].weight = (int)frequencies[i];
leaves[numpresent].index = i;
@ -1107,21 +1106,21 @@ unsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequen
if(!lists.memory || !lists.freelist || !lists.chains0 || !lists.chains1) error = 83; /*alloc fail*/
if(!error) {
for(i = 0; i != lists.memsize; ++i) lists.freelist[i] = &lists.memory[i];
for(unsigned i = 0; i != lists.memsize; ++i) lists.freelist[i] = &lists.memory[i];
// CopyMem(lists.freelist, &lists.memory, lists.memsize * sizeof(*lists.freelist));
bpmnode_create(&lists, leaves[0].weight, 1, 0);
bpmnode_create(&lists, leaves[1].weight, 2, 0);
for(i = 0; i != lists.listsize; ++i) {
for(unsigned i = 0; i != lists.listsize; ++i) {
lists.chains0[i] = &lists.memory[0];
lists.chains1[i] = &lists.memory[1];
}
/*each boundaryPM call adds one chain to the last list, and we need 2 * numpresent - 2 chains.*/
for(i = 2; i != 2 * numpresent - 2; ++i) boundaryPM(&lists, leaves, numpresent, (int)maxbitlen - 1, (int)i);
for(unsigned i = 2; i != 2 * numpresent - 2; ++i) boundaryPM(&lists, leaves, numpresent, (int)maxbitlen - 1, (int)i);
for(node = lists.chains1[maxbitlen - 1]; node; node = node->tail) {
for(i = 0; i != node->index; ++i) ++lengths[leaves[i].index];
for(unsigned i = 0; i != node->index; ++i) ++lengths[leaves[i].index];
}
}
@ -1153,15 +1152,15 @@ static unsigned HuffmanTree_makeFromFrequencies(HuffmanTree* tree, const unsigne
/*get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/
static unsigned generateFixedLitLenTree(HuffmanTree* tree) {
unsigned i, error = 0;
unsigned error = 0;
unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
if(!bitlen) return 83; /*alloc fail*/
/*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/
for(i = 0; i <= 143; ++i) bitlen[i] = 8;
for(i = 144; i <= 255; ++i) bitlen[i] = 9;
for(i = 256; i <= 279; ++i) bitlen[i] = 7;
for(i = 280; i <= 287; ++i) bitlen[i] = 8;
for(unsigned i = 0; i <= 143; ++i) bitlen[i] = 8;
for(unsigned i = 144; i <= 255; ++i) bitlen[i] = 9;
for(unsigned i = 256; i <= 279; ++i) bitlen[i] = 7;
for(unsigned i = 280; i <= 287; ++i) bitlen[i] = 8;
error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);
@ -1171,12 +1170,12 @@ static unsigned generateFixedLitLenTree(HuffmanTree* tree) {
/*get the distance code tree of a deflated block with fixed tree, as specified in the deflate specification*/
static unsigned generateFixedDistanceTree(HuffmanTree* tree) {
unsigned i, error = 0;
unsigned error = 0;
unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));
if(!bitlen) return 83; /*alloc fail*/
/*there are 32 distance codes, but 30-31 are unused*/
for(i = 0; i != NUM_DISTANCE_SYMBOLS; ++i) bitlen[i] = 5;
for(unsigned i = 0; i != NUM_DISTANCE_SYMBOLS; ++i) bitlen[i] = 5;
error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DISTANCE_SYMBOLS, 15);
lodepng_free(bitlen);
@ -1224,7 +1223,7 @@ static unsigned getTreeInflateDynamic(HuffmanTree* tree_ll, HuffmanTree* tree_d,
LodePNGBitReader* reader) {
/*make sure that length values that aren't filled in will be 0, or a wrong tree will be generated*/
unsigned error = 0;
unsigned n, HLIT, HDIST, HCLEN, i;
unsigned n, HLIT, HDIST, HCLEN;
/*see comments in deflateDynamic for explanation of the context and these variables, it is analogous*/
unsigned* bitlen_ll = 0; /*lit,len code lengths*/
@ -1252,11 +1251,11 @@ static unsigned getTreeInflateDynamic(HuffmanTree* tree_ll, HuffmanTree* tree_d,
if(lodepng_gtofl(reader->bp, HCLEN * 3, reader->bitsize)) {
ERROR_BREAK(50); /*error: the bit pointer is or will go past the memory*/
}
for(i = 0; i != HCLEN; ++i) {
for(unsigned i = 0; i != HCLEN; ++i) {
ensureBits9(reader, 3); /*out of bounds already checked above */
bitlen_cl[CLCL_ORDER[i]] = readBits(reader, 3);
}
for(i = HCLEN; i != NUM_CODE_LENGTH_CODES; ++i) {
for(unsigned i = HCLEN; i != NUM_CODE_LENGTH_CODES; ++i) {
bitlen_cl[CLCL_ORDER[i]] = 0;
}
@ -1271,7 +1270,7 @@ static unsigned getTreeInflateDynamic(HuffmanTree* tree_ll, HuffmanTree* tree_d,
lodepng_memset(bitlen_d, 0, NUM_DISTANCE_SYMBOLS * sizeof(*bitlen_d));
/*i is the current symbol we're reading in the part that contains the code lengths of lit/len and dist codes*/
i = 0;
unsigned i = 0;
while(i < HLIT + HDIST) {
unsigned code;
ensureBits25(reader, 22); /* up to 15 bits for huffman code, up to 7 extra bits below*/
@ -5189,20 +5188,21 @@ static unsigned addChunk_PLTE(ucvector* out, const LodePNGColorMode* info) {
return error;
}
static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info) {
static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info)
{
unsigned error = 0;
size_t i;
// size_t i;
ucvector tRNS;
ucvector_init(&tRNS);
if(info->colortype == LCT_PALETTE) {
size_t amount = info->palettesize;
/*the tail of palette values that all have 255 as alpha, does not have to be encoded*/
for(i = info->palettesize; i != 0; --i) {
for(unsigned i = info->palettesize; i != 0; --i) {
if(info->palette[4 * (i - 1) + 3] == 255) --amount;
else break;
}
/*add only alpha channel*/
for(i = 0; i != amount; ++i) ucvector_push_back(&tRNS, info->palette[4 * i + 3]);
for(unsigned i = 0; i != amount; ++i) ucvector_push_back(&tRNS, info->palette[4 * i + 3]);
} else if(info->colortype == LCT_GREY) {
if(info->key_defined) {
ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
@ -5226,7 +5226,8 @@ static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info) {
}
static unsigned addChunk_IDAT(ucvector* out, const unsigned char* data, size_t datasize,
LodePNGCompressSettings* zlibsettings) {
LodePNGCompressSettings* zlibsettings)
{
ucvector zlibdata;
unsigned error = 0;
@ -5239,7 +5240,8 @@ static unsigned addChunk_IDAT(ucvector* out, const unsigned char* data, size_t d
return error;
}
static unsigned addChunk_IEND(ucvector* out) {
static unsigned addChunk_IEND(ucvector* out)
{
unsigned error = 0;
error = addChunk(out, "IEND", 0, 0);
return error;
@ -5247,7 +5249,8 @@ static unsigned addChunk_IEND(ucvector* out) {
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring) {
static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring)
{
unsigned error = 0;
size_t i;
ucvector text;

View File

@ -71,7 +71,7 @@
#define ceilf(x) CeilF(x)
#define floorf(x) FloorF(x)
#define acosf(x) AcosF(x)
#define atan2f(x,y) Atan2F(x,y)
#define atan2f(y,x) Atan2F(y,x)
#define fabsf(x) FabsF(x)
@ -447,7 +447,6 @@ static double nsvg__evalBezier(double t, double p0, double p1, double p2, double
static void nsvg__curveBounds(float* bounds, float* curve)
{
int i, j, count;
double roots[2], a, b, c, b2ac, t, v;
float* v0 = &curve[0];
float* v1 = &curve[2];
@ -466,11 +465,11 @@ static void nsvg__curveBounds(float* bounds, float* curve)
return;
// Add bezier curve inflection points in X and Y.
for (i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++) {
a = -3.0f * v0[i] + 9.0f * v1[i] - 9.0f * v2[i] + 3.0f * v3[i];
b = 6.0f * v0[i] - 12.0f * v1[i] + 6.0f * v2[i];
c = 3.0f * v1[i] - 3.0f * v0[i];
count = 0;
int count = 0;
if (fabs(a) < NSVG_EPSILON) {
if (fabs(b) > NSVG_EPSILON) {
t = -c / b;
@ -486,7 +485,7 @@ static void nsvg__curveBounds(float* bounds, float* curve)
if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON) roots[count++] = t;
}
}
for (j = 0; j < count; j++) {
for (int j = 0; j < count; j++) {
v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
@ -4232,10 +4231,10 @@ static void nsvg__content(void* ud, char* s)
if (p->shapeFlag) {
while (shape->next)
shape = shape->next;
if (shape) {
memcpy(shape->title, s, len);
memset(shape->title + len, 0, lim-len);
}
// if (shape) {
memcpy(shape->title, s, len);
memset(shape->title + len, 0, lim-len);
// }
} else { //not shape
NSVGattrib* attr = nsvg__getAttr(p);
memcpy(attr->title, s, len);

View File

@ -61,7 +61,7 @@
#define floorf(x) FloorF(x)
#define fmodf(x,y) ModF(x,y)
#define acosf(x) AcosF(x)
#define atan2f(x,y) Atan2F(x,y)
#define atan2f(y,x) Atan2F(y,x)
//#define fabsf(x) ((x >= 0.0f)?x:(-x))
#define fabsf(x) FabsF(x)