diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2023-05-01 22:58:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-01 22:58:20 -0400 |
| commit | fcfa28901e91d756ad22f05e6827d7646e484061 (patch) | |
| tree | 70c3fe8e99b5ff52921a3e3b56d8815f5a10da34 /ZAPD/ZDisplayList.cpp | |
| parent | 53e140e8419f9c067de22949bcea45ede750bf75 (diff) | |
Warn hardcoded pointers (Merge Conflict Fix) (#288)
* Warn on hardcoded pointers
* Fix a bunch of false positives
* Move warning to a more common place
* Add -Whardcoded-generic-pointer
* format
---------
Co-authored-by: angie <angheloalf95@gmail.com>
Diffstat (limited to 'ZAPD/ZDisplayList.cpp')
| -rw-r--r-- | ZAPD/ZDisplayList.cpp | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/ZAPD/ZDisplayList.cpp b/ZAPD/ZDisplayList.cpp index a070ac5..27bd966 100644 --- a/ZAPD/ZDisplayList.cpp +++ b/ZAPD/ZDisplayList.cpp @@ -1713,17 +1713,26 @@ static int32_t GfxdCallback_DisplayList(uint32_t seg) uint32_t dListSegNum = GETSEGNUM(seg); std::string dListName = ""; - bool addressFound = Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Gfx", dListName); + bool addressFound = + Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Gfx", dListName, false); - if (!addressFound && self->parent->segment == dListSegNum) + if (!addressFound) { - ZDisplayList* newDList = new ZDisplayList(self->parent); - newDList->ExtractFromBinary( - dListOffset, - self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType)); - newDList->SetName(newDList->GetDefaultName(self->parent->GetName())); - self->otherDLists.push_back(newDList); - dListName = newDList->GetName(); + if (self->parent->segment == dListSegNum) + { + ZDisplayList* newDList = new ZDisplayList(self->parent); + newDList->ExtractFromBinary( + dListOffset, + self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType)); + newDList->SetName(newDList->GetDefaultName(self->parent->GetName())); + self->otherDLists.push_back(newDList); + dListName = newDList->GetName(); + } + else + { + Globals::Instance->WarnHardcodedPointer(seg, self->parent, self, + self->GetRawDataIndex()); + } } gfxd_puts(dListName.c_str()); @@ -1736,21 +1745,31 @@ static int32_t GfxdCallback_Matrix(uint32_t seg) std::string mtxName; ZDisplayList* self = static_cast<ZDisplayList*>(gfxd_udata_get()); - bool addressFound = Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Mtx", mtxName); - if (!addressFound && GETSEGNUM(seg) == self->parent->segment) + bool addressFound = + Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Mtx", mtxName, false); + + if (!addressFound) { - Declaration* decl = - self->parent->GetDeclaration(Seg2Filespace(seg, self->parent->baseAddress)); - if (decl == nullptr) + if (GETSEGNUM(seg) == self->parent->segment) + { + Declaration* decl = + self->parent->GetDeclaration(Seg2Filespace(seg, self->parent->baseAddress)); + if (decl == nullptr) + { + ZMtx mtx(self->parent); + mtx.SetName(mtx.GetDefaultName(self->GetName())); + mtx.ExtractFromFile(Seg2Filespace(seg, self->parent->baseAddress)); + mtx.DeclareVar(self->GetName(), ""); + + mtx.GetSourceOutputCode(self->GetName()); + self->mtxList.push_back(mtx); + mtxName = "&" + mtx.GetName(); + } + } + else { - ZMtx mtx(self->parent); - mtx.SetName(mtx.GetDefaultName(self->GetName())); - mtx.ExtractFromFile(Seg2Filespace(seg, self->parent->baseAddress)); - mtx.DeclareVar(self->GetName(), ""); - - mtx.GetSourceOutputCode(self->GetName()); - self->mtxList.push_back(mtx); - mtxName = "&" + mtx.GetName(); + Globals::Instance->WarnHardcodedPointer(seg, self->parent, self, + self->GetRawDataIndex()); } } |
