DO NOT explicitly call default ctor with new because of clang bug.

This commit is contained in:
jief666 2021-05-05 20:10:10 +03:00
parent 8dab184a8b
commit d52803e7cd
31 changed files with 58 additions and 52 deletions

View File

@ -2144,7 +2144,7 @@ UINT32 FixRTC (UINT8 *dsdt, UINT32 len)
break;
}
if ((dsdt[i+1] == 0x5B) && (dsdt[i+2] == 0x82)) {
break; //end of RTC device and begin of new Device()
break; //end of RTC device and begin of new Device
}
}
@ -2251,7 +2251,7 @@ UINT32 FixTMR (UINT8 *dsdt, UINT32 len)
} // offset if
if ((dsdt[i+1] == 0x5B) && (dsdt[i+2] == 0x82)) {
break; //end of TMR device and begin of new Device()
break; //end of TMR device and begin of new Device
}
} // i loop
@ -2336,7 +2336,7 @@ UINT32 FixPIC (UINT8 *dsdt, UINT32 len)
sizeoffset = 0;
} // sizeoffset if
if ((dsdt[i+1] == 0x5B) && (dsdt[i+2] == 0x82)) {
break; //end of PIC device and begin of new Device()
break; //end of PIC device and begin of new Device
}
} // i loop

View File

