Misc: Fix a bunch of recent warnings from clang

This commit is contained in:
Connor McLaughlin 2022-05-25 01:12:56 +10:00 committed by refractionpcsx2
parent cefe4b773c
commit b5721a92e9
14 changed files with 60 additions and 55 deletions

View File

@ -169,12 +169,12 @@ private: \
public: \
virtual ~classname() = default; \
\
virtual void Rethrow() const \
virtual void Rethrow() const override \
{ \
throw *this; \
} \
\
virtual classname* Clone() const \
virtual classname* Clone() const override \
{ \
return new classname(*this); \
}
@ -245,8 +245,8 @@ public: \
// overridden message formatters only use the diagnostic version...
}
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const override;
virtual std::string FormatDiagnosticMessage() const override;
};
// ---------------------------------------------------------------------------------------
@ -269,8 +269,8 @@ public: \
public:
OutOfMemory(std::string allocdesc);
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const override;
virtual std::string FormatDiagnosticMessage() const override;
};
class ParseError : public RuntimeError
@ -292,8 +292,8 @@ public: \
VirtualMemoryMapConflict(std::string allocdesc);
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const override;
virtual std::string FormatDiagnosticMessage() const override;
};
class HardwareDeficiency : public RuntimeError
@ -307,26 +307,23 @@ public: \
// Stream / BadStream / CannotCreateStream / FileNotFound / AccessDenied / EndOfStream
// ---------------------------------------------------------------------------------------
#define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \
virtual classname& SetStreamName(std::string name) \
{ \
StreamName = std::move(name); \
return *this; \
} \
\
virtual classname& SetStreamName(const char* name) \
{ \
StreamName = name; \
return *this; \
}
#define DEFINE_STREAM_EXCEPTION(classname, parent) \
DEFINE_RUNTIME_EXCEPTION(classname, parent, "") \
classname(std::string filename) \
{ \
StreamName = filename; \
} \
DEFINE_STREAM_EXCEPTION_ACCESSORS(classname)
virtual classname& SetStreamName(std::string name) override \
{ \
StreamName = std::move(name); \
return *this; \
} \
\
virtual classname& SetStreamName(const char* name) override \
{ \
StreamName = name; \
return *this; \
}
// A generic base error class for bad streams -- corrupted data, sudden closures, loss of
// connection, or anything else that would indicate a failure to open a stream or read the
@ -334,13 +331,28 @@ public: \
//
class BadStream : public RuntimeError
{
DEFINE_STREAM_EXCEPTION(BadStream, RuntimeError)
DEFINE_RUNTIME_EXCEPTION(BadStream, RuntimeError, "")
public:
BadStream(std::string filename)
: StreamName(std::move(filename))
{
}
virtual BadStream& SetStreamName(std::string name)
{
StreamName = std::move(name);
return *this;
}
virtual BadStream& SetStreamName(const char* name)
{
StreamName = name;
return *this;
}
std::string StreamName; // name of the stream (if applicable)
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const override;
virtual std::string FormatDisplayMessage() const override;
protected:
void _formatDiagMsg(std::string& dest) const;
@ -353,8 +365,8 @@ public: \
{
DEFINE_STREAM_EXCEPTION(CannotCreateStream, BadStream)
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const override;
virtual std::string FormatDisplayMessage() const override;
};
// Exception thrown when an attempt to open a non-existent file is made.
@ -365,8 +377,8 @@ public: \
public:
DEFINE_STREAM_EXCEPTION(FileNotFound, CannotCreateStream)
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const override;
virtual std::string FormatDisplayMessage() const override;
};
class AccessDenied : public CannotCreateStream
@ -374,8 +386,8 @@ public: \
public:
DEFINE_STREAM_EXCEPTION(AccessDenied, CannotCreateStream)
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const override;
virtual std::string FormatDisplayMessage() const override;
};
// EndOfStream can be used either as an error, or used just as a shortcut for manual
@ -386,8 +398,8 @@ public: \
public:
DEFINE_STREAM_EXCEPTION(EndOfStream, BadStream)
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const override;
virtual std::string FormatDisplayMessage() const override;
};
#ifdef _WIN32
@ -406,8 +418,8 @@ public: \
WinApiError();
std::string GetMsgFromWindows() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const override;
virtual std::string FormatDiagnosticMessage() const override;
};
#endif
} // namespace Exception

View File

@ -23,9 +23,6 @@
#include <QtWidgets/QMessageBox>
// Limit UI update times to 4 per second, so we don't spend longer redrawing the UI than scanning
static constexpr float UI_UPDATE_INTERVAL = 0.25f;
AsyncRefreshProgressCallback::AsyncRefreshProgressCallback(GameListRefreshThread* parent)
: m_parent(parent)
{

View File

@ -1846,7 +1846,7 @@ std::optional<bool> MainWindow::promptForResumeState(const QString& save_state_p
QPushButton* load = msgbox.addButton(tr("Load State"), QMessageBox::AcceptRole);
QPushButton* boot = msgbox.addButton(tr("Fresh Boot"), QMessageBox::RejectRole);
QPushButton* delboot = msgbox.addButton(tr("Delete And Boot"), QMessageBox::RejectRole);
QPushButton* cancel = msgbox.addButton(QMessageBox::Cancel);
msgbox.addButton(QMessageBox::Cancel);
msgbox.setDefaultButton(load);
msgbox.exec();

View File

@ -217,7 +217,7 @@ void InputBindingDialog::inputManagerHookCallback(InputBindingKey key, float val
{
InputBindingKey key_to_add = key;
key_to_add.negative = (value < 0.0f);
m_new_bindings.push_back(key);
m_new_bindings.push_back(key_to_add);
}
}

View File

@ -110,7 +110,7 @@ static void WriteIndexToFile(Access* index, const char* filename)
}
}
static constexpr char* INDEX_TEMPLATE_KEY = "$(f)";
static const char* INDEX_TEMPLATE_KEY = "$(f)";
// template:
// must contain one and only one instance of '$(f)' (without the quotes)

