Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
- Unused variables
- Variables with same name
  • Loading branch information
visuve committed Apr 5, 2024
1 parent 4cb11f1 commit d5d823e
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 21 deletions.
1 change: 0 additions & 1 deletion commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ bool Commander::addCommand(const std::string& name, Command *cmd, bool overwrite
void Commander::parseCommands()
{
const std::string PROMPT = "$ ";
Command *cmd = NULL;

while (true) {
if (this->context == NULL) throw CmdException("Uninitialized commander context!");
Expand Down
1 change: 1 addition & 0 deletions commander/Commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ friend class Commander;
class Command
{
public:
Command() {}
Command(const std::string& v_desc) : desc(v_desc) {}
virtual ~Command() {}

Expand Down
5 changes: 1 addition & 4 deletions commander/ExeCommander.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class DumpWrapperEntriesCommand : public WrapperCommand
{
public:
DumpWrapperEntriesCommand(const std::string& desc, size_t v_wrapperId = INVALID_WRAPPER)
: WrapperCommand(desc), wrapperId(v_wrapperId) {}
: WrapperCommand(desc, v_wrapperId) {}

virtual void wrapperAction(ExeElementWrapper *wrapper)
{
Expand All @@ -196,9 +196,6 @@ class DumpWrapperEntriesCommand : public WrapperCommand
cmd_util::dumpEntryInfo(lib);
cmd_util::dumpNodeInfo(lib);
}

protected:
size_t wrapperId; //TODO: fetch it from params!
};


Expand Down
4 changes: 2 additions & 2 deletions commander/PECommander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void cmd_util::printStrings(PEFile *pe, size_t limit)
}
size_t count = wrapper->getResStringsCount();

for (size_t i = 0; i < count; i++) {
for (size_t j = 0; j < count; j++) {
if (limit != 0 && limCount >= limit) return;

ResString *resStr = wrapper->getResStringAt(i);
ResString *resStr = wrapper->getResStringAt(j);
if (resStr != NULL) {
OUT_PADDED_OFFSET(std::cout, resStr->offset);
std::cout << " [" << std::dec << resStr->getSize() << "]" << std::endl;
Expand Down
3 changes: 0 additions & 3 deletions commander/PECommander.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ class PrintStringsCommand : public Command

cmd_util::printStrings(pe, limit);
}
protected:
int wrapperId; //TODO: fetch it from params!
};

class PrintWrapperTypesCommand : public Command
Expand Down Expand Up @@ -210,7 +208,6 @@ class SectionDumpCommand : public Command
PEFile *pe = cmd_util::getPEFromContext(context);
if (!pe) return;

size_t sectHdrCount = pe->getSectionsCount(false);
size_t sectCount = pe->getSectionsCount(true);
std:: cout << "Sections count = " << std::dec << sectCount << "\n";
if (sectCount == 0) {
Expand Down
1 change: 0 additions & 1 deletion parser/pe/ExportDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ size_t ExportDirWrapper::mapNames()
bool ExportDirWrapper::wrap()
{
clear();
size_t mapNum = mapNames();

IMAGE_EXPORT_DIRECTORY* exp = exportDir();
if (exp == NULL) return 0;
Expand Down
3 changes: 1 addition & 2 deletions parser/pe/ImportBaseDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void ImportBaseDirWrapper::reloadMapping()
for (size_t i = 0; i < entriesCount; i++) {
ImportBaseEntryWrapper* lib = dynamic_cast<ImportBaseEntryWrapper*> (this->getEntryAt(i));
if (lib == NULL) continue;
size_t libId = lib->entryNum;

size_t funcCount = lib->getEntriesCount();
for (size_t fI = 0; fI < funcCount; fI++) {
Expand Down Expand Up @@ -254,7 +253,7 @@ bool ImportBaseFuncWrapper::isValid()

if (!isByOrdinal()) {
char *fName = this->getFunctionName();
if (!imports_util::isNameValid(m_Exe, libName)) return false;
if (!imports_util::isNameValid(m_Exe, fName)) return false;
}
return true;
}
6 changes: 0 additions & 6 deletions parser/pe/ImportDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ uint64_t ImportedFuncWrapper::getThunkValue()

bool ImportedFuncWrapper::isByOrdinal()
{
bool isOk = false;

void *p = getValuePtr(ImportEntryWrapper::ORIG_FIRST_THUNK);
if (!p) p = getValuePtr(ImportEntryWrapper::FIRST_THUNK);
if (!p) return false;
Expand Down Expand Up @@ -122,13 +120,9 @@ bufsize_t ImportedFuncWrapper::getSize()

void* ImportedFuncWrapper::getFieldPtr(size_t fId, size_t subField)
{
bool is64 = isBit64();
void *entryPtr = this->getPtr();
if (entryPtr == NULL) return NULL;

IMAGE_THUNK_DATA32* en32 = is64 ? NULL : (IMAGE_THUNK_DATA32*) entryPtr;
IMAGE_THUNK_DATA64* en64 = is64 ? (IMAGE_THUNK_DATA64*) entryPtr : NULL;

switch (fId) {
case ORIG_THUNK: return (void*) getValuePtr(ImportEntryWrapper::ORIG_FIRST_THUNK);
case THUNK: return (void*) getValuePtr(ImportEntryWrapper::FIRST_THUNK);
Expand Down
3 changes: 1 addition & 2 deletions parser/pe/SectHdrsWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bufsize_t SectionHdrWrapper::getMappedRawSize()
if (secEnd > peSize) {
const bufsize_t trimmedSize = peSize - secOffset; // trim to the file size
if (virtualSize) {
bufsize_t unit = m_PE->getAlignment(Executable::RVA);
unit = m_PE->getAlignment(Executable::RVA);
if (unit != 0) {
virtualSize = roundupToUnit(virtualSize, unit);
}
Expand Down Expand Up @@ -534,7 +534,6 @@ QString SectHdrsWrapper::getFieldName(size_t fieldId)

SectionHdrWrapper* SectHdrsWrapper::getSecHdrAtOffset(offset_t offset, Executable::addr_type addrType, bool recalculate, bool verbose)
{
size_t size = this->entries.size();
std::map<offset_t, SectionHdrWrapper*> *secMap = NULL;

if (addrType == Executable::RAW) {
Expand Down

0 comments on commit d5d823e

Please sign in to comment.