@ -1029,7 +1029,7 @@ public:
for ( idx = 0 ; idx < configPlist.size() ; ++idx ) {
if ( idx < size() ) ElementAt(idx).takeValueFrom(configPlist.getAtIndex(idx));
else {
ACPI_RENAME_DEVICE* s = new ACPI_RENAME_DEVICE();
ACPI_RENAME_DEVICE* s = new ACPI_RENAME_DEVICE;
s->takeValueFrom(configPlist.getAtIndex(idx));
AddReference(s, true);
}
@ -1048,7 +1048,7 @@ public:
// for ( idx = 0 ; idx < configPlist.size() ; ++idx ) {
// if ( idx < size() ) ElementAt(idx).takeValueFrom(configPlist[idx]);
// else {
// ACPIDropTablesClass* s = new ACPIDropTablesClass();
// ACPIDropTablesClass* s = new ACPIDropTablesClass;
// s->takeValueFrom(configPlist[idx]);
// AddReference(s, true);
// }
@ -1994,7 +1994,7 @@ printf("%s", "");
const ArbitraryPropertyClass& newArb = ArbitraryArray[idx];
for ( size_t jdx = newArb.CustomPropertyArray.size() ; jdx-- > 0 ; ) {
const SimplePropertyClass& newArbProp = newArb.CustomPropertyArray[jdx];
DEV_PROPERTY* newProp = new DEV_PROPERTY();
DEV_PROPERTY* newProp = new DEV_PROPERTY;
newProp->Device = newArb.Device;
newProp->Key = const_cast<char*>(newArbProp.Key.c_str()); // const_cast !!! So ugly. It is just because it's temporary. If ArbProperties is modified after this, a lot a memory problem will happen. I could have done some strdup, but that way I don't use memory and don't have to free it.
newProp->Value = const_cast<unsigned char*>(newArbProp.Value.data());
@ -2009,7 +2009,7 @@ printf("%s", "");
// Non arb : device = 0
for ( size_t idx = Properties.PropertyArray.size() ; idx-- > 0 ; ) {
const PropertiesClass::PropertyClass& Prop = Properties.PropertyArray[idx];
DEV_PROPERTY* newProp = new DEV_PROPERTY();
DEV_PROPERTY* newProp = new DEV_PROPERTY;
newProp->Device = 0;
newProp->Key = 0;
if ( Prop.Enabled ) newProp->Label = XString8(Prop.DevicePathAsString).forgetDataWithoutFreeing();
@ -2017,7 +2017,7 @@ printf("%s", "");
newProp->Child = NULL;
for ( size_t jdx = Properties.PropertyArray[idx].propertiesArray.size() ; jdx-- > 0 ; ) {
const SimplePropertyClass& SubProp = Prop.propertiesArray[jdx];
DEV_PROPERTY* newSubProp = new DEV_PROPERTY();
DEV_PROPERTY* newSubProp = new DEV_PROPERTY;
newSubProp->Device = 0;
newSubProp->Key = const_cast<char*>(SubProp.Key.c_str());
// newSubProp->Key = NULL;

View File

@ -27,7 +27,7 @@ class XObjArrayWithTakeValueFromXmlArray: public XObjArray<SettingsClass>
for ( idx = 0 ; idx < xmlArray.size() ; ++idx ) {
if ( idx < super::size() ) super::ElementAt(idx).takeValueFrom(xmlArray[idx]);
else {
SettingsClass* s = new SettingsClass();
SettingsClass* s = new SettingsClass;
s->takeValueFrom(xmlArray[idx]);
super::AddReference(s, true);
}
@ -51,7 +51,7 @@ class XObjArrayWithTakeValueFromXmlRepeatingDict: public XObjArray<SettingsClass
for ( idx = 0 ; idx < xmlRepeatingDict.valueArray().size() ; ++idx ) {
if ( idx < super::size() ) super::ElementAt(idx).takeValueFrom(xmlRepeatingDict.valueArray()[idx]);
else {
SettingsClass* s = new SettingsClass();
SettingsClass* s = new SettingsClass;
s->takeValueFrom(xmlRepeatingDict.valueArray()[idx]);
super::AddReference(s, true);
}

View File

@ -449,7 +449,7 @@ void GetOutputs()
}
HdaCodecDev = AudioIoPrivateData->HdaCodecDev;
for (i = 0; i < OutputPortsCount; i++) {
HDA_OUTPUTS* hdaOutputPtr = new HDA_OUTPUTS();
HDA_OUTPUTS* hdaOutputPtr = new HDA_OUTPUTS;
HDA_OUTPUTS& hdaOutput = *hdaOutputPtr;
// HdaCodecDev->OutputPorts[i];
hdaOutput.Name.takeValueFrom(HdaCodecDev->Name);

View File

@ -298,7 +298,7 @@ EFI_STATUS LOADER_ENTRY::AddKext(const EFI_FILE *RootDir, const XString8& FileNa
EFI_STATUS Status;
KEXT_ENTRY *KextEntry;
KextEntry = new KEXT_ENTRY();
KextEntry = new KEXT_ENTRY;
KextEntry->Signature = KEXT_SIGNATURE;
Status = LoadKext(RootDir, FileName, archCpuType, &KextEntry->kext);
if(EFI_ERROR(Status)) {

View File

@ -92,7 +92,7 @@ TagArray* TagArray::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagArray();
tag = new TagArray;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -59,7 +59,7 @@ TagBool* TagBool::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagBool();
tag = new TagBool;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -61,7 +61,7 @@ TagData* TagData::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagData();
tag = new TagData;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -60,7 +60,7 @@ TagDate* TagDate::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagDate();
tag = new TagDate;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -59,7 +59,7 @@ TagDict* TagDict::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagDict();
tag = new TagDict;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -61,7 +61,7 @@ TagFloat* TagFloat::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagFloat();
tag = new TagFloat;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -61,7 +61,7 @@ TagInt64* TagInt64::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagInt64();
tag = new TagInt64;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -61,7 +61,7 @@ TagKey* TagKey::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagKey();
tag = new TagKey;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -60,7 +60,7 @@ TagString* TagString::getEmptyTag()
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagString();
tag = new TagString;
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;

View File

@ -89,7 +89,7 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr);
////DBG("tagcachehit=%lld\n", tagcachehit);
// return tag;
// }
// tag = new TagStruct();
// tag = new TagStruct;
////newtagcount += 1;
////DBG("newtagcount=%lld\n", newtagcount);
// return tag;

View File

@ -28,7 +28,7 @@ class PropertiesUnion: public XmlUnion
// XmlCompositeField m_fields[1] = { xmlValue };
// virtual void getFields(XmlCompositeField** fields, size_t* nb) override { *fields = m_fields; *nb = sizeof(m_fields)/sizeof(m_fields[0]); };
Property() : parent(*new Properties4DeviceClass()) { panic("BUG. define getNewInstance()"); }
Property() : parent(*new Properties4DeviceClass) { panic("BUG. define getNewInstance()"); }
Property(const Properties4DeviceClass& _parent) : parent(_parent) {}
uint8_t dgetBValue() const {

View File

@ -75,7 +75,7 @@ public:
explicit Shared_ptr(T* ptr = nullptr)
{
m_ptr = ptr;
m_counter = new Counter();
m_counter = new Counter;
if (ptr) {
++(*m_counter);
}

View File

@ -69,7 +69,7 @@ bool XmlArray<T>::parseFromXmlLite(XmlLiteParser* xmlLiteParser, const XString8&
xmlSubPath.S8Catf("[%zu]", n);
XmlParserPosition beforePos = xmlLiteParser->getPosition();
T* newT = new T();
T* newT = new T;
if ( newT->parseFromXmlLite(xmlLiteParser, xmlSubPath, generateErrors) ) {
super2::AddReference(newT, true);
}else{

View File

@ -97,7 +97,7 @@ public:
virtual const char* getDescription() override { return "dict"; };
virtual void reset() override { super::reset(); m_valueArray.setEmpty(); };
virtual XmlValueType* getNewInstance() { return new XmlValueType(); }
virtual XmlValueType* getNewInstance() { return new XmlValueType; }
const ValueArrayType& valueArray() const { if ( !isDefined() ) panic("%s : value is not defined", __PRETTY_FUNCTION__); return m_valueArray; }

View File

@ -448,6 +448,11 @@ bool XmlLiteParser::getKeyTagValue(const char** value, size_t* valueLength, XmlP
currentPos = *xmlParserPosition;
return false;
}
#ifdef DEBUG_TRACE
printf("XmlLiteParser::getKeyTagValue key=%.*s, line=%d, buffer=", (int)*valueLength, *value, (*xmlParserPosition).getLine());
for(size_t i=0 ; i<40 ; i++) printf("%c", (*xmlParserPosition).p[i] < 32 ? 0 : (*xmlParserPosition).p[i]);
printf("\n");
#endif
// I think the following cannot happen anymore...
if ( !strnIsEqualIC(tag, tagLength, "key") ) {
addXmlError(generateErrors, S8Printf("Expecting a <key> at line %d col %d", (*xmlParserPosition).line, (*xmlParserPosition).col));

View File

@ -270,7 +270,7 @@ class XmlKeyDisablable : public XmlKey
protected:
bool Disabled = false;
public:
XmlKeyDisablable() : super() {};
XmlKeyDisablable() {};
~XmlKeyDisablable() {};
virtual void reset() override { super::reset(); Disabled = false; };

View File

@ -109,7 +109,7 @@ DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
//DBG("VolDesc=%ls\n", VolDesc);
// prepare the menu entry
Entry = new LEGACY_ENTRY();
Entry = new LEGACY_ENTRY;
if ( FullTitle.notEmpty() ) {
Entry->Title = FullTitle;
} else {
@ -181,7 +181,7 @@ DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
}
// create the submenu
SubScreen = new REFIT_MENU_SCREEN();
SubScreen = new REFIT_MENU_SCREEN;
// SubScreen->Title = L"Boot Options for "_XSW + LoaderTitle + L" on "_XSW + VolDesc;
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle.wc_str(), VolDesc.wc_str());
@ -189,7 +189,7 @@ DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
SubScreen->ID = SCREEN_BOOT;
SubScreen->GetAnime();
// default entry
SubEntry = new LEGACY_ENTRY();
SubEntry = new LEGACY_ENTRY;
SubEntry->Title = L"Boot "_XSW + LoaderTitle;
// SubEntry->Tag = TAG_LEGACY;
SubEntry->Volume = Entry->Volume;

View File

@ -931,7 +931,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
// DBG("OSType =%d\n", OSType);
// DBG("prepare the menu entry\n");
// prepare the menu entry
Entry = new LOADER_ENTRY();
Entry = new LOADER_ENTRY;
if (!CustomEntry) {
// Ignore this loader if it's device path is already present in another loader

View File

@ -75,13 +75,13 @@ void AddSecureBootTool(void)
}
//panic("not done yet");
// if (gSettings.Boot.SecureBoot) {
// Entry = new REFIT_MENU_ENTRY_SECURE_BOOT();
// Entry = new REFIT_MENU_ENTRY_SECURE_BOOT;
// Entry->Title.SWPrintf("Clover Secure Boot Configuration");
//// Entry->Tag = TAG_SECURE_BOOT_CONFIG;
// Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG);
//
// } else {
// Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG();
// Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG;
// Entry->Title.SWPrintf("Enable Clover Secure Boot");
//// Entry->Tag = TAG_SECURE_BOOT;
// Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT);

View File

@ -90,7 +90,7 @@ STATIC BOOLEAN AddToolEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *Full
return FALSE;
}
// Allocate the entry
Entry = new REFIT_MENU_ENTRY_LOADER_TOOL();
Entry = new REFIT_MENU_ENTRY_LOADER_TOOL;
if (FullTitle) {
Entry->Title.takeValueFrom(FullTitle);
@ -124,7 +124,7 @@ STATIC void AddCloverEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *Loade
// EFI_STATUS Status;
// prepare the menu entry
Entry = new REFIT_MENU_ENTRY_CLOVER();
Entry = new REFIT_MENU_ENTRY_CLOVER;
Entry->Title.takeValueFrom(LoaderTitle);
// Entry->Tag = TAG_CLOVER;
Entry->Row = 1;

View File

@ -387,7 +387,7 @@ void REFIT_MENU_SCREEN::HidePointer()
EFI_STATUS REFIT_MENU_SCREEN::MouseBirth()
{
//if ( !mPointer ) mPointer = new XPointer();
//if ( !mPointer ) mPointer = new XPointer;
return mPointer.MouseBirth();
}
@ -398,7 +398,7 @@ void REFIT_MENU_SCREEN::KillMouse()
void REFIT_MENU_SCREEN::AddMenuInfoLine_f(CONST char *format, ...)
{
XStringW* s = new XStringW();
XStringW* s = new XStringW;
VA_LIST va;
VA_START(va, format);
s->vSWPrintf(format, va);

View File

@ -47,7 +47,7 @@
REFIT_MENU_ENTRY_CLOVER* REFIT_MENU_ENTRY_CLOVER::getPartiallyDuplicatedEntry() const
{
REFIT_MENU_ENTRY_CLOVER* DuplicateEntry = new REFIT_MENU_ENTRY_CLOVER();
REFIT_MENU_ENTRY_CLOVER* DuplicateEntry = new REFIT_MENU_ENTRY_CLOVER;
DuplicateEntry->AtClick = ActionEnter;
DuplicateEntry->Volume = Volume;
@ -62,7 +62,7 @@ REFIT_MENU_ENTRY_CLOVER* REFIT_MENU_ENTRY_CLOVER::getPartiallyDuplicatedEntry()
LOADER_ENTRY* LOADER_ENTRY::getPartiallyDuplicatedEntry() const
{
LOADER_ENTRY* DuplicateEntry = new LOADER_ENTRY();
LOADER_ENTRY* DuplicateEntry = new LOADER_ENTRY;
DuplicateEntry->AtClick = ActionEnter;
DuplicateEntry->Volume = Volume;

View File

@ -8,6 +8,7 @@
#ifndef INCLUDE_PCI_H_
#define INCLUDE_PCI_H_
#include <stdint.h>
/* PCI */
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
@ -24,18 +25,18 @@
typedef struct {
UINT32 :2;
UINT32 reg :6;
UINT32 func:3;
UINT32 dev :5;
UINT32 bus :8;
UINT32 :7;
UINT32 eb :1;
uint32_t :2;
uint32_t reg :6;
uint32_t func:3;
uint32_t dev :5;
uint32_t bus :8;
uint32_t :7;
uint32_t eb :1;
} pci_addr_t;
typedef union {
pci_addr_t bits;
UINT32 addr;
uint32_t addr;
} pci_dev_t;
typedef struct pci_dt_t {

View File

@ -356,7 +356,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
if (Dict != NULL) {
INTN Count = Get_TagCount (Dict);
for (INTN i = 0; i < Count; i++) {
FILM *NewFilm = new FILM();
FILM *NewFilm = new FILM;
if (EFI_ERROR(GetElement(Dict, i, &Dict3))) {
continue;
}

View File

@ -680,7 +680,7 @@ XTheme::GetThemeTagSettings(const TagDict* DictPointer)
}
Dict3 = AnimeArray->dictElementAt(i, "Anime"_XS8);
FILM *NewFilm = new FILM();
FILM *NewFilm = new FILM;
Prop = Dict3->propertyForKey("ID");
NewFilm->SetIndex((UINTN)GetPropertyAsInteger(Prop, 1)); //default=main screen

View File

@ -1531,7 +1531,7 @@ REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MEN
Entry->Image = OptionMenu.TitleImage;
Entry->AtClick = AtClick;
// create the submenu
*SubScreen = new REFIT_MENU_SCREEN();
*SubScreen = new REFIT_MENU_SCREEN;
(*SubScreen)->Title = Entry->Title;
(*SubScreen)->TitleImage = Entry->Image;
(*SubScreen)->ID = ID;
@ -1542,7 +1542,7 @@ REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MEN
REFIT_MENU_ITEM_OPTIONS* newREFIT_MENU_ITEM_OPTIONS(REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, const XString8& Title)
{
REFIT_MENU_ITEM_OPTIONS* Entry = new REFIT_MENU_ITEM_OPTIONS();
REFIT_MENU_ITEM_OPTIONS* Entry = new REFIT_MENU_ITEM_OPTIONS;
return NewEntry_(Entry, SubScreen, AtClick, ID, Title)->getREFIT_MENU_ITEM_OPTIONS();
}
@ -1797,7 +1797,7 @@ LOADER_ENTRY* LOADER_ENTRY::SubMenuKextInjectMgmt()
LOADER_ENTRY *SubEntry;
REFIT_MENU_SCREEN *SubSubScreen;
SubEntry = new LOADER_ENTRY();
SubEntry = new LOADER_ENTRY;
NewEntry_(SubEntry, &SubSubScreen, ActionEnter, SCREEN_SYSTEM, "Block injected kexts->"_XS8);
SubEntry->Flags = Flags;
if (macOSVersion.notEmpty()) {