View File

@ -64,7 +64,7 @@ void ElfObject::initElfHeaders(bool isPSXElf)
if (header.e_phnum > 0)
{
if ((header.e_phoff + sizeof(ELF_PHR)) <= data.GetSizeInBytes())
if ((header.e_phoff + sizeof(ELF_PHR)) <= static_cast<u32>(data.GetSizeInBytes()))
proghead = reinterpret_cast<ELF_PHR*>(&data[header.e_phoff]);
else
Console.Error("(ELF) Program header offset %u is larger than file size %u", header.e_phoff, data.GetSizeInBytes());
@ -72,7 +72,7 @@ void ElfObject::initElfHeaders(bool isPSXElf)
if (header.e_shnum > 0)
{
if ((header.e_shoff + sizeof(ELF_SHR)) <= data.GetSizeInBytes())
if ((header.e_shoff + sizeof(ELF_SHR)) <= static_cast<u32>(data.GetSizeInBytes()))
secthead = reinterpret_cast<ELF_SHR*>(&data[header.e_shoff]);
else
Console.Error("(ELF) Section header offset %u is larger than file size %u", header.e_shoff, data.GetSizeInBytes());

View File

@ -494,8 +494,6 @@ void GameList::ScanDirectory(const char* path, bool recursive, const std::vector
progress->SetProgressRange(static_cast<u32>(files.size()));
progress->SetProgressValue(0);
u32 cached_files = 0;
for (FILESYSTEM_FIND_DATA& ffd : files)
{
if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) ||

View File

@ -594,7 +594,6 @@ void GSRenderer::VSync(u32 field, bool registers_written)
if (GSTexture* t = g_gs_device->GetCurrent())
{
const std::string path(m_snapshot + ".png");
const std::string_view filename(Path::GetFileName(path));
if (t->Save(path))
{
Host::AddKeyedOSDMessage("GSScreenshot",

View File

@ -2896,12 +2896,10 @@ void GSTextureCache::PreloadTexture(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
const GSOffset off(mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM));
const int read_width = std::max(tw, psm.bs.x);
u32 pitch = static_cast<u32>(read_width) * sizeof(u32);
u32 row_size = static_cast<u32>(tw) * sizeof(u32);
GSLocalMemory::readTexture rtx = psm.rtx;
if (paltex)
{
pitch >>= 2;
row_size >>= 2;
rtx = psm.rtxP;
}

View File

@ -782,7 +782,7 @@ void Pcsx2Config::DEV9Options::LoadSave(SettingsWrapper& wrap)
SettingsWrapEntryEx(hostCount, "Count");
}
for (size_t i = 0; i < hostCount; i++)
for (int i = 0; i < hostCount; i++)
{
std::string section = "DEV9/Eth/Hosts/Host" + std::to_string(i);
SettingsWrapSection(section.c_str());

View File

@ -34,8 +34,8 @@ public:
cpuRegisters cpuState;
public:
u32 GetPc() const { return cpuState.pc; }
bool IsDelaySlot() const { return !!cpuState.IsDelaySlot; }
u32 GetPc() const override { return cpuState.pc; }
bool IsDelaySlot() const override { return !!cpuState.IsDelaySlot; }
std::string& Message() override { return m_message; }
std::string FormatMessage() const

View File

@ -604,6 +604,8 @@ void InputRecording::IncrementFrameCounter()
case InputRecordingMode::Replaying:
if (frameCounter == inputRecordingData.GetTotalFrames())
incrementUndo = false;
default:
break;
}
}
}
@ -823,4 +825,4 @@ std::string InputRecording::resolveGameName()
return !gameName.empty() ? gameName : VMManager::GetGameName();
}
#endif
#endif

View File

@ -356,7 +356,7 @@ namespace Exception
{
DEFINE_STREAM_EXCEPTION(SaveStateLoadError, BadStream)
virtual std::string FormatDiagnosticMessage() const;
virtual std::string FormatDisplayMessage() const;
virtual std::string FormatDiagnosticMessage() const override;
virtual std::string FormatDisplayMessage() const override;
};
}; // namespace Exception

View File

@ -104,7 +104,6 @@ namespace VMManager
static std::unique_ptr<SysMainMemory> s_vm_memory;
static std::unique_ptr<SysCpuProviderPack> s_cpu_provider_pack;
static std::unique_ptr<INISettingsInterface> s_game_settings_interface;
static u64 s_emu_thread_affinity;
static std::atomic<VMState> s_state{VMState::Shutdown};
static std::atomic_bool s_cpu_implementation_changed{false};