Skip to content

Commit

Permalink
DO NOT explicitly call default ctor with new because of clang bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
jief666 committed May 5, 2021
1 parent 8dab184 commit d52803e
Show file tree
Hide file tree
Showing 31 changed files with 58 additions and 52 deletions.
6 changes: 3 additions & 3 deletions rEFIt_UEFI/Platform/FixBiosDsdt.cpp
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions rEFIt_UEFI/Platform/Settings.h
Expand Up @@ -1029,7 +1029,7 @@ class SETTINGS_DATA {
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);
}
Expand All @@ -1048,7 +1048,7 @@ class SETTINGS_DATA {
// 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);
// }
Expand Down Expand Up @@ -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());
Expand All @@ -2009,15 +2009,15 @@ 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();
else newProp->Label = S8Printf("!%ls", Prop.DevicePathAsString.wc_str()).forgetDataWithoutFreeing();
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;
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/Platform/SettingsUtils.h
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/StartupSound.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/kext_inject.cpp
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagArray.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagBool.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagData.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagDate.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagDict.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagFloat.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagInt64.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagKey.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagString8.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/plist.cpp
Expand Up @@ -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;
Expand Down
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/cpp_foundation/shared_ptr.h
Expand Up @@ -75,7 +75,7 @@ class Shared_ptr {
explicit Shared_ptr(T* ptr = nullptr)
{
m_ptr = ptr;
m_counter = new Counter();
m_counter = new Counter;
if (ptr) {
++(*m_counter);
}
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/cpp_lib/XmlLiteArrayTypes.h
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/cpp_lib/XmlLiteDictTypes.h
Expand Up @@ -97,7 +97,7 @@ class _XmlRepeatingDict : public XmlAbstractType
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; }

Expand Down
5 changes: 5 additions & 0 deletions rEFIt_UEFI/cpp_lib/XmlLiteParser.cpp
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/cpp_lib/XmlLiteSimpleTypes.h
Expand Up @@ -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; };
Expand Down
6 changes: 3 additions & 3 deletions rEFIt_UEFI/entry_scan/legacy.cpp
Expand Up @@ -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 {
Expand Down Expand Up @@ -181,15 +181,15 @@ 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());

SubScreen->TitleImage = Entry->Image; //it is XIcon
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;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/entry_scan/loader.cpp
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/entry_scan/securemenu.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/entry_scan/tool.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp
Expand Up @@ -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();
}

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/gui/menu_items/menu_items.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions rEFIt_UEFI/include/Pci.h
Expand Up @@ -8,6 +8,7 @@
#ifndef INCLUDE_PCI_H_
#define INCLUDE_PCI_H_

#include <stdint.h>

/* PCI */
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
Expand All @@ -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 {
Expand Down

0 comments on commit d52803e

Please sign in to comment.