From f44852bb18ddaa759b3b86ba357360bca6375a8b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Dec 2022 20:32:12 -0800 Subject: [PATCH 1/6] Global: Cleanup virtual/override specifiers. Also missing virtual destructors, hidden non-overrides, etc. --- Common/CodeBlock.h | 5 +- Common/ConsoleListener.h | 2 +- Common/Data/Text/WrapText.h | 1 + Common/File/VFS/AssetReader.h | 8 ++-- Common/GPU/D3D9/thin3d_d3d9.cpp | 6 +-- Common/GPU/OpenGL/thin3d_gl.cpp | 4 +- Common/GPU/Vulkan/thin3d_vulkan.cpp | 4 +- Common/GPU/thin3d.h | 5 +- Common/LogManager.h | 13 +++-- Common/Math/expression_parser.h | 1 + Common/Net/URL.h | 11 ++--- Common/UI/UI.h | 5 +- Common/UI/UIScreen.h | 34 ++++++------- Common/UI/ViewGroup.h | 48 +++++++++---------- Core/Debugger/DebugInterface.h | 2 + Core/Debugger/DisassemblyManager.h | 8 +--- Core/Debugger/WebSocket/DisasmSubscriber.cpp | 2 +- .../WebSocket/GPURecordSubscriber.cpp | 2 +- .../Debugger/WebSocket/GPUStatsSubscriber.cpp | 2 +- .../WebSocket/MemoryInfoSubscriber.cpp | 2 +- .../Debugger/WebSocket/SteppingSubscriber.cpp | 2 +- Core/Dialog/PSPGamedataInstallDialog.h | 10 ++-- Core/Dialog/PSPMsgDialog.h | 14 +++--- Core/Dialog/PSPNetconfDialog.h | 12 ++--- Core/Dialog/PSPNpSigninDialog.h | 12 ++--- Core/Dialog/PSPOskDialog.h | 14 +++--- Core/Dialog/PSPPlaceholderDialog.h | 6 +-- Core/Dialog/PSPSaveDialog.h | 14 +++--- Core/Dialog/PSPScreenshotDialog.h | 12 ++--- Core/FileLoaders/CachingFileLoader.h | 2 +- Core/FileLoaders/DiskCachingFileLoader.h | 2 +- Core/FileLoaders/HTTPFileLoader.h | 16 +++---- Core/FileLoaders/LocalFileLoader.h | 12 ++--- Core/FileLoaders/RamCachingFileLoader.h | 2 +- Core/FileSystems/FileSystem.h | 22 ++++----- Core/Loaders.h | 2 +- Core/MIPS/IR/IRJit.h | 2 +- Core/MIPS/x86/IRToX86.h | 2 +- Core/MIPS/x86/Jit.h | 2 +- Core/Screenshot.cpp | 2 +- Core/ThreadEventQueue.h | 2 + GPU/Common/GPUDebugInterface.h | 1 + GPU/Common/SplineCommon.h | 6 +-- GPU/D3D11/DrawEngineD3D11.h | 2 +- GPU/D3D11/GPU_D3D11.h | 3 -- GPU/Directx9/DrawEngineDX9.h | 2 +- GPU/Directx9/GPU_DX9.h | 3 -- GPU/GLES/DrawEngineGLES.cpp | 4 -- GPU/GLES/DrawEngineGLES.h | 4 +- GPU/GLES/GPU_GLES.h | 3 -- GPU/GPUCommon.h | 2 +- GPU/Vulkan/DrawEngineVulkan.h | 2 +- GPU/Vulkan/GPU_Vulkan.h | 3 -- GPU/Vulkan/TextureCacheVulkan.cpp | 4 +- GPU/Vulkan/TextureCacheVulkan.h | 2 +- Qt/QtHost.h | 26 +++++----- UI/DisplayLayoutScreen.cpp | 2 +- UI/GameInfoCache.cpp | 2 +- UI/InstallZipScreen.h | 6 +-- UI/MainScreen.cpp | 9 +--- UI/MainScreen.h | 1 - UI/MiscScreens.cpp | 9 +--- UI/MiscScreens.h | 4 +- UI/PauseScreen.h | 2 +- UI/RemoteISOScreen.h | 2 +- UI/ReportScreen.cpp | 16 +++---- UI/TouchControlLayoutScreen.h | 16 +++---- Windows/CaptureDevice.h | 14 +++--- Windows/DSoundStream.h | 2 +- Windows/Debugger/Debugger_Lists.h | 41 ++++++++-------- Windows/Debugger/Debugger_MemoryDlg.h | 6 +-- Windows/Debugger/Debugger_VFPUDlg.h | 4 +- Windows/DinputDevice.h | 2 +- Windows/GEDebugger/GEDebugger.h | 4 +- Windows/GEDebugger/TabDisplayLists.h | 28 ++++++----- Windows/GEDebugger/TabState.h | 2 +- Windows/GEDebugger/TabVertices.h | 14 +++--- Windows/WASAPIStream.cpp | 2 +- Windows/WASAPIStream.h | 2 +- Windows/XinputDevice.h | 2 +- headless/Compare.cpp | 4 +- headless/Headless.cpp | 2 +- unittest/TestThreadManager.cpp | 4 +- 83 files changed, 283 insertions(+), 315 deletions(-) diff --git a/Common/CodeBlock.h b/Common/CodeBlock.h index e76bbf40ce..0307cf9df6 100644 --- a/Common/CodeBlock.h +++ b/Common/CodeBlock.h @@ -57,7 +57,10 @@ private: public: CodeBlock() {} - virtual ~CodeBlock() { if (region) FreeCodeSpace(); } + ~CodeBlock() { + if (region) + FreeCodeSpace(); + } // Call this before you generate any code. void AllocCodeSpace(int size) { diff --git a/Common/ConsoleListener.h b/Common/ConsoleListener.h index 976e7531cd..32a32b7981 100644 --- a/Common/ConsoleListener.h +++ b/Common/ConsoleListener.h @@ -41,7 +41,7 @@ public: #if defined(USING_WIN_UI) COORD GetCoordinates(int BytesRead, int BufferWidth); #endif - void Log(const LogMessage &message); + void Log(const LogMessage &message) override; void ClearScreen(bool Cursor = true); void Show(bool bShow); diff --git a/Common/Data/Text/WrapText.h b/Common/Data/Text/WrapText.h index bcdd19a6fd..d51f860362 100644 --- a/Common/Data/Text/WrapText.h +++ b/Common/Data/Text/WrapText.h @@ -7,6 +7,7 @@ public: WordWrapper(const char *str, float maxW, int flags) : str_(str), maxW_(maxW), flags_(flags) { } + virtual ~WordWrapper() {} std::string Wrapped(); diff --git a/Common/File/VFS/AssetReader.h b/Common/File/VFS/AssetReader.h index df0c4f2821..36ccd60161 100644 --- a/Common/File/VFS/AssetReader.h +++ b/Common/File/VFS/AssetReader.h @@ -47,10 +47,10 @@ class DirectoryAssetReader : public AssetReader { public: explicit DirectoryAssetReader(const Path &path); // use delete[] - virtual uint8_t *ReadAsset(const char *path, size_t *size); - virtual bool GetFileListing(const char *path, std::vector *listing, const char *filter); - virtual bool GetFileInfo(const char *path, File::FileInfo *info); - virtual std::string toString() const { + uint8_t *ReadAsset(const char *path, size_t *size) override; + bool GetFileListing(const char *path, std::vector *listing, const char *filter) override; + bool GetFileInfo(const char *path, File::FileInfo *info) override; + std::string toString() const override { return path_.ToString(); } diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index e50eb3b1c8..94bce31760 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -291,7 +291,7 @@ public: D3D9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, const TextureDesc &desc); ~D3D9Texture(); void SetToSampler(LPDIRECT3DDEVICE9 device, int sampler); - LPDIRECT3DBASETEXTURE9 Texture() const { + LPDIRECT3DBASETEXTURE9 TexturePtr() const { // TODO: Cleanup if (tex_) { return tex_; @@ -590,7 +590,7 @@ public: case NativeObject::DEVICE_EX: return (uint64_t)(uintptr_t)deviceEx_; case NativeObject::TEXTURE_VIEW: - return (uint64_t)(((D3D9Texture *)srcObject)->Texture()); + return (uint64_t)(((D3D9Texture *)srcObject)->TexturePtr()); default: return 0; } @@ -1007,7 +1007,7 @@ public: device->CreateVertexBuffer((UINT)size, usage, 0, D3DPOOL_DEFAULT, &vbuffer_, NULL); } } - virtual ~D3D9Buffer() override { + ~D3D9Buffer() { if (ibuffer_) { ibuffer_->Release(); } diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 2536d2beea..6ea0ddc1dd 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -324,7 +324,7 @@ class OpenGLTexture; class OpenGLContext : public DrawContext { public: OpenGLContext(); - virtual ~OpenGLContext(); + ~OpenGLContext(); void SetTargetSize(int w, int h) override { DrawContext::SetTargetSize(w, h); @@ -1084,7 +1084,7 @@ public: buffer_ = render->CreateBuffer(target_, size, usage_); totalSize_ = size; } - ~OpenGLBuffer() override { + ~OpenGLBuffer() { render_->DeleteBuffer(buffer_); } diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 9cfcbea7c9..bb57abdea4 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -382,7 +382,7 @@ class VKFramebuffer; class VKContext : public DrawContext { public: VKContext(VulkanContext *vulkan); - virtual ~VKContext(); + ~VKContext(); void DebugAnnotate(const char *annotation) override; @@ -1362,7 +1362,7 @@ public: VKBuffer(size_t size, uint32_t flags) : dataSize_(size) { data_ = new uint8_t[size]; } - ~VKBuffer() override { + ~VKBuffer() { delete[] data_; } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 78ae3375b8..76afa314be 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -483,10 +483,7 @@ public: virtual ShaderStage GetStage() const = 0; }; -class Pipeline : public RefCountedObject { -public: - virtual ~Pipeline() {} -}; +class Pipeline : public RefCountedObject { }; class RasterState : public RefCountedObject {}; diff --git a/Common/LogManager.h b/Common/LogManager.h index 65423b6121..5d8afddae5 100644 --- a/Common/LogManager.h +++ b/Common/LogManager.h @@ -55,7 +55,7 @@ public: FileLogListener(const char *filename); ~FileLogListener(); - void Log(const LogMessage &msg); + void Log(const LogMessage &msg) override; bool IsValid() { if (!fp_) return false; else return true; } bool IsEnabled() const { return m_enable; } @@ -71,13 +71,12 @@ private: class OutputDebugStringLogListener : public LogListener { public: - void Log(const LogMessage &msg); + void Log(const LogMessage &msg) override; }; class RingbufferLogListener : public LogListener { public: - RingbufferLogListener() : curMessage_(0), count_(0), enabled_(false) {} - void Log(const LogMessage &msg); + void Log(const LogMessage &msg) override; bool IsEnabled() const { return enabled_; } void SetEnabled(bool enable) { enabled_ = enable; } @@ -89,9 +88,9 @@ public: private: enum { MAX_LOGS = 128 }; LogMessage messages_[MAX_LOGS]; - int curMessage_; - int count_; - bool enabled_; + int curMessage_ = 0; + int count_ = 0; + bool enabled_ = false; }; // TODO: A simple buffered log that can be used to display the log in-window diff --git a/Common/Math/expression_parser.h b/Common/Math/expression_parser.h index 3d39340a42..55de0a234a 100644 --- a/Common/Math/expression_parser.h +++ b/Common/Math/expression_parser.h @@ -15,6 +15,7 @@ enum ExpressionType class IExpressionFunctions { public: + virtual ~IExpressionFunctions() {} virtual bool parseReference(char* str, uint32_t& referenceIndex) = 0; virtual bool parseSymbol(char* str, uint32_t& symbolValue) = 0; virtual uint32_t getReferenceValue(uint32_t referenceIndex) = 0; diff --git a/Common/Net/URL.h b/Common/Net/URL.h index 7fcaa0c455..e7f33e6d8a 100644 --- a/Common/Net/URL.h +++ b/Common/Net/URL.h @@ -15,6 +15,8 @@ struct UrlEncoder { + virtual ~UrlEncoder() {} + UrlEncoder() : paramCount(0) { data.reserve(256); @@ -129,8 +131,7 @@ struct MultipartFormDataEncoder : UrlEncoder boundary = temp; } - virtual void Add(const std::string &key, const std::string &value) - { + void Add(const std::string &key, const std::string &value) override { Add(key, value, "", ""); } @@ -158,13 +159,11 @@ struct MultipartFormDataEncoder : UrlEncoder Add(key, std::string((const char *)&value[0], value.size()), filename, mimeType); } - virtual void Finish() - { + void Finish() override { data += "--" + boundary + "--"; } - virtual std::string GetMimeType() const - { + std::string GetMimeType() const override { return "multipart/form-data; boundary=\"" + boundary + "\""; } diff --git a/Common/UI/UI.h b/Common/UI/UI.h index ccd6b50dbe..4357693d16 100644 --- a/Common/UI/UI.h +++ b/Common/UI/UI.h @@ -43,6 +43,7 @@ extern DrawBuffer ui_draw2d_front; // for things that need to be on top of the r // Implement this interface to style your lists class UIListAdapter { public: + virtual ~UIListAdapter() {} virtual size_t getCount() const = 0; virtual void drawItem(int item, int x, int y, int w, int h, bool active) const = 0; virtual float itemHeight(int itemIndex) const { return 64; } @@ -52,8 +53,8 @@ public: class StringVectorListAdapter : public UIListAdapter { public: StringVectorListAdapter(const std::vector *items) : items_(items) {} - virtual size_t getCount() const { return items_->size(); } - virtual void drawItem(int item, int x, int y, int w, int h, bool active) const; + size_t getCount() const override { return items_->size(); } + void drawItem(int item, int x, int y, int w, int h, bool active) const override; private: const std::vector *items_; diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index 03a8f8a18a..50a5f1f2d9 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -74,12 +74,12 @@ public: PopupScreen(std::string title, std::string button1 = "", std::string button2 = ""); virtual void CreatePopupContents(UI::ViewGroup *parent) = 0; - virtual void CreateViews() override; - virtual bool isTransparent() const override { return true; } - virtual bool touch(const TouchInput &touch) override; - virtual bool key(const KeyInput &key) override; + void CreateViews() override; + bool isTransparent() const override { return true; } + bool touch(const TouchInput &touch) override; + bool key(const KeyInput &key) override; - virtual void TriggerFinish(DialogResult result) override; + void TriggerFinish(DialogResult result) override; void SetPopupOrigin(const UI::View *view); void SetPopupOffset(float y); @@ -95,7 +95,7 @@ protected: virtual bool HasTitleBar() const { return true; } const std::string &Title() { return title_; } - virtual void update() override; + void update() override; private: UI::ViewGroup *box_; @@ -143,9 +143,9 @@ public: UI::Event OnChoice; protected: - virtual bool FillVertical() const override { return false; } - virtual bool ShowButtons() const override { return showButtons_; } - virtual void CreatePopupContents(UI::ViewGroup *parent) override; + bool FillVertical() const override { return false; } + bool ShowButtons() const override { return showButtons_; } + void CreatePopupContents(UI::ViewGroup *parent) override; UI::StringVectorListAdaptor adaptor_; UI::ListView *listView_ = nullptr; @@ -164,9 +164,9 @@ public: UI::Event OnChoice; protected: - virtual bool FillVertical() const override { return false; } - virtual bool ShowButtons() const override { return true; } - virtual void CreatePopupContents(UI::ViewGroup *parent) override; + bool FillVertical() const override { return false; } + bool ShowButtons() const override { return true; } + void CreatePopupContents(UI::ViewGroup *parent) override; private: void OnCompleted(DialogResult result) override; @@ -182,7 +182,7 @@ class SliderPopupScreen : public PopupScreen { public: SliderPopupScreen(int *value, int minValue, int maxValue, const std::string &title, int step = 1, const std::string &units = "") : PopupScreen(title, "OK", "Cancel"), units_(units), value_(value), minValue_(minValue), maxValue_(maxValue), step_(step) {} - virtual void CreatePopupContents(ViewGroup *parent) override; + void CreatePopupContents(ViewGroup *parent) override; void SetNegativeDisable(const std::string &str) { negativeLabel_ = str; @@ -198,7 +198,7 @@ private: EventReturn OnIncrease(EventParams ¶ms); EventReturn OnTextChange(EventParams ¶ms); EventReturn OnSliderChange(EventParams ¶ms); - virtual void OnCompleted(DialogResult result) override; + void OnCompleted(DialogResult result) override; Slider *slider_ = nullptr; UI::TextEdit *edit_ = nullptr; std::string units_; @@ -227,7 +227,7 @@ private: EventReturn OnDecrease(EventParams ¶ms); EventReturn OnTextChange(EventParams ¶ms); EventReturn OnSliderChange(EventParams ¶ms); - virtual void OnCompleted(DialogResult result) override; + void OnCompleted(DialogResult result) override; UI::SliderFloat *slider_; UI::TextEdit *edit_; std::string units_; @@ -245,7 +245,7 @@ class TextEditPopupScreen : public PopupScreen { public: TextEditPopupScreen(std::string *value, const std::string &placeholder, const std::string &title, int maxLen) : PopupScreen(title, "OK", "Cancel"), value_(value), placeholder_(placeholder), maxLen_(maxLen) {} - virtual void CreatePopupContents(ViewGroup *parent) override; + void CreatePopupContents(ViewGroup *parent) override; const char *tag() const override { return "TextEditPopup"; } @@ -378,7 +378,7 @@ public: } protected: - void PostChoiceCallback(int num) { + void PostChoiceCallback(int num) override { *valueStr_ = choices_[num]; } diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index d408548b69..32ddb8eb56 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -24,27 +24,23 @@ struct NeighborResult { class ViewGroup : public View { public: ViewGroup(LayoutParams *layoutParams = 0) : View(layoutParams) {} - virtual ~ViewGroup(); + ~ViewGroup(); // Pass through external events to children. - virtual bool Key(const KeyInput &input) override; - virtual bool Touch(const TouchInput &input) override; - virtual void Axis(const AxisInput &input) override; + bool Key(const KeyInput &input) override; + bool Touch(const TouchInput &input) override; + void Axis(const AxisInput &input) override; // By default, a container will layout to its own bounds. - virtual void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override = 0; - virtual void Layout() override = 0; - virtual void Update() override; - virtual void Query(float x, float y, std::vector &list) override; + void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override = 0; + void Layout() override = 0; + void Update() override; + void Query(float x, float y, std::vector &list) override; - virtual void DeviceLost() override; - virtual void DeviceRestored(Draw::DrawContext *draw) override; + void DeviceLost() override; + void DeviceRestored(Draw::DrawContext *draw) override; - virtual void Draw(UIContext &dc) override; - - // These should be unused. - virtual float GetContentWidth() const { return 0.0f; } - virtual float GetContentHeight() const { return 0.0f; } + void Draw(UIContext &dc) override; // Takes ownership! DO NOT add a view to multiple parents! template @@ -54,8 +50,8 @@ public: return view; } - virtual bool SetFocus() override; - virtual bool SubviewFocused(View *view) override; + bool SetFocus() override; + bool SubviewFocused(View *view) override; virtual void RemoveSubview(View *view); void SetDefaultFocusView(View *view) { defaultFocusView_ = view; } @@ -406,9 +402,9 @@ public: class ChoiceListAdaptor : public ListAdaptor { public: ChoiceListAdaptor(const char *items[], int numItems) : items_(items), numItems_(numItems) {} - virtual View *CreateItemView(int index); - virtual int GetNumItems() { return numItems_; } - virtual bool AddEventCallback(View *view, std::function callback); + View *CreateItemView(int index) override; + int GetNumItems() override { return numItems_; } + bool AddEventCallback(View *view, std::function callback) override; private: const char **items_; @@ -421,12 +417,12 @@ class StringVectorListAdaptor : public ListAdaptor { public: StringVectorListAdaptor() : selected_(-1) {} StringVectorListAdaptor(const std::vector &items, int selected = -1) : items_(items), selected_(selected) {} - virtual View *CreateItemView(int index) override; - virtual int GetNumItems() override { return (int)items_.size(); } - virtual bool AddEventCallback(View *view, std::function callback) override; + View *CreateItemView(int index) override; + int GetNumItems() override { return (int)items_.size(); } + bool AddEventCallback(View *view, std::function callback) override; void SetSelected(int sel) override { selected_ = sel; } - virtual std::string GetTitle(int index) const override { return items_[index]; } - virtual int GetSelected() override { return selected_; } + std::string GetTitle(int index) const override { return items_[index]; } + int GetSelected() override { return selected_; } private: std::vector items_; @@ -440,7 +436,7 @@ public: ListView(ListAdaptor *a, std::set hidden = std::set(), LayoutParams *layoutParams = 0); int GetSelected() { return adaptor_->GetSelected(); } - virtual void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override; + void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override; virtual void SetMaxHeight(float mh) { maxHeight_ = mh; } Event OnChoice; std::string DescribeLog() const override { return "ListView: " + View::DescribeLog(); } diff --git a/Core/Debugger/DebugInterface.h b/Core/Debugger/DebugInterface.h index 6f48c7db0f..a92c8bab26 100644 --- a/Core/Debugger/DebugInterface.h +++ b/Core/Debugger/DebugInterface.h @@ -31,6 +31,8 @@ enum { class DebugInterface { public: + virtual ~DebugInterface() {} + virtual const char *disasm(unsigned int address, unsigned int align) {return "NODEBUGGER";} virtual int getInstructionSize(int instruction) {return 1;} diff --git a/Core/Debugger/DisassemblyManager.h b/Core/Debugger/DisassemblyManager.h index 00ff46c6fc..81520818b1 100644 --- a/Core/Debugger/DisassemblyManager.h +++ b/Core/Debugger/DisassemblyManager.h @@ -99,8 +99,7 @@ private: class DisassemblyOpcode: public DisassemblyEntry { public: - DisassemblyOpcode(u32 _address, int _num): address(_address), num(_num) { }; - virtual ~DisassemblyOpcode() { }; + DisassemblyOpcode(u32 _address, int _num): address(_address), num(_num) { } void recheck() override { }; int getNumLines() override { return num; }; int getLineNum(u32 address, bool findStart) override { return (address - this->address) / 4; }; @@ -118,8 +117,7 @@ private: class DisassemblyMacro: public DisassemblyEntry { public: - DisassemblyMacro(u32 _address): address(_address) { }; - virtual ~DisassemblyMacro() { }; + DisassemblyMacro(u32 _address): address(_address) { } void setMacroLi(u32 _immediate, u8 _rt); void setMacroMemory(std::string _name, u32 _immediate, u8 _rt, int _dataSize); @@ -147,7 +145,6 @@ class DisassemblyData: public DisassemblyEntry { public: DisassemblyData(u32 _address, u32 _size, DataType _type); - virtual ~DisassemblyData() { }; void recheck() override; int getNumLines() override { return (int)lines.size(); }; @@ -179,7 +176,6 @@ class DisassemblyComment: public DisassemblyEntry { public: DisassemblyComment(u32 _address, u32 _size, std::string name, std::string param); - virtual ~DisassemblyComment() { }; void recheck() override { }; int getNumLines() override { return 1; }; diff --git a/Core/Debugger/WebSocket/DisasmSubscriber.cpp b/Core/Debugger/WebSocket/DisasmSubscriber.cpp index 5d766785a2..d467a25cd8 100644 --- a/Core/Debugger/WebSocket/DisasmSubscriber.cpp +++ b/Core/Debugger/WebSocket/DisasmSubscriber.cpp @@ -36,7 +36,7 @@ public: WebSocketDisasmState() { disasm_.setCpu(currentDebugMIPS); } - ~WebSocketDisasmState() override { + ~WebSocketDisasmState() { disasm_.clear(); } diff --git a/Core/Debugger/WebSocket/GPURecordSubscriber.cpp b/Core/Debugger/WebSocket/GPURecordSubscriber.cpp index f31aa26d54..f1aad51e12 100644 --- a/Core/Debugger/WebSocket/GPURecordSubscriber.cpp +++ b/Core/Debugger/WebSocket/GPURecordSubscriber.cpp @@ -23,7 +23,7 @@ #include "GPU/Debugger/Record.h" struct WebSocketGPURecordState : public DebuggerSubscriber { - ~WebSocketGPURecordState() override; + ~WebSocketGPURecordState(); void Dump(DebuggerRequest &req); void Broadcast(net::WebSocketServer *ws) override; diff --git a/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp b/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp index 0d579b6747..1135ad98a2 100644 --- a/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp +++ b/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp @@ -68,7 +68,7 @@ struct DebuggerGPUStatsEvent { struct WebSocketGPUStatsState : public DebuggerSubscriber { WebSocketGPUStatsState(); - ~WebSocketGPUStatsState() override; + ~WebSocketGPUStatsState(); void Get(DebuggerRequest &req); void Feed(DebuggerRequest &req); diff --git a/Core/Debugger/WebSocket/MemoryInfoSubscriber.cpp b/Core/Debugger/WebSocket/MemoryInfoSubscriber.cpp index 30eb8cdd02..139b9124ec 100644 --- a/Core/Debugger/WebSocket/MemoryInfoSubscriber.cpp +++ b/Core/Debugger/WebSocket/MemoryInfoSubscriber.cpp @@ -27,7 +27,7 @@ class WebSocketMemoryInfoState : public DebuggerSubscriber { public: WebSocketMemoryInfoState() { } - ~WebSocketMemoryInfoState() override { + ~WebSocketMemoryInfoState() { UpdateOverride(false); } diff --git a/Core/Debugger/WebSocket/SteppingSubscriber.cpp b/Core/Debugger/WebSocket/SteppingSubscriber.cpp index fcb9296985..b07349a26b 100644 --- a/Core/Debugger/WebSocket/SteppingSubscriber.cpp +++ b/Core/Debugger/WebSocket/SteppingSubscriber.cpp @@ -32,7 +32,7 @@ struct WebSocketSteppingState : public DebuggerSubscriber { WebSocketSteppingState() { disasm_.setCpu(currentDebugMIPS); } - ~WebSocketSteppingState() override { + ~WebSocketSteppingState() { disasm_.clear(); } diff --git a/Core/Dialog/PSPGamedataInstallDialog.h b/Core/Dialog/PSPGamedataInstallDialog.h index a74fdb5254..47febcff9f 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.h +++ b/Core/Dialog/PSPGamedataInstallDialog.h @@ -36,12 +36,12 @@ struct SceUtilityGamedataInstallParam { class PSPGamedataInstallDialog: public PSPDialog { public: PSPGamedataInstallDialog(UtilityDialogType type); - virtual ~PSPGamedataInstallDialog(); + ~PSPGamedataInstallDialog(); - virtual int Init(u32 paramAddr); - virtual int Update(int animSpeed) override; - virtual int Shutdown(bool force = false) override; - virtual void DoState(PointerWrap &p) override; + int Init(u32 paramAddr); + int Update(int animSpeed) override; + int Shutdown(bool force = false) override; + void DoState(PointerWrap &p) override; int Abort(); std::string GetGameDataInstallFileName(SceUtilityGamedataInstallParam *param, std::string filename); diff --git a/Core/Dialog/PSPMsgDialog.h b/Core/Dialog/PSPMsgDialog.h index 78ee4e54f4..32a4831640 100644 --- a/Core/Dialog/PSPMsgDialog.h +++ b/Core/Dialog/PSPMsgDialog.h @@ -59,18 +59,18 @@ struct pspMessageDialog class PSPMsgDialog: public PSPDialog { public: PSPMsgDialog(UtilityDialogType type); - virtual ~PSPMsgDialog(); + ~PSPMsgDialog(); - virtual int Init(unsigned int paramAddr); - virtual int Update(int animSpeed) override; - virtual int Shutdown(bool force = false) override; - virtual void DoState(PointerWrap &p) override; - virtual pspUtilityDialogCommon *GetCommonParam() override; + int Init(unsigned int paramAddr); + int Update(int animSpeed) override; + int Shutdown(bool force = false) override; + void DoState(PointerWrap &p) override; + pspUtilityDialogCommon *GetCommonParam() override; int Abort(); protected: - virtual bool UseAutoStatus() override { + bool UseAutoStatus() override { return false; } diff --git a/Core/Dialog/PSPNetconfDialog.h b/Core/Dialog/PSPNetconfDialog.h index 13d267f5d9..52a3ce203a 100644 --- a/Core/Dialog/PSPNetconfDialog.h +++ b/Core/Dialog/PSPNetconfDialog.h @@ -38,13 +38,13 @@ struct SceUtilityNetconfParam { class PSPNetconfDialog: public PSPDialog { public: PSPNetconfDialog(UtilityDialogType type); - virtual ~PSPNetconfDialog(); + ~PSPNetconfDialog(); - virtual int Init(u32 paramAddr); - virtual int Update(int animSpeed) override; - virtual int Shutdown(bool force = false) override; - virtual void DoState(PointerWrap &p) override; - virtual pspUtilityDialogCommon* GetCommonParam() override; + int Init(u32 paramAddr); + int Update(int animSpeed) override; + int Shutdown(bool force = false) override; + void DoState(PointerWrap &p) override; + pspUtilityDialogCommon* GetCommonParam() override; protected: bool UseAutoStatus() override { diff --git a/Core/Dialog/PSPNpSigninDialog.h b/Core/Dialog/PSPNpSigninDialog.h index 15aac7b0c9..2b31922735 100644 --- a/Core/Dialog/PSPNpSigninDialog.h +++ b/Core/Dialog/PSPNpSigninDialog.h @@ -34,13 +34,13 @@ struct SceUtilityNpSigninParam { class PSPNpSigninDialog: public PSPDialog { public: PSPNpSigninDialog(UtilityDialogType type); - virtual ~PSPNpSigninDialog(); + ~PSPNpSigninDialog(); - virtual int Init(u32 paramAddr); - virtual int Update(int animSpeed) override; - virtual int Shutdown(bool force = false) override; - virtual void DoState(PointerWrap &p) override; - virtual pspUtilityDialogCommon* GetCommonParam() override; + int Init(u32 paramAddr); + int Update(int animSpeed) override; + int Shutdown(bool force = false) override; + void DoState(PointerWrap &p) override; + pspUtilityDialogCommon* GetCommonParam() override; protected: bool UseAutoStatus() override { diff --git a/Core/Dialog/PSPOskDialog.h b/Core/Dialog/PSPOskDialog.h index c760afb1e4..b4aeefc745 100644 --- a/Core/Dialog/PSPOskDialog.h +++ b/Core/Dialog/PSPOskDialog.h @@ -213,16 +213,16 @@ enum class PSPOskNativeStatus { class PSPOskDialog: public PSPDialog { public: PSPOskDialog(UtilityDialogType type); - virtual ~PSPOskDialog(); + ~PSPOskDialog(); - virtual int Init(u32 oskPtr); - virtual int Update(int animSpeed) override; - virtual int Shutdown(bool force = false) override; - virtual void DoState(PointerWrap &p) override; - virtual pspUtilityDialogCommon *GetCommonParam() override; + int Init(u32 oskPtr); + int Update(int animSpeed) override; + int Shutdown(bool force = false) override; + void DoState(PointerWrap &p) override; + pspUtilityDialogCommon *GetCommonParam() override; protected: - virtual bool UseAutoStatus() override { + bool UseAutoStatus() override { return false; } diff --git a/Core/Dialog/PSPPlaceholderDialog.h b/Core/Dialog/PSPPlaceholderDialog.h index 4c81efe636..b494d92944 100644 --- a/Core/Dialog/PSPPlaceholderDialog.h +++ b/Core/Dialog/PSPPlaceholderDialog.h @@ -22,9 +22,9 @@ class PSPPlaceholderDialog: public PSPDialog { public: PSPPlaceholderDialog(UtilityDialogType type); - virtual ~PSPPlaceholderDialog(); + ~PSPPlaceholderDialog(); - virtual int Init(); - virtual int Update(int animSpeed) override; + int Init(); + int Update(int animSpeed) override; }; diff --git a/Core/Dialog/PSPSaveDialog.h b/Core/Dialog/PSPSaveDialog.h index 90f8d6312a..be6024ac52 100644 --- a/Core/Dialog/PSPSaveDialog.h +++ b/Core/Dialog/PSPSaveDialog.h @@ -72,18 +72,18 @@ class PSPSaveDialog: public PSPDialog { public: PSPSaveDialog(UtilityDialogType type); - virtual ~PSPSaveDialog(); + ~PSPSaveDialog(); - virtual int Init(int paramAddr); - virtual int Update(int animSpeed) override; - virtual int Shutdown(bool force = false) override; - virtual void DoState(PointerWrap &p) override; - virtual pspUtilityDialogCommon *GetCommonParam() override; + int Init(int paramAddr); + int Update(int animSpeed) override; + int Shutdown(bool force = false) override; + void DoState(PointerWrap &p) override; + pspUtilityDialogCommon *GetCommonParam() override; void ExecuteIOAction(); protected: - virtual bool UseAutoStatus() override { + bool UseAutoStatus() override { return false; } diff --git a/Core/Dialog/PSPScreenshotDialog.h b/Core/Dialog/PSPScreenshotDialog.h index ae83e9e8ca..760cd8fcc7 100644 --- a/Core/Dialog/PSPScreenshotDialog.h +++ b/Core/Dialog/PSPScreenshotDialog.h @@ -25,13 +25,13 @@ struct SceUtilityScreenshotParams; class PSPScreenshotDialog : public PSPDialog { public: PSPScreenshotDialog(UtilityDialogType type); - virtual ~PSPScreenshotDialog(); + ~PSPScreenshotDialog(); - virtual int Init(u32 paramAddr); - virtual int Update(int animSpeed) override; - virtual int ContStart(); - virtual void DoState(PointerWrap &p) override; - virtual pspUtilityDialogCommon *GetCommonParam() override; + int Init(u32 paramAddr); + int Update(int animSpeed) override; + int ContStart(); + void DoState(PointerWrap &p) override; + pspUtilityDialogCommon *GetCommonParam() override; protected: // TODO: Manage status correctly. diff --git a/Core/FileLoaders/CachingFileLoader.h b/Core/FileLoaders/CachingFileLoader.h index e778265cce..a4299b567d 100644 --- a/Core/FileLoaders/CachingFileLoader.h +++ b/Core/FileLoaders/CachingFileLoader.h @@ -27,7 +27,7 @@ class CachingFileLoader : public ProxiedFileLoader { public: CachingFileLoader(FileLoader *backend); - ~CachingFileLoader() override; + ~CachingFileLoader(); bool Exists() override; bool ExistsFast() override; diff --git a/Core/FileLoaders/DiskCachingFileLoader.h b/Core/FileLoaders/DiskCachingFileLoader.h index bfbf780c2b..a9b75f4406 100644 --- a/Core/FileLoaders/DiskCachingFileLoader.h +++ b/Core/FileLoaders/DiskCachingFileLoader.h @@ -31,7 +31,7 @@ class DiskCachingFileLoaderCache; class DiskCachingFileLoader : public ProxiedFileLoader { public: DiskCachingFileLoader(FileLoader *backend); - ~DiskCachingFileLoader() override; + ~DiskCachingFileLoader(); bool Exists() override; bool ExistsFast() override; diff --git a/Core/FileLoaders/HTTPFileLoader.h b/Core/FileLoaders/HTTPFileLoader.h index 84a4361097..ec92b8b9d5 100644 --- a/Core/FileLoaders/HTTPFileLoader.h +++ b/Core/FileLoaders/HTTPFileLoader.h @@ -30,21 +30,21 @@ class HTTPFileLoader : public FileLoader { public: HTTPFileLoader(const ::Path &filename); - virtual ~HTTPFileLoader() override; + ~HTTPFileLoader(); bool IsRemote() override { return true; } - virtual bool Exists() override; - virtual bool ExistsFast() override; - virtual bool IsDirectory() override; - virtual s64 FileSize() override; - virtual Path GetPath() const override; + bool Exists() override; + bool ExistsFast() override; + bool IsDirectory() override; + s64 FileSize() override; + Path GetPath() const override; - virtual size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override { + size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override { return ReadAt(absolutePos, bytes * count, data, flags) / bytes; } - virtual size_t ReadAt(s64 absolutePos, size_t bytes, void *data, Flags flags = Flags::NONE) override; + size_t ReadAt(s64 absolutePos, size_t bytes, void *data, Flags flags = Flags::NONE) override; void Cancel() override { cancel_ = true; diff --git a/Core/FileLoaders/LocalFileLoader.h b/Core/FileLoaders/LocalFileLoader.h index 9e1f37c10f..8db0b24b02 100644 --- a/Core/FileLoaders/LocalFileLoader.h +++ b/Core/FileLoaders/LocalFileLoader.h @@ -30,15 +30,15 @@ typedef void *HANDLE; class LocalFileLoader : public FileLoader { public: LocalFileLoader(const Path &filename); - virtual ~LocalFileLoader(); + ~LocalFileLoader(); - virtual bool Exists() override; - virtual bool IsDirectory() override; - virtual s64 FileSize() override; - virtual Path GetPath() const override { + bool Exists() override; + bool IsDirectory() override; + s64 FileSize() override; + Path GetPath() const override { return filename_; } - virtual size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override; + size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override; private: #ifndef _WIN32 diff --git a/Core/FileLoaders/RamCachingFileLoader.h b/Core/FileLoaders/RamCachingFileLoader.h index 44c375d442..dde5e74ecb 100644 --- a/Core/FileLoaders/RamCachingFileLoader.h +++ b/Core/FileLoaders/RamCachingFileLoader.h @@ -27,7 +27,7 @@ class RamCachingFileLoader : public ProxiedFileLoader { public: RamCachingFileLoader(FileLoader *backend); - ~RamCachingFileLoader() override; + ~RamCachingFileLoader(); bool Exists() override; bool ExistsFast() override; diff --git a/Core/FileSystems/FileSystem.h b/Core/FileSystems/FileSystem.h index 350b97cd8f..d2eeca6651 100644 --- a/Core/FileSystems/FileSystem.h +++ b/Core/FileSystems/FileSystem.h @@ -77,7 +77,7 @@ public: class SequentialHandleAllocator : public IHandleAllocator { public: SequentialHandleAllocator() : handle_(1) {} - virtual u32 GetNewHandle() override { + u32 GetNewHandle() override { u32 res = handle_++; if (handle_ < 0) { // Some code assumes it'll never become 0. @@ -85,7 +85,7 @@ public: } return res; } - virtual void FreeHandle(u32 handle) override {} + void FreeHandle(u32 handle) override {} private: int handle_; }; @@ -142,7 +142,7 @@ public: class EmptyFileSystem : public IFileSystem { public: - virtual void DoState(PointerWrap &p) override {} + void DoState(PointerWrap &p) override {} std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { if (exists) *exists = false; @@ -158,14 +158,14 @@ public: size_t SeekFile(u32 handle, s32 position, FileMove type) override {return 0;} PSPFileInfo GetFileInfo(std::string filename) override {PSPFileInfo f; return f;} bool OwnsHandle(u32 handle) override {return false;} - virtual bool MkDir(const std::string &dirname) override {return false;} - virtual bool RmDir(const std::string &dirname) override {return false;} - virtual int RenameFile(const std::string &from, const std::string &to) override {return -1;} - virtual bool RemoveFile(const std::string &filename) override {return false;} - virtual int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override {return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED; } - virtual PSPDevType DevType(u32 handle) override { return PSPDevType::INVALID; } - virtual FileSystemFlags Flags() override { return FileSystemFlags::NONE; } - virtual u64 FreeSpace(const std::string &path) override { return 0; } + bool MkDir(const std::string &dirname) override {return false;} + bool RmDir(const std::string &dirname) override {return false;} + int RenameFile(const std::string &from, const std::string &to) override {return -1;} + bool RemoveFile(const std::string &filename) override {return false;} + int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override { return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED; } + PSPDevType DevType(u32 handle) override { return PSPDevType::INVALID; } + FileSystemFlags Flags() override { return FileSystemFlags::NONE; } + u64 FreeSpace(const std::string &path) override { return 0; } bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; } }; diff --git a/Core/Loaders.h b/Core/Loaders.h index fa6c637d9e..2bef2858f5 100644 --- a/Core/Loaders.h +++ b/Core/Loaders.h @@ -94,7 +94,7 @@ public: class ProxiedFileLoader : public FileLoader { public: ProxiedFileLoader(FileLoader *backend) : backend_(backend) {} - ~ProxiedFileLoader() override { + ~ProxiedFileLoader() { // Takes ownership. delete backend_; } diff --git a/Core/MIPS/IR/IRJit.h b/Core/MIPS/IR/IRJit.h index e5aadba24b..973ddf524e 100644 --- a/Core/MIPS/IR/IRJit.h +++ b/Core/MIPS/IR/IRJit.h @@ -136,7 +136,7 @@ private: class IRJit : public JitInterface { public: IRJit(MIPSState *mipsState); - virtual ~IRJit(); + ~IRJit(); void DoState(PointerWrap &p) override; diff --git a/Core/MIPS/x86/IRToX86.h b/Core/MIPS/x86/IRToX86.h index d1555f6405..31a2cc3297 100644 --- a/Core/MIPS/x86/IRToX86.h +++ b/Core/MIPS/x86/IRToX86.h @@ -14,7 +14,7 @@ public: class IRToX86 : public IRToNativeInterface { public: void SetCodeBlock(Gen::XCodeBlock *code) { code_ = code; } - virtual void ConvertIRToNative(const IRInst *instructions, int count, const u32 *constants) override; + void ConvertIRToNative(const IRInst *instructions, int count, const u32 *constants) override; private: Gen::XCodeBlock *code_; diff --git a/Core/MIPS/x86/Jit.h b/Core/MIPS/x86/Jit.h index 0c96188ee4..8427f837ec 100644 --- a/Core/MIPS/x86/Jit.h +++ b/Core/MIPS/x86/Jit.h @@ -44,7 +44,7 @@ struct RegCacheState { class Jit : public Gen::XCodeBlock, public JitInterface, public MIPSFrontendInterface { public: Jit(MIPSState *mipsState); - virtual ~Jit(); + ~Jit(); const JitOptions &GetJitOptions() { return jo; } diff --git a/Core/Screenshot.cpp b/Core/Screenshot.cpp index 00f7d0a305..6ad9de9316 100644 --- a/Core/Screenshot.cpp +++ b/Core/Screenshot.cpp @@ -41,7 +41,7 @@ public: JPEGFileStream(const Path &filename) { fp_ = File::OpenCFile(filename, "wb"); } - ~JPEGFileStream() override { + ~JPEGFileStream() { if (fp_ ) { fclose(fp_); } diff --git a/Core/ThreadEventQueue.h b/Core/ThreadEventQueue.h index d365454776..161e06753c 100644 --- a/Core/ThreadEventQueue.h +++ b/Core/ThreadEventQueue.h @@ -28,6 +28,8 @@ template ActiveDisplayLists() = 0; virtual void ResetListPC(int listID, u32 pc) = 0; diff --git a/GPU/Common/SplineCommon.h b/GPU/Common/SplineCommon.h index 3b63732c87..f1a834b265 100644 --- a/GPU/Common/SplineCommon.h +++ b/GPU/Common/SplineCommon.h @@ -63,7 +63,7 @@ struct SurfaceInfo { GEPatchPrimType primType; bool patchFacing; - void Init() { + void BaseInit() { // If specified as 0, uses 1. if (tess_u < 1) tess_u = 1; if (tess_v < 1) tess_v = 1; @@ -88,7 +88,7 @@ struct BezierSurface : public SurfaceInfo { int num_verts_per_patch; void Init(int maxVertices) { - SurfaceInfo::Init(); + SurfaceInfo::BaseInit(); // Downsample until it fits, in case crazy tessellation factors are sent. while ((tess_u + 1) * (tess_v + 1) * num_patches_u * num_patches_v > maxVertices) { tess_u--; @@ -126,7 +126,7 @@ struct SplineSurface : public SurfaceInfo { int num_vertices_u; void Init(int maxVertices) { - SurfaceInfo::Init(); + SurfaceInfo::BaseInit(); // Downsample until it fits, in case crazy tessellation factors are sent. while ((num_patches_u * tess_u + 1) * (num_patches_v * tess_v + 1) > maxVertices) { tess_u--; diff --git a/GPU/D3D11/DrawEngineD3D11.h b/GPU/D3D11/DrawEngineD3D11.h index 468c8cd3bb..2703828516 100644 --- a/GPU/D3D11/DrawEngineD3D11.h +++ b/GPU/D3D11/DrawEngineD3D11.h @@ -117,7 +117,7 @@ public: class DrawEngineD3D11 : public DrawEngineCommon { public: DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context); - virtual ~DrawEngineD3D11(); + ~DrawEngineD3D11(); void SetShaderManager(ShaderManagerD3D11 *shaderManager) { shaderManager_ = shaderManager; diff --git a/GPU/D3D11/GPU_D3D11.h b/GPU/D3D11/GPU_D3D11.h index a4bcbd670f..0fece6f431 100644 --- a/GPU/D3D11/GPU_D3D11.h +++ b/GPU/D3D11/GPU_D3D11.h @@ -54,9 +54,6 @@ protected: void FinishDeferred() override; private: - void Flush() { - drawEngine_.Flush(); - } // void ApplyDrawState(int prim); void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo() override; diff --git a/GPU/Directx9/DrawEngineDX9.h b/GPU/Directx9/DrawEngineDX9.h index 3bc7222a67..e8bb1fbf42 100644 --- a/GPU/Directx9/DrawEngineDX9.h +++ b/GPU/Directx9/DrawEngineDX9.h @@ -105,7 +105,7 @@ public: class DrawEngineDX9 : public DrawEngineCommon { public: DrawEngineDX9(Draw::DrawContext *draw); - virtual ~DrawEngineDX9(); + ~DrawEngineDX9(); void SetShaderManager(ShaderManagerDX9 *shaderManager) { shaderManager_ = shaderManager; diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index 058e1b75d2..621ad79857 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -54,9 +54,6 @@ protected: void FinishDeferred() override; private: - void Flush() { - drawEngine_.Flush(); - } void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo() override; diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 2907929f12..ebdf4051b4 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -487,10 +487,6 @@ void DrawEngineGLES::DoFlush() { GPUDebug::NotifyDraw(); } -bool DrawEngineGLES::IsCodePtrVertexDecoder(const u8 *ptr) const { - return decJitCache_->IsInSpace(ptr); -} - // TODO: Refactor this to a single USE flag. bool DrawEngineGLES::SupportsHWTessellation() const { bool hasTexelFetch = gl_extensions.GLES3 || (!gl_extensions.IsGLES && gl_extensions.VersionGEThan(3, 3, 0)) || gl_extensions.EXT_gpu_shader4; diff --git a/GPU/GLES/DrawEngineGLES.h b/GPU/GLES/DrawEngineGLES.h index a1a8adce97..9352291c29 100644 --- a/GPU/GLES/DrawEngineGLES.h +++ b/GPU/GLES/DrawEngineGLES.h @@ -61,7 +61,7 @@ public: class DrawEngineGLES : public DrawEngineCommon { public: DrawEngineGLES(Draw::DrawContext *draw); - virtual ~DrawEngineGLES(); + ~DrawEngineGLES(); void SetShaderManager(ShaderManagerGLES *shaderManager) { shaderManager_ = shaderManager; @@ -97,8 +97,6 @@ public: DoFlush(); } - bool IsCodePtrVertexDecoder(const u8 *ptr) const; - void DispatchFlush() override { Flush(); } GLPushBuffer *GetPushVertexBuffer() { diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index afb1de0f42..ce2b363149 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -65,9 +65,6 @@ protected: void FinishDeferred() override; private: - void Flush() { - drawEngine_.Flush(); - } void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo() override; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index c15afe508f..26442c09bd 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -71,7 +71,7 @@ struct TransformedVertex { class GPUCommon : public GPUInterface, public GPUDebugInterface { public: GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw); - virtual ~GPUCommon(); + ~GPUCommon(); Draw::DrawContext *GetDrawContext() override { return draw_; diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 239be55390..afc61a25f4 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -140,7 +140,7 @@ enum { class DrawEngineVulkan : public DrawEngineCommon { public: DrawEngineVulkan(Draw::DrawContext *draw); - virtual ~DrawEngineVulkan(); + ~DrawEngineVulkan(); // We reference feature flags, so this is called after construction. void InitDeviceObjects(); diff --git a/GPU/Vulkan/GPU_Vulkan.h b/GPU/Vulkan/GPU_Vulkan.h index 8c970948bd..eefaa23b3c 100644 --- a/GPU/Vulkan/GPU_Vulkan.h +++ b/GPU/Vulkan/GPU_Vulkan.h @@ -71,9 +71,6 @@ protected: void CheckRenderResized() override; private: - void Flush() { - drawEngine_.Flush(); - } void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo() override; void InitClear() override; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index a39d7e71b0..3205453c21 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -588,7 +588,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } else { data = drawEngine_->GetPushBufferForTextureData()->PushAligned(sz, &bufferOffset, &texBuf, pushAlignment); } - LoadTextureLevel(*entry, (uint8_t *)data, lstride, srcLevel, lfactor, actualFmt); + LoadVulkanTextureLevel(*entry, (uint8_t *)data, lstride, srcLevel, lfactor, actualFmt); if (plan.saveTexture) bufferOffset = drawEngine_->GetPushBufferForTextureData()->PushAligned(&saveData[0], sz, pushAlignment, &texBuf); }; @@ -706,7 +706,7 @@ VkFormat TextureCacheVulkan::GetDestFormat(GETextureFormat format, GEPaletteForm } } -void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt) { +void TextureCacheVulkan::LoadVulkanTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt) { int w = gstate.getTextureWidth(level); int h = gstate.getTextureHeight(level); diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index f83595dc46..2c16d02a03 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -100,7 +100,7 @@ protected: void *GetNativeTextureView(const TexCacheEntry *entry) override; private: - void LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt); + void LoadVulkanTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt); VkFormat GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const; void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) override; diff --git a/Qt/QtHost.h b/Qt/QtHost.h index 79a65caa68..d8fa12f1f7 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -30,45 +30,45 @@ public: mainWindow = mainWindow_; } - virtual void UpdateUI() override { + void UpdateUI() override { mainWindow->updateMenus(); } - virtual void UpdateMemView() override { + void UpdateMemView() override { } - virtual void UpdateDisassembly() override { + void UpdateDisassembly() override { mainWindow->updateMenus(); } - virtual void SetDebugMode(bool mode) override { + void SetDebugMode(bool mode) override { } - virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; } - virtual void ShutdownGraphics() override {} + bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; } + void ShutdownGraphics() override {} - virtual void InitSound() override; - virtual void UpdateSound() override {} - virtual void ShutdownSound() override; + void InitSound() override; + void UpdateSound() override {} + void ShutdownSound() override; // this is sent from EMU thread! Make sure that Host handles it properly! - virtual void BootDone() override { + void BootDone() override { g_symbolMap->SortSymbols(); mainWindow->Notify(MainWindowMsg::BOOT_DONE); } - virtual bool IsDebuggingEnabled() override { + bool IsDebuggingEnabled() override { #ifdef _DEBUG return true; #else return false; #endif } - virtual bool AttemptLoadSymbolMap() override { + bool AttemptLoadSymbolMap() override { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); return g_symbolMap->LoadSymbolMap(fn); } - virtual void NotifySymbolMapUpdated() override { g_symbolMap->SortSymbols(); } + void NotifySymbolMapUpdated() override { g_symbolMap->SortSymbols(); } void PrepareShutdown() { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index b1612c3c2f..380208d42c 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -61,7 +61,7 @@ class DisplayLayoutBackground : public UI::View { public: DisplayLayoutBackground(UI::ChoiceStrip *mode, UI::LayoutParams *layoutParams) : UI::View(layoutParams), mode_(mode) {} - bool Touch(const TouchInput &touch) { + bool Touch(const TouchInput &touch) override { int mode = mode_ ? mode_->GetSelection() : 0; if ((touch.flags & TOUCH_MOVE) != 0 && dragging_) { diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index b6f0a7cfb7..16efa42e90 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -334,7 +334,7 @@ public: : gamePath_(gamePath), info_(info) { } - ~GameInfoWorkItem() override { + ~GameInfoWorkItem() { info_->pending.store(false); info_->working.store(false); info_->DisposeFileLoader(); diff --git a/UI/InstallZipScreen.h b/UI/InstallZipScreen.h index 140b82fec2..b877595d57 100644 --- a/UI/InstallZipScreen.h +++ b/UI/InstallZipScreen.h @@ -27,13 +27,13 @@ class InstallZipScreen : public UIDialogScreenWithBackground { public: InstallZipScreen(const Path &zipPath); - virtual void update() override; - virtual bool key(const KeyInput &key) override; + void update() override; + bool key(const KeyInput &key) override; const char *tag() const override { return "InstallZip"; } protected: - virtual void CreateViews() override; + void CreateViews() override; private: UI::EventReturn OnInstall(UI::EventParams ¶ms); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 0855e7eea6..5a03804908 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -434,7 +434,7 @@ public: DirButton(const Path &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0) : UI::Button(text, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(true) {} - virtual void Draw(UIContext &dc); + void Draw(UIContext &dc) override; const Path &GetPath() const { return path_; @@ -1490,7 +1490,7 @@ void UmdReplaceScreen::CreateViews() { tabAllGames->OnHoldChoice.Handle(this, &UmdReplaceScreen::OnGameSelected); - rightColumnItems->Add(new Choice(di->T("Cancel")))->OnClick.Handle(this, &UmdReplaceScreen::OnCancel); + rightColumnItems->Add(new Choice(di->T("Cancel")))->OnClick.Handle(this, &UIScreen::OnCancel); rightColumnItems->Add(new Choice(mm->T("Game Settings")))->OnClick.Handle(this, &UmdReplaceScreen::OnGameSettings); if (g_Config.HasRecentIsos()) { @@ -1515,11 +1515,6 @@ UI::EventReturn UmdReplaceScreen::OnGameSelected(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn UmdReplaceScreen::OnCancel(UI::EventParams &e) { - TriggerFinish(DR_CANCEL); - return UI::EVENT_DONE; -} - UI::EventReturn UmdReplaceScreen::OnGameSettings(UI::EventParams &e) { screenManager()->push(new GameSettingsScreen(Path())); return UI::EVENT_DONE; diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 995a912a92..ee79725fd1 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -165,7 +165,6 @@ private: UI::EventReturn OnGameSelected(UI::EventParams &e); UI::EventReturn OnGameSelectedInstant(UI::EventParams &e); - UI::EventReturn OnCancel(UI::EventParams &e); UI::EventReturn OnGameSettings(UI::EventParams &e); }; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index f880935e08..4bcfb1cb83 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -157,7 +157,6 @@ public: class FloatingSymbolsAnimation : public Animation { public: - ~FloatingSymbolsAnimation() override {} void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { float xres = dc.GetBounds().w; float yres = dc.GetBounds().h; @@ -196,7 +195,6 @@ private: class RecentGamesAnimation : public Animation { public: - ~RecentGamesAnimation() override {} void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { if (lastIndex_ == nextIndex_) { CheckNext(dc, t); @@ -812,7 +810,7 @@ void CreditsScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); Button *back = root_->Add(new Button(di->T("Back"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, 10, false))); - back->OnClick.Handle(this, &CreditsScreen::OnOK); + back->OnClick.Handle(this, &UIScreen::OnOK); root_->SetDefaultFocusView(back); // Really need to redo this whole layout with some linear layouts... @@ -881,11 +879,6 @@ UI::EventReturn CreditsScreen::OnShare(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn CreditsScreen::OnOK(UI::EventParams &e) { - TriggerFinish(DR_OK); - return UI::EVENT_DONE; -} - CreditsScreen::CreditsScreen() { startTime_ = time_now_d(); } diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index d218739a78..32fe101973 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -161,8 +161,6 @@ public: const char *tag() const override { return "Credits"; } private: - UI::EventReturn OnOK(UI::EventParams &e); - UI::EventReturn OnSupport(UI::EventParams &e); UI::EventReturn OnPPSSPPOrg(UI::EventParams &e); UI::EventReturn OnPrivacy(UI::EventParams &e); @@ -183,7 +181,7 @@ public: } void Show(const std::string &text, UI::View *refView = nullptr); - void Draw(UIContext &dc); + void Draw(UIContext &dc) override; std::string GetText() const; private: diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 1d54db7916..f9f0a949ab 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -33,7 +33,7 @@ enum class PauseScreenMode { class GamePauseScreen : public UIDialogScreenWithGameBackground { public: GamePauseScreen(const Path &filename) : UIDialogScreenWithGameBackground(filename), gamePath_(filename) {} - virtual ~GamePauseScreen(); + ~GamePauseScreen(); void dialogFinished(const Screen *dialog, DialogResult dr) override; diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index b8676e4832..53bc2706ed 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -57,7 +57,7 @@ enum class ScanStatus { class RemoteISOConnectScreen : public UIScreenWithBackground { public: RemoteISOConnectScreen(); - ~RemoteISOConnectScreen() override; + ~RemoteISOConnectScreen(); const char *tag() const override { return "RemoteISOConnect"; } diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index ca09054c28..c192a021a5 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -43,7 +43,7 @@ class RatingChoice : public LinearLayout { public: RatingChoice(const char *captionKey, int *value, LayoutParams *layoutParams = 0); - RatingChoice *SetEnabledPtr(bool *enabled); + RatingChoice *SetEnabledPtrs(bool *enabled); Event OnChoice; @@ -94,7 +94,7 @@ void RatingChoice::Update() { } } -RatingChoice *RatingChoice::SetEnabledPtr(bool *ptr) { +RatingChoice *RatingChoice::SetEnabledPtrs(bool *ptr) { for (int i = 0; i < TotalChoices(); i++) { GetChoice(i)->SetEnabledPtr(ptr); } @@ -139,8 +139,8 @@ public: CompatRatingChoice(const char *captionKey, int *value, LayoutParams *layoutParams = 0); protected: - virtual void SetupChoices() override; - virtual int TotalChoices() override { + void SetupChoices() override; + int TotalChoices() override { return 5; } }; @@ -295,16 +295,16 @@ void ReportScreen::CreateViews() { screenshot_ = nullptr; } - leftColumnItems->Add(new CompatRatingChoice("Overall", (int *)&overall_))->SetEnabledPtr(&enableReporting_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); + leftColumnItems->Add(new CompatRatingChoice("Overall", (int *)&overall_))->SetEnabledPtrs(&enableReporting_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); overallDescription_ = leftColumnItems->Add(new TextView("", FLAG_WRAP_TEXT, false, new LinearLayoutParams(Margins(10, 0)))); overallDescription_->SetShadow(true); UI::Orientation ratingsOrient = leftColumnWidth >= 750.0f ? ORIENT_HORIZONTAL : ORIENT_VERTICAL; UI::LinearLayout *ratingsHolder = new LinearLayoutList(ratingsOrient, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)); leftColumnItems->Add(ratingsHolder); - ratingsHolder->Add(new RatingChoice("Graphics", &graphics_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); - ratingsHolder->Add(new RatingChoice("Speed", &speed_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); - ratingsHolder->Add(new RatingChoice("Gameplay", &gameplay_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); + ratingsHolder->Add(new RatingChoice("Graphics", &graphics_))->SetEnabledPtrs(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); + ratingsHolder->Add(new RatingChoice("Speed", &speed_))->SetEnabledPtrs(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); + ratingsHolder->Add(new RatingChoice("Gameplay", &gameplay_))->SetEnabledPtrs(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); rightColumnItems->SetSpacing(0.0f); rightColumnItems->Add(new Choice(rp->T("Open Browser")))->OnClick.Handle(this, &ReportScreen::HandleBrowser); diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index 0c3f328f96..43c5762f4f 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -27,18 +27,18 @@ class TouchControlLayoutScreen : public UIDialogScreenWithGameBackground { public: TouchControlLayoutScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} - virtual void CreateViews() override; - virtual void dialogFinished(const Screen *dialog, DialogResult result) override; - virtual void onFinish(DialogResult reason) override; - virtual void update() override; - virtual void resized() override; + void CreateViews() override; + void dialogFinished(const Screen *dialog, DialogResult result) override; + void onFinish(DialogResult reason) override; + void update() override; + void resized() override; const char *tag() const override { return "TouchControlLayout"; } protected: - virtual UI::EventReturn OnReset(UI::EventParams &e); - virtual UI::EventReturn OnVisibility(UI::EventParams &e); - virtual UI::EventReturn OnMode(UI::EventParams &e); + UI::EventReturn OnReset(UI::EventParams &e); + UI::EventReturn OnVisibility(UI::EventParams &e); + UI::EventReturn OnMode(UI::EventParams &e); private: UI::ChoiceStrip *mode_ = nullptr; diff --git a/Windows/CaptureDevice.h b/Windows/CaptureDevice.h index d457702afe..d0ed3b4b5f 100644 --- a/Windows/CaptureDevice.h +++ b/Windows/CaptureDevice.h @@ -116,12 +116,12 @@ class WindowsCaptureDevice; class ReaderCallback final : public IMFSourceReaderCallback { public: ReaderCallback(WindowsCaptureDevice *device); - ~ReaderCallback(); + virtual ~ReaderCallback(); // IUnknown methods. - STDMETHODIMP QueryInterface(REFIID iid, void** ppv); - STDMETHODIMP_(ULONG) AddRef() { return 0; } // Unused, just define. - STDMETHODIMP_(ULONG) Release() { return 0; } // Unused, just define. + STDMETHODIMP QueryInterface(REFIID iid, void** ppv) override; + STDMETHODIMP_(ULONG) AddRef() override { return 0; } // Unused, just define. + STDMETHODIMP_(ULONG) Release() override { return 0; } // Unused, just define. // IMFSourceReaderCallback methods. STDMETHODIMP OnReadSample( @@ -130,10 +130,10 @@ public: DWORD dwStreamFlags, LONGLONG llTimestamp, IMFSample *pSample // Can be null,even if hrStatus is success. - ); + ) override; - STDMETHODIMP OnEvent(DWORD, IMFMediaEvent *) { return S_OK; } - STDMETHODIMP OnFlush(DWORD) { return S_OK; } + STDMETHODIMP OnEvent(DWORD, IMFMediaEvent *) override { return S_OK; } + STDMETHODIMP OnFlush(DWORD) override { return S_OK; } AVPixelFormat getAVVideoFormatbyMFVideoFormat(const GUID &MFVideoFormat); AVSampleFormat getAVAudioFormatbyMFAudioFormat(const GUID &MFAudioFormat, const u32 &bitsPerSample); diff --git a/Windows/DSoundStream.h b/Windows/DSoundStream.h index 7b4798449a..b3ebe194ab 100644 --- a/Windows/DSoundStream.h +++ b/Windows/DSoundStream.h @@ -11,7 +11,7 @@ struct IDirectSoundBuffer; class DSoundAudioBackend : public WindowsAudioBackend { public: DSoundAudioBackend(); - ~DSoundAudioBackend() override; + ~DSoundAudioBackend(); bool Init(HWND window, StreamCallback callback, int sampleRate) override; // If fails, can safely delete the object void Update() override; diff --git a/Windows/Debugger/Debugger_Lists.h b/Windows/Debugger/Debugger_Lists.h index 43dd834a44..b553de5f7b 100644 --- a/Windows/Debugger/Debugger_Lists.h +++ b/Windows/Debugger/Debugger_Lists.h @@ -15,11 +15,11 @@ public: void showMenu(int itemIndex, const POINT &pt); const char* getCurrentThreadName(); protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue); - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return (int) threads.size(); }; - virtual void OnDoubleClick(int itemIndex, int column); - virtual void OnRightClick(int itemIndex, int column, const POINT& point); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override; + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override { return (int) threads.size(); } + void OnDoubleClick(int itemIndex, int column) override; + void OnRightClick(int itemIndex, int column, const POINT &point) override; private: std::vector threads; }; @@ -31,14 +31,13 @@ class CtrlBreakpointList: public GenericListControl public: CtrlBreakpointList(HWND hwnd, DebugInterface* cpu, CtrlDisAsmView* disasm); void reloadBreakpoints(); - void showMenu(int itemIndex, const POINT &pt); protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue); - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return getTotalBreakpointCount(); }; - virtual void OnDoubleClick(int itemIndex, int column); - virtual void OnRightClick(int itemIndex, int column, const POINT& point); - virtual void OnToggle(int item, bool newValue); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override; + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override { return getTotalBreakpointCount(); } + void OnDoubleClick(int itemIndex, int column) override; + void OnRightClick(int itemIndex, int column, const POINT &point) override; + void OnToggle(int item, bool newValue) override; private: std::vector displayedBreakPoints_; std::vector displayedMemChecks_; @@ -61,10 +60,10 @@ public: CtrlStackTraceView(HWND hwnd, DebugInterface* cpu, CtrlDisAsmView* disasm); void loadStackTrace(); protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue); - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return (int)frames.size(); }; - virtual void OnDoubleClick(int itemIndex, int column); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override; + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override { return (int)frames.size(); } + void OnDoubleClick(int itemIndex, int column) override; private: std::vector frames; DebugInterface* cpu; @@ -77,11 +76,11 @@ public: CtrlModuleList(HWND hwnd, DebugInterface* cpu); void loadModules(); protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue); - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return (int)modules.size(); }; - virtual void OnDoubleClick(int itemIndex, int column); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override; + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override { return (int)modules.size(); } + void OnDoubleClick(int itemIndex, int column) override; private: std::vector modules; DebugInterface* cpu; -}; \ No newline at end of file +}; diff --git a/Windows/Debugger/Debugger_MemoryDlg.h b/Windows/Debugger/Debugger_MemoryDlg.h index b02d72d0d9..4e47d37be1 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.h +++ b/Windows/Debugger/Debugger_MemoryDlg.h @@ -19,7 +19,7 @@ private: HWND memViewHdl, symListHdl, editWnd, searchBoxHdl, srcListHdl; HWND layerDropdown_; HWND status_; - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; public: int index; //helper @@ -33,11 +33,9 @@ public: ~CMemoryDlg(void); void Goto(u32 addr); - void Update(void); + void Update(void) override; void NotifyMapLoaded(); - void NotifySearchCompleted(); - void Size(void); private: diff --git a/Windows/Debugger/Debugger_VFPUDlg.h b/Windows/Debugger/Debugger_VFPUDlg.h index 0e5763dcfc..080957a7a9 100644 --- a/Windows/Debugger/Debugger_VFPUDlg.h +++ b/Windows/Debugger/Debugger_VFPUDlg.h @@ -10,7 +10,7 @@ public: ~CVFPUDlg(); void Goto(u32 addr); - void Update(); + void Update() override; void Size(); private: @@ -18,5 +18,5 @@ private: DebugInterface *cpu; HFONT font; int mode; - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; }; diff --git a/Windows/DinputDevice.h b/Windows/DinputDevice.h index d8ecc8762f..5dc2474e2a 100644 --- a/Windows/DinputDevice.h +++ b/Windows/DinputDevice.h @@ -32,7 +32,7 @@ public: //getDevices(), enumerates all devices if not done yet DinputDevice(int devnum); ~DinputDevice(); - virtual int UpdateState() override; + int UpdateState() override; static size_t getNumPads(); static void CheckDevices() { needsCheck_ = true; diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index 24e7ffd280..56f1d24746 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -81,7 +81,7 @@ public: StepCountDlg(HINSTANCE _hInstance, HWND _hParent); ~StepCountDlg(); protected: - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private: void Jump(int count, bool relative); }; @@ -94,7 +94,7 @@ public: static void Init(); protected: - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private: void SetupPreviews(); diff --git a/Windows/GEDebugger/TabDisplayLists.h b/Windows/GEDebugger/TabDisplayLists.h index ff4388225a..5e31a49341 100644 --- a/Windows/GEDebugger/TabDisplayLists.h +++ b/Windows/GEDebugger/TabDisplayLists.h @@ -12,12 +12,15 @@ class CtrlDisplayListStack: public GenericListControl { public: CtrlDisplayListStack(HWND hwnd); - void setDisplayList(DisplayList& _list) { list = _list; Update(); } + void setDisplayList(const DisplayList &_list) { + list = _list; + Update(); + } protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) { return false; }; - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return list.stackptr; }; - virtual void OnDoubleClick(int itemIndex, int column); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override { return false; } + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override { return list.stackptr; } + void OnDoubleClick(int itemIndex, int column) override; private: DisplayList list; }; @@ -26,12 +29,15 @@ class CtrlAllDisplayLists: public GenericListControl { public: CtrlAllDisplayLists(HWND hwnd); - void setDisplayLists(std::vector& _lists) { lists = _lists; Update(); }; + void setDisplayLists(const std::vector &_lists) { + lists = _lists; + Update(); + } protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue); - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return (int) lists.size(); }; - virtual void OnDoubleClick(int itemIndex, int column); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override; + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override { return (int) lists.size(); } + void OnDoubleClick(int itemIndex, int column) override; private: std::vector lists; }; @@ -43,7 +49,7 @@ public: ~TabDisplayLists(); void Update(bool reload = true); protected: - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private: void UpdateSize(WORD width, WORD height); diff --git a/Windows/GEDebugger/TabState.h b/Windows/GEDebugger/TabState.h index 6992af14be..f525b02723 100644 --- a/Windows/GEDebugger/TabState.h +++ b/Windows/GEDebugger/TabState.h @@ -63,7 +63,7 @@ public: } protected: - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; CtrlStateValues *values; diff --git a/Windows/GEDebugger/TabVertices.h b/Windows/GEDebugger/TabVertices.h index 0a1f48be0c..4d7a04d660 100644 --- a/Windows/GEDebugger/TabVertices.h +++ b/Windows/GEDebugger/TabVertices.h @@ -35,9 +35,9 @@ public: } protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) { return false; }; - virtual void GetColumnText(wchar_t *dest, int row, int col); - virtual int GetRowCount(); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override { return false; } + void GetColumnText(wchar_t *dest, int row, int col) override; + int GetRowCount() override; private: void FormatVertCol(wchar_t *dest, const GPUDebugVertex &vert, int col); @@ -57,12 +57,12 @@ public: TabVertices(HINSTANCE _hInstance, HWND _hParent); ~TabVertices(); - virtual void Update() { + void Update() override { values->Update(); } protected: - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private: void UpdateSize(WORD width, WORD height); @@ -98,12 +98,12 @@ public: TabMatrices(HINSTANCE _hInstance, HWND _hParent); ~TabMatrices(); - virtual void Update() { + void Update() override { values->Update(); } protected: - BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private: void UpdateSize(WORD width, WORD height); diff --git a/Windows/WASAPIStream.cpp b/Windows/WASAPIStream.cpp index 3481e42d69..6079c030de 100644 --- a/Windows/WASAPIStream.cpp +++ b/Windows/WASAPIStream.cpp @@ -38,7 +38,7 @@ public: CMMNotificationClient() { } - ~CMMNotificationClient() { + virtual ~CMMNotificationClient() { CoTaskMemFree(currentDevice_); currentDevice_ = nullptr; SAFE_RELEASE(_pEnumerator) diff --git a/Windows/WASAPIStream.h b/Windows/WASAPIStream.h index b9e2169a78..9f0b88b40d 100644 --- a/Windows/WASAPIStream.h +++ b/Windows/WASAPIStream.h @@ -8,7 +8,7 @@ class WASAPIAudioBackend : public WindowsAudioBackend { public: WASAPIAudioBackend(); - ~WASAPIAudioBackend() override; + ~WASAPIAudioBackend(); bool Init(HWND window, StreamCallback callback, int sampleRate) override; // If fails, can safely delete the object void Update() override {} diff --git a/Windows/XinputDevice.h b/Windows/XinputDevice.h index bcff3e5db8..93347a6722 100644 --- a/Windows/XinputDevice.h +++ b/Windows/XinputDevice.h @@ -8,7 +8,7 @@ class XinputDevice final : public InputDevice { public: XinputDevice(); ~XinputDevice(); - virtual int UpdateState() override; + int UpdateState() override; private: void UpdatePad(int pad, const XINPUT_STATE &state, XINPUT_VIBRATION &vibration); diff --git a/headless/Compare.cpp b/headless/Compare.cpp index 9c42887342..e99b496b30 100644 --- a/headless/Compare.cpp +++ b/headless/Compare.cpp @@ -138,11 +138,11 @@ protected: BufferedLineReader() { } - virtual bool HasMoreLines() { + bool HasMoreLines() { return pos_ != data_.npos; } - virtual std::string ReadLine() { + std::string ReadLine() { size_t next = data_.find('\n', pos_); if (next == data_.npos) { std::string result = data_.substr(pos_); diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 98aefd31e7..fa63a489e1 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -65,7 +65,7 @@ bool audioRecording_State() { return false; } class PrintfLogger : public LogListener { public: - void Log(const LogMessage &message) { + void Log(const LogMessage &message) override { switch (message.level) { case LogTypes::LVERBOSE: fprintf(stderr, "V %s", message.msg.c_str()); diff --git a/unittest/TestThreadManager.cpp b/unittest/TestThreadManager.cpp index 1457c587ed..ece88ca494 100644 --- a/unittest/TestThreadManager.cpp +++ b/unittest/TestThreadManager.cpp @@ -74,8 +74,8 @@ class IncrementTask : public Task { public: IncrementTask(TaskType type, LimitedWaitable *waitable) : type_(type), waitable_(waitable) {} ~IncrementTask() {} - virtual TaskType Type() const { return type_; } - virtual void Run() { + TaskType Type() const override { return type_; } + void Run() override { g_atomicCounter++; waitable_->Notify(); } From e3fdb183f6c04eda1b88711552fdff5cee010de3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Dec 2022 20:50:11 -0800 Subject: [PATCH 2/6] Common: Remove some unused color conv funcs. We already have versions of these doing other conversions. --- Common/Data/Convert/ColorConv.cpp | 82 ------------------------------- Common/Data/Convert/ColorConv.h | 9 ---- 2 files changed, 91 deletions(-) diff --git a/Common/Data/Convert/ColorConv.cpp b/Common/Data/Convert/ColorConv.cpp index 55686f5c00..01c434e6e5 100644 --- a/Common/Data/Convert/ColorConv.cpp +++ b/Common/Data/Convert/ColorConv.cpp @@ -34,88 +34,6 @@ #endif #endif -// convert 4444 image to 8888, parallelizable -void convert4444_gl(u16* data, u32* out, int width, int l, int u) { - for (int y = l; y < u; ++y) { - for (int x = 0; x < width; ++x) { - u32 val = data[y*width + x]; - u32 r = ((val >> 12) & 0xF) * 17; - u32 g = ((val >> 8) & 0xF) * 17; - u32 b = ((val >> 4) & 0xF) * 17; - u32 a = ((val >> 0) & 0xF) * 17; - out[y*width + x] = (a << 24) | (b << 16) | (g << 8) | r; - } - } -} - -// convert 565 image to 8888, parallelizable -void convert565_gl(u16* data, u32* out, int width, int l, int u) { - for (int y = l; y < u; ++y) { - for (int x = 0; x < width; ++x) { - u32 val = data[y*width + x]; - u32 r = Convert5To8((val >> 11) & 0x1F); - u32 g = Convert6To8((val >> 5) & 0x3F); - u32 b = Convert5To8((val)& 0x1F); - out[y*width + x] = (0xFF << 24) | (b << 16) | (g << 8) | r; - } - } -} - -// convert 5551 image to 8888, parallelizable -void convert5551_gl(u16* data, u32* out, int width, int l, int u) { - for (int y = l; y < u; ++y) { - for (int x = 0; x < width; ++x) { - u32 val = data[y*width + x]; - u32 r = Convert5To8((val >> 11) & 0x1F); - u32 g = Convert5To8((val >> 6) & 0x1F); - u32 b = Convert5To8((val >> 1) & 0x1F); - u32 a = (val & 0x1) * 255; - out[y*width + x] = (a << 24) | (b << 16) | (g << 8) | r; - } - } -} - -// convert 4444 image to 8888, parallelizable -void convert4444_dx9(u16* data, u32* out, int width, int l, int u) { - for (int y = l; y < u; ++y) { - for (int x = 0; x < width; ++x) { - u32 val = data[y*width + x]; - u32 r = ((val >> 0) & 0xF) * 17; - u32 g = ((val >> 4) & 0xF) * 17; - u32 b = ((val >> 8) & 0xF) * 17; - u32 a = ((val >> 12) & 0xF) * 17; - out[y*width + x] = (a << 24) | (b << 16) | (g << 8) | r; - } - } -} - -// convert 565 image to 8888, parallelizable -void convert565_dx9(u16* data, u32* out, int width, int l, int u) { - for (int y = l; y < u; ++y) { - for (int x = 0; x < width; ++x) { - u32 val = data[y*width + x]; - u32 r = Convert5To8((val)& 0x1F); - u32 g = Convert6To8((val >> 5) & 0x3F); - u32 b = Convert5To8((val >> 11) & 0x1F); - out[y*width + x] = (0xFF << 24) | (b << 16) | (g << 8) | r; - } - } -} - -// convert 5551 image to 8888, parallelizable -void convert5551_dx9(u16* data, u32* out, int width, int l, int u) { - for (int y = l; y < u; ++y) { - for (int x = 0; x < width; ++x) { - u32 val = data[y*width + x]; - u32 r = Convert5To8((val >> 0) & 0x1F); - u32 g = Convert5To8((val >> 5) & 0x1F); - u32 b = Convert5To8((val >> 10) & 0x1F); - u32 a = ((val >> 15) & 0x1) * 255; - out[y*width + x] = (a << 24) | (b << 16) | (g << 8) | r; - } - } -} - void ConvertBGRA8888ToRGBA8888(u32 *dst, const u32 *src, u32 numPixels) { #ifdef _M_SSE const __m128i maskGA = _mm_set1_epi32(0xFF00FF00); diff --git a/Common/Data/Convert/ColorConv.h b/Common/Data/Convert/ColorConv.h index a7355dbb9d..53a286d127 100644 --- a/Common/Data/Convert/ColorConv.h +++ b/Common/Data/Convert/ColorConv.h @@ -126,15 +126,6 @@ inline u16 RGBA8888ToRGBA444X(u32 value) { return r | g | b; } -// convert image to 8888, parallelizable -// TODO: Implement these in terms of the conversion functions below. -void convert4444_gl(u16* data, u32* out, int width, int l, int u); -void convert565_gl(u16* data, u32* out, int width, int l, int u); -void convert5551_gl(u16* data, u32* out, int width, int l, int u); -void convert4444_dx9(u16* data, u32* out, int width, int l, int u); -void convert565_dx9(u16* data, u32* out, int width, int l, int u); -void convert5551_dx9(u16* data, u32* out, int width, int l, int u); - // "Complete" set of color conversion functions between the usual formats. // TODO: Need to revisit the naming convention of these. Seems totally backwards From a7b7bf78262fbe7432382b5445a71ad741893385 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Dec 2022 21:02:44 -0800 Subject: [PATCH 3/6] Global: Set many read-only params as const. This makes what they do and which args to use clearer, if nothing else. --- Common/Data/Encoding/Utf8.cpp | 2 +- Common/GPU/D3D11/thin3d_d3d11.cpp | 4 ++-- Common/GPU/OpenGL/GLRenderManager.h | 2 +- Common/GPU/OpenGL/thin3d_gl.cpp | 2 +- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 2 +- Common/LogManager.cpp | 2 +- Common/LogManager.h | 2 +- Common/Render/DrawBuffer.cpp | 2 +- Common/Render/DrawBuffer.h | 2 +- Common/UI/View.cpp | 2 +- Common/UI/View.h | 2 +- Common/UI/ViewGroup.cpp | 4 ++-- Core/Config.cpp | 2 +- Core/Dialog/PSPGamedataInstallDialog.cpp | 2 +- Core/Dialog/PSPGamedataInstallDialog.h | 2 +- Core/Dialog/PSPSaveDialog.cpp | 2 +- Core/Dialog/SavedataParam.cpp | 11 +++++------ Core/Dialog/SavedataParam.h | 6 +++--- Core/FileLoaders/DiskCachingFileLoader.cpp | 2 +- Core/FileLoaders/DiskCachingFileLoader.h | 2 +- Core/FileSystems/DirectoryFileSystem.cpp | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 2 +- Core/HLE/proAdhoc.cpp | 2 +- Core/HLE/proAdhoc.h | 2 +- Core/HLE/sceIo.cpp | 2 +- Core/HLE/sceKernelThread.cpp | 2 +- Core/HLE/sceKernelThread.h | 2 +- Core/HLE/sceKernelVTimer.cpp | 2 +- Core/HLE/sceMpeg.cpp | 6 +++--- Core/HW/AsyncIOManager.cpp | 2 +- Core/HW/AsyncIOManager.h | 2 +- Core/HW/MpegDemux.cpp | 2 +- Core/HW/SimpleAudioDec.cpp | 2 +- Core/HW/SimpleAudioDec.h | 2 +- Core/MIPS/IR/IRCompVFPU.cpp | 8 ++++---- Core/MIPS/JitCommon/JitBlockCache.cpp | 2 +- Core/MIPS/MIPSVFPUUtils.cpp | 2 +- Core/MIPS/MIPSVFPUUtils.h | 2 +- Core/MIPS/x86/CompVFPU.cpp | 4 ++-- GPU/Common/Draw2D.cpp | 2 +- GPU/Common/Draw2D.h | 2 +- GPU/Common/DrawEngineCommon.cpp | 4 ++-- GPU/Common/FramebufferManagerCommon.cpp | 2 +- GPU/Common/SoftwareTransformCommon.cpp | 8 ++++---- GPU/Common/SoftwareTransformCommon.h | 8 ++++---- GPU/Common/TextureCacheCommon.h | 2 +- GPU/Common/TextureScalerCommon.cpp | 22 +++++++++++----------- GPU/Common/TextureShaderCommon.cpp | 2 +- GPU/Common/TextureShaderCommon.h | 2 +- GPU/Common/VertexDecoderCommon.cpp | 2 +- GPU/Common/VertexDecoderCommon.h | 2 +- GPU/Directx9/ShaderManagerDX9.cpp | 2 +- GPU/Directx9/ShaderManagerDX9.h | 2 +- GPU/GPUState.cpp | 2 +- GPU/GPUState.h | 2 +- GPU/Math3D.cpp | 12 ++++-------- GPU/Math3D.h | 8 ++++---- GPU/Software/BinManager.cpp | 2 +- GPU/Software/BinManager.h | 2 +- GPU/Software/Lighting.cpp | 2 +- GPU/Software/TransformUnit.cpp | 2 +- GPU/Software/TransformUnit.h | 2 +- UI/ComboKeyMappingScreen.cpp | 2 +- UI/MiscScreens.cpp | 6 +++--- UI/MiscScreens.h | 4 ++-- Windows/Debugger/CtrlDisAsmView.cpp | 3 +-- Windows/Debugger/CtrlDisAsmView.h | 2 +- Windows/RawInput.cpp | 4 ++-- unittest/TestArm64Emitter.cpp | 2 +- unittest/TestArmEmitter.cpp | 2 +- unittest/TestX64Emitter.cpp | 4 ++-- 71 files changed, 113 insertions(+), 119 deletions(-) diff --git a/Common/Data/Encoding/Utf8.cpp b/Common/Data/Encoding/Utf8.cpp index d30a9432a8..760fe6b07d 100644 --- a/Common/Data/Encoding/Utf8.cpp +++ b/Common/Data/Encoding/Utf8.cpp @@ -112,7 +112,7 @@ int u8_toucs(uint32_t *dest, int sz, const char *src, int srcsz) the NUL as well. the destination string will never be bigger than the source string. */ -int u8_toutf8(char *dest, int sz, uint32_t *src, int srcsz) +int u8_toutf8(char *dest, int sz, const uint32_t *src, int srcsz) { uint32_t ch; int i = 0; diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 9b59852c88..43e6c2b653 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -170,7 +170,7 @@ public: private: void ApplyCurrentState(); - ID3D11DepthStencilState *GetCachedDepthStencilState(D3D11DepthStencilState *state, uint8_t stencilWriteMask, uint8_t stencilCompareMask); + ID3D11DepthStencilState *GetCachedDepthStencilState(const D3D11DepthStencilState *state, uint8_t stencilWriteMask, uint8_t stencilCompareMask); HWND hWnd_; ID3D11Device *device_; @@ -550,7 +550,7 @@ public: float blendFactor[4]; }; -ID3D11DepthStencilState *D3D11DrawContext::GetCachedDepthStencilState(D3D11DepthStencilState *state, uint8_t stencilWriteMask, uint8_t stencilCompareMask) { +ID3D11DepthStencilState *D3D11DrawContext::GetCachedDepthStencilState(const D3D11DepthStencilState *state, uint8_t stencilWriteMask, uint8_t stencilCompareMask) { D3D11DepthStencilKey key; key.desc = state->desc; key.writeMask = stencilWriteMask; diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index ff48306c3e..52ac971cec 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -481,7 +481,7 @@ public: return step.create_program.program; } - GLRInputLayout *CreateInputLayout(std::vector &entries) { + GLRInputLayout *CreateInputLayout(const std::vector &entries) { GLRInitStep step{ GLRInitStepType::CREATE_INPUT_LAYOUT }; step.create_input_layout.inputLayout = new GLRInputLayout(); step.create_input_layout.inputLayout->entries = entries; diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 6ea0ddc1dd..c9edb68502 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -517,7 +517,7 @@ static constexpr int MakeIntelSimpleVer(int v1, int v2, int v3) { return (v1 << 16) | (v2 << 8) | v3; } -static bool HasIntelDualSrcBug(int versions[4]) { +static bool HasIntelDualSrcBug(const int versions[4]) { // Intel uses a confusing set of at least 3 version numbering schemes. This is the one given to OpenGL. switch (MakeIntelSimpleVer(versions[0], versions[1], versions[2])) { case MakeIntelSimpleVer(9, 17, 10): diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index d28871e8c7..ec38cabecd 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -11,7 +11,7 @@ using namespace PPSSPP_VK; // Debug help: adb logcat -s DEBUG PPSSPPNativeActivity PPSSPP NativeGLView NativeRenderer NativeSurfaceView PowerSaveModeReceiver InputDeviceState -static void MergeRenderAreaRectInto(VkRect2D *dest, VkRect2D &src) { +static void MergeRenderAreaRectInto(VkRect2D *dest, const VkRect2D &src) { if (dest->offset.x > src.offset.x) { dest->extent.width += (dest->offset.x - src.offset.x); dest->offset.x = src.offset.x; diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 26b1ed49ec..13084098a4 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -200,7 +200,7 @@ void LogManager::SaveConfig(Section *section) { } } -void LogManager::LoadConfig(Section *section, bool debugDefaults) { +void LogManager::LoadConfig(const Section *section, bool debugDefaults) { for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { bool enabled = false; int level = 0; diff --git a/Common/LogManager.h b/Common/LogManager.h index 5d8afddae5..3ee1347f42 100644 --- a/Common/LogManager.h +++ b/Common/LogManager.h @@ -183,5 +183,5 @@ public: void ChangeFileLog(const char *filename); void SaveConfig(Section *section); - void LoadConfig(Section *section, bool debugDefaults); + void LoadConfig(const Section *section, bool debugDefaults); }; diff --git a/Common/Render/DrawBuffer.cpp b/Common/Render/DrawBuffer.cpp index e3efb6b5d0..7a50f2844a 100644 --- a/Common/Render/DrawBuffer.cpp +++ b/Common/Render/DrawBuffer.cpp @@ -130,7 +130,7 @@ void DrawBuffer::RectOutline(float x, float y, float w, float h, uint32_t color, vLine(x + w, y, y + h + pixel_in_dps_y, color); } -void DrawBuffer::MultiVGradient(float x, float y, float w, float h, GradientStop *stops, int numStops) { +void DrawBuffer::MultiVGradient(float x, float y, float w, float h, const GradientStop *stops, int numStops) { for (int i = 0; i < numStops - 1; i++) { float t0 = stops[i].t, t1 = stops[i+1].t; uint32_t c0 = stops[i].color, c1 = stops[i+1].color; diff --git a/Common/Render/DrawBuffer.h b/Common/Render/DrawBuffer.h index 4a29893c15..8c6262c7c7 100644 --- a/Common/Render/DrawBuffer.h +++ b/Common/Render/DrawBuffer.h @@ -88,7 +88,7 @@ public: RectVGradient(x, y, w, h, colorTop, darkenColor(colorTop)); } - void MultiVGradient(float x, float y, float w, float h, GradientStop *stops, int numStops); + void MultiVGradient(float x, float y, float w, float h, const GradientStop *stops, int numStops); void RectCenter(float x, float y, float w, float h, uint32_t color) { Rect(x - w/2, y - h/2, w, h, color); diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 769089e375..8be9b3076d 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -169,7 +169,7 @@ void View::PersistData(PersistStatus status, std::string anonId, PersistMap &sto } } -Point View::GetFocusPosition(FocusDirection dir) { +Point View::GetFocusPosition(FocusDirection dir) const { // The +2/-2 is some extra fudge factor to cover for views sitting right next to each other. // Distance zero yields strange results otherwise. switch (dir) { diff --git a/Common/UI/View.h b/Common/UI/View.h index 1ab1ea5f68..f3c54a0a3d 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -468,7 +468,7 @@ public: virtual bool IsViewGroup() const { return false; } virtual bool ContainsSubview(const View *view) const { return false; } - Point GetFocusPosition(FocusDirection dir); + Point GetFocusPosition(FocusDirection dir) const; template T *AddTween(T *t) { diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 50398dac45..de556ad5d9 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -294,7 +294,7 @@ static float VerticalOverlap(const Bounds &a, const Bounds &b) { return std::min(1.0f, overlap / minH); } -float GetTargetScore(const Point &originPos, int originIndex, View *origin, View *destination, FocusDirection direction) { +float GetTargetScore(const Point &originPos, int originIndex, const View *origin, const View *destination, FocusDirection direction) { // Skip labels and things like that. if (!destination->CanBeFocused()) return 0.0f; @@ -394,7 +394,7 @@ float GetTargetScore(const Point &originPos, int originIndex, View *origin, View } } -float GetDirectionScore(int originIndex, View *origin, View *destination, FocusDirection direction) { +static float GetDirectionScore(int originIndex, const View *origin, View *destination, FocusDirection direction) { Point originPos = origin->GetFocusPosition(direction); return GetTargetScore(originPos, originIndex, origin, destination, direction); } diff --git a/Core/Config.cpp b/Core/Config.cpp index ebc731cbd2..02e10366c0 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -257,7 +257,7 @@ struct ConfigSetting { return type_ != TYPE_TERMINATOR; } - bool Get(Section *section) { + bool Get(const Section *section) { switch (type_) { case TYPE_BOOL: if (cb_.b) { diff --git a/Core/Dialog/PSPGamedataInstallDialog.cpp b/Core/Dialog/PSPGamedataInstallDialog.cpp index 30da2953c6..22ef058313 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.cpp +++ b/Core/Dialog/PSPGamedataInstallDialog.cpp @@ -250,7 +250,7 @@ int PSPGamedataInstallDialog::Shutdown(bool force) { return PSPDialog::Shutdown(force); } -std::string PSPGamedataInstallDialog::GetGameDataInstallFileName(SceUtilityGamedataInstallParam *param, std::string filename){ +std::string PSPGamedataInstallDialog::GetGameDataInstallFileName(const SceUtilityGamedataInstallParam *param, std::string filename) { if (!param) return ""; std::string GameDataInstallPath = saveBasePath + param->gameName + param->dataName + "/"; diff --git a/Core/Dialog/PSPGamedataInstallDialog.h b/Core/Dialog/PSPGamedataInstallDialog.h index 47febcff9f..c73db2a01f 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.h +++ b/Core/Dialog/PSPGamedataInstallDialog.h @@ -44,7 +44,7 @@ public: void DoState(PointerWrap &p) override; int Abort(); - std::string GetGameDataInstallFileName(SceUtilityGamedataInstallParam *param, std::string filename); + std::string GetGameDataInstallFileName(const SceUtilityGamedataInstallParam *param, std::string filename); protected: // TODO: Manage status correctly. diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index a857f53a44..8e0bfcb1ba 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -157,7 +157,7 @@ int PSPSaveDialog::Init(int paramAddr) break; } - if(!param.wouldHasMultiSaveName(param.GetPspParam())) + if (!param.WouldHaveMultiSaveName(param.GetPspParam())) currentSelectedSave = 0; switch ((SceUtilitySavedataType)(u32)param.GetPspParam()->mode) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index f2c7b1758c..b78f728788 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -86,7 +86,7 @@ namespace return result != 0; } - bool WritePSPFile(std::string filename, u8 *data, SceSize dataSize) + bool WritePSPFile(std::string filename, const u8 *data, SceSize dataSize) { int handle = pspFileSystem.OpenFile(filename, (FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE | FILEACCESS_TRUNCATE)); if (handle < 0) @@ -1516,7 +1516,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) saveDataListCount++; } - if (saveDataListCount > 0 && wouldHasMultiSaveName(param)) { + if (saveDataListCount > 0 && WouldHaveMultiSaveName(param)) { hasMultipleFileName = true; saveDataList = new SaveFileInfo[saveDataListCount]; @@ -1842,8 +1842,7 @@ int SavedataParam::GetLastEmptySave() return idx; } -int SavedataParam::GetSaveNameIndex(SceUtilitySavedataParam* param) -{ +int SavedataParam::GetSaveNameIndex(const SceUtilitySavedataParam *param) { std::string saveName = GetSaveName(param); for (int i = 0; i < saveNameListDataCount; i++) { @@ -1857,7 +1856,7 @@ int SavedataParam::GetSaveNameIndex(SceUtilitySavedataParam* param) return 0; } -bool SavedataParam::wouldHasMultiSaveName(SceUtilitySavedataParam* param) { +bool SavedataParam::WouldHaveMultiSaveName(const SceUtilitySavedataParam *param) { switch ((SceUtilitySavedataType)(u32)param->mode) { case SCE_UTILITY_SAVEDATA_TYPE_LOAD: case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD: @@ -1937,7 +1936,7 @@ std::shared_ptr SavedataParam::LoadCachedSFO(const std::string &pa return sfoCache_.at(path); } -int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam *param, const std::string &saveDirName) { +int SavedataParam::GetSaveCryptMode(const SceUtilitySavedataParam *param, const std::string &saveDirName) { std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); std::string sfopath = dirPath + "/" + SFO_FILENAME; std::shared_ptr sfoFile = LoadCachedSFO(sfopath); diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index 65a1ac5cd1..257fc02746 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -317,7 +317,7 @@ public: bool GetList(SceUtilitySavedataParam* param); int GetFilesList(SceUtilitySavedataParam* param, u32 requestAddr); bool GetSize(SceUtilitySavedataParam* param); - int GetSaveCryptMode(SceUtilitySavedataParam* param, const std::string &saveDirName); + int GetSaveCryptMode(const SceUtilitySavedataParam *param, const std::string &saveDirName); bool IsInSaveDataList(std::string saveName, int count); std::string GetGameName(const SceUtilitySavedataParam *param) const; @@ -351,9 +351,9 @@ public: int GetLastDataSave(); int GetFirstEmptySave(); int GetLastEmptySave(); - int GetSaveNameIndex(SceUtilitySavedataParam* param); + int GetSaveNameIndex(const SceUtilitySavedataParam *param); - bool wouldHasMultiSaveName(SceUtilitySavedataParam* param); + bool WouldHaveMultiSaveName(const SceUtilitySavedataParam *param); void ClearCaches(); diff --git a/Core/FileLoaders/DiskCachingFileLoader.cpp b/Core/FileLoaders/DiskCachingFileLoader.cpp index dd8d59bf05..20c3ae0ad5 100644 --- a/Core/FileLoaders/DiskCachingFileLoader.cpp +++ b/Core/FileLoaders/DiskCachingFileLoader.cpp @@ -480,7 +480,7 @@ bool DiskCachingFileLoaderCache::ReadBlockData(u8 *dest, BlockInfo &info, size_t return !failed; } -void DiskCachingFileLoaderCache::WriteBlockData(BlockInfo &info, u8 *src) { +void DiskCachingFileLoaderCache::WriteBlockData(BlockInfo &info, const u8 *src) { if (!f_) { return; } diff --git a/Core/FileLoaders/DiskCachingFileLoader.h b/Core/FileLoaders/DiskCachingFileLoader.h index a9b75f4406..242c28ab5d 100644 --- a/Core/FileLoaders/DiskCachingFileLoader.h +++ b/Core/FileLoaders/DiskCachingFileLoader.h @@ -95,7 +95,7 @@ private: struct BlockInfo; bool ReadBlockData(u8 *dest, BlockInfo &info, size_t offset, size_t size); - void WriteBlockData(BlockInfo &info, u8 *src); + void WriteBlockData(BlockInfo &info, const u8 *src); void WriteIndexData(u32 indexPos, BlockInfo &info); s64 GetBlockOffset(u32 block); diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index b2ae2fabb7..27abc90564 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -712,7 +712,7 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) { #ifdef _WIN32 #define FILETIME_FROM_UNIX_EPOCH_US 11644473600000000ULL -static void tmFromFiletime(tm &dest, FILETIME &src) { +static void tmFromFiletime(tm &dest, const FILETIME &src) { u64 from_1601_us = (((u64) src.dwHighDateTime << 32ULL) + (u64) src.dwLowDateTime) / 10ULL; u64 from_1970_us = from_1601_us - FILETIME_FROM_UNIX_EPOCH_US; diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index dbe130f30c..5c5a6714e2 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -651,7 +651,7 @@ PSPFileInfo VirtualDiscFileSystem::GetFileInfo(std::string filename) { #ifdef _WIN32 #define FILETIME_FROM_UNIX_EPOCH_US 11644473600000000ULL -static void tmFromFiletime(tm &dest, FILETIME &src) +static void tmFromFiletime(tm &dest, const FILETIME &src) { u64 from_1601_us = (((u64) src.dwHighDateTime << 32ULL) + (u64) src.dwLowDateTime) / 10ULL; u64 from_1970_us = from_1601_us - FILETIME_FROM_UNIX_EPOCH_US; diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index dfcc535df0..2a18f05534 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -180,7 +180,7 @@ std::string ip2str(in_addr in, bool maskPublicIP) { return std::string(str); } -std::string mac2str(SceNetEtherAddr* mac) { +std::string mac2str(const SceNetEtherAddr *mac) { char str[18] = ":::::"; if (mac != NULL) { diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index b3594e5a7b..c448d0189b 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -1017,7 +1017,7 @@ bool isPTPPortInUse(uint16_t port, bool forListen, SceNetEtherAddr* dstmac = nul std::string ip2str(in_addr in, bool maskPublicIP = true); // Convert MAC address to string -std::string mac2str(SceNetEtherAddr* mac); +std::string mac2str(const SceNetEtherAddr *mac); /* * Matching Members diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 7425ec2603..e6fbd166e7 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -796,7 +796,7 @@ void __IoShutdown() { memStickFatCallbacks.clear(); } -static std::string IODetermineFilename(FileNode *f) { +static std::string IODetermineFilename(const FileNode *f) { uint64_t offset = pspFileSystem.GetSeekPos(f->handle); if ((pspFileSystem.DevType(f->handle) & PSPDevType::BLOCK) != 0) { return StringFromFormat("%s offset 0x%08llx", f->fullpath.c_str(), offset * 2048); diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index e3fcf2e442..995ead9667 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1466,7 +1466,7 @@ void __KernelSaveContext(PSPThreadContext *ctx, bool vfpuEnabled) { } // Loads a CPU context -void __KernelLoadContext(PSPThreadContext *ctx, bool vfpuEnabled) { +void __KernelLoadContext(const PSPThreadContext *ctx, bool vfpuEnabled) { // r and f are immediately next to each other and must be. memcpy((void *)currentMIPS->r, (void *)ctx->r, sizeof(ctx->r) + sizeof(ctx->f)); diff --git a/Core/HLE/sceKernelThread.h b/Core/HLE/sceKernelThread.h index b7e77c95b9..70c380245d 100644 --- a/Core/HLE/sceKernelThread.h +++ b/Core/HLE/sceKernelThread.h @@ -177,7 +177,7 @@ bool KernelIsThreadDormant(SceUID threadID); bool KernelIsThreadWaiting(SceUID threadID); void __KernelSaveContext(PSPThreadContext *ctx, bool vfpuEnabled); -void __KernelLoadContext(PSPThreadContext *ctx, bool vfpuEnabled); +void __KernelLoadContext(const PSPThreadContext *ctx, bool vfpuEnabled); u32 __KernelResumeThreadFromWait(SceUID threadID, u32 retval); // can return an error value u32 __KernelResumeThreadFromWait(SceUID threadID, u64 retval); diff --git a/Core/HLE/sceKernelVTimer.cpp b/Core/HLE/sceKernelVTimer.cpp index 63efc53eda..ce26b208ac 100644 --- a/Core/HLE/sceKernelVTimer.cpp +++ b/Core/HLE/sceKernelVTimer.cpp @@ -71,7 +71,7 @@ KernelObject *__KernelVTimerObject() { return new VTimer; } -static u64 __getVTimerRunningTime(VTimer *vt) { +static u64 __getVTimerRunningTime(const VTimer *vt) { if (vt->nvt.active == 0) return 0; diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index b39b5bd8db..e96ae6ebe8 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -314,7 +314,7 @@ static u32 getMpegVersion(u32 mpegRawVersion) { } } -static void AnalyzeMpeg(u8 *buffer, u32 validSize, MpegContext *ctx) { +static void AnalyzeMpeg(const u8 *buffer, u32 validSize, MpegContext *ctx) { ctx->mpegMagic = *(u32_le*)buffer; ctx->mpegRawVersion = *(u32_le*)(buffer + PSMF_STREAM_VERSION_OFFSET); ctx->mpegVersion = getMpegVersion(ctx->mpegRawVersion); @@ -883,11 +883,11 @@ public: } }; - void add(H264Frames *p){ + void add(const H264Frames *p) { add(p->stream, p->size); }; - void add(u8* str, int sz){ + void add(const u8 *str, int sz) { int newsize = size + sz; u8* newstream = new u8[newsize]; // join two streams diff --git a/Core/HW/AsyncIOManager.cpp b/Core/HW/AsyncIOManager.cpp index 1d4ce89b0a..85a9886053 100644 --- a/Core/HW/AsyncIOManager.cpp +++ b/Core/HW/AsyncIOManager.cpp @@ -134,7 +134,7 @@ void AsyncIOManager::Read(u32 handle, u8 *buf, size_t bytes, u32 invalidateAddr) EventResult(handle, AsyncIOResult(result, usec, invalidateAddr)); } -void AsyncIOManager::Write(u32 handle, u8 *buf, size_t bytes) { +void AsyncIOManager::Write(u32 handle, const u8 *buf, size_t bytes) { int usec = 0; s64 result = pspFileSystem.WriteFile(handle, buf, bytes, usec); EventResult(handle, AsyncIOResult(result, usec)); diff --git a/Core/HW/AsyncIOManager.h b/Core/HW/AsyncIOManager.h index 4b1e0b5276..59d50050cf 100644 --- a/Core/HW/AsyncIOManager.h +++ b/Core/HW/AsyncIOManager.h @@ -98,7 +98,7 @@ private: bool PopResult(u32 handle, AsyncIOResult &result); bool ReadResult(u32 handle, AsyncIOResult &result); void Read(u32 handle, u8 *buf, size_t bytes, u32 invalidateAddr); - void Write(u32 handle, u8 *buf, size_t bytes); + void Write(u32 handle, const u8 *buf, size_t bytes); void EventResult(u32 handle, AsyncIOResult result); diff --git a/Core/HW/MpegDemux.cpp b/Core/HW/MpegDemux.cpp index 4dce9cff05..6dbfa5ec44 100644 --- a/Core/HW/MpegDemux.cpp +++ b/Core/HW/MpegDemux.cpp @@ -288,7 +288,7 @@ bool MpegDemux::demux(int audioChannel) return looksValid; } -static bool isHeader(u8* audioStream, int offset) +static bool isHeader(const u8 *audioStream, int offset) { const u8 header1 = (u8)0x0F; const u8 header2 = (u8)0xD0; diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 8db47c77b5..0a19d92f85 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -120,7 +120,7 @@ bool SimpleAudio::OpenCodec(int block_align) { #endif // USE_FFMPEG } -void SimpleAudio::SetExtraData(u8 *data, int size, int wav_bytes_per_packet) { +void SimpleAudio::SetExtraData(const u8 *data, int size, int wav_bytes_per_packet) { #ifdef USE_FFMPEG if (codecCtx_) { codecCtx_->extradata = (uint8_t *)av_mallocz(size); diff --git a/Core/HW/SimpleAudioDec.h b/Core/HW/SimpleAudioDec.h index 533172aaa6..ec792c9031 100644 --- a/Core/HW/SimpleAudioDec.h +++ b/Core/HW/SimpleAudioDec.h @@ -53,7 +53,7 @@ public: int GetAudioCodecID(int audioType); // Get audioCodecId from audioType // Not save stated, only used by UI. Used for ATRAC3 (non+) files. - void SetExtraData(u8 *data, int size, int wav_bytes_per_packet); + void SetExtraData(const u8 *data, int size, int wav_bytes_per_packet); void SetChannels(int channels); diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index f325f006b3..11050c44cc 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -92,7 +92,7 @@ namespace MIPSComp { // Vector regs can overlap in all sorts of swizzled ways. // This does allow a single overlap in sregs[i]. - static bool IsOverlapSafeAllowS(int dreg, int di, int sn, u8 sregs[], int tn = 0, u8 tregs[] = NULL) { + static bool IsOverlapSafeAllowS(int dreg, int di, int sn, const u8 sregs[], int tn = 0, const u8 tregs[] = NULL) { for (int i = 0; i < sn; ++i) { if (sregs[i] == dreg && i != di) return false; @@ -106,7 +106,7 @@ namespace MIPSComp { return true; } - static bool IsOverlapSafeAllowS(int dn, u8 dregs[], int sn, u8 sregs[], int tn = 0, u8 tregs[] = nullptr) { + static bool IsOverlapSafeAllowS(int dn, const u8 dregs[], int sn, const u8 sregs[], int tn = 0, const u8 tregs[] = nullptr) { for (int i = 0; i < dn; ++i) { if (!IsOverlapSafeAllowS(dregs[i], i, sn, sregs, tn, tregs)) { return false; @@ -115,11 +115,11 @@ namespace MIPSComp { return true; } - static bool IsOverlapSafe(int dreg, int sn, u8 sregs[], int tn = 0, u8 tregs[] = nullptr) { + static bool IsOverlapSafe(int dreg, int sn, const u8 sregs[], int tn = 0, const u8 tregs[] = nullptr) { return IsOverlapSafeAllowS(dreg, -1, sn, sregs, tn, tregs); } - static bool IsOverlapSafe(int dn, u8 dregs[], int sn, u8 sregs[], int tn = 0, u8 tregs[] = nullptr) { + static bool IsOverlapSafe(int dn, const u8 dregs[], int sn, const u8 sregs[], int tn = 0, const u8 tregs[] = nullptr) { for (int i = 0; i < dn; ++i) { if (!IsOverlapSafe(dregs[i], sn, sregs, tn, tregs)) { return false; diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index f5b11ca4a5..e822c5c47d 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -304,7 +304,7 @@ bool JitBlockCache::RangeMayHaveEmuHacks(u32 start, u32 end) const { return false; } -static int binary_search(JitBlock blocks_[], const u8 *baseoff, int imin, int imax) { +static int binary_search(const JitBlock blocks_[], const u8 *baseoff, int imin, int imax) { while (imin < imax) { int imid = (imin + imax) / 2; if (blocks_[imid].normalEntry < baseoff) diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index e7f7bf7a7f..1019cbf494 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -678,7 +678,7 @@ static int32_t get_sign(uint32_t x) { return x & 0x80000000; } -float vfpu_dot(float a[4], float b[4]) { +float vfpu_dot(const float a[4], const float b[4]) { static const int EXTRA_BITS = 2; float2int result; float2int src[2]; diff --git a/Core/MIPS/MIPSVFPUUtils.h b/Core/MIPS/MIPSVFPUUtils.h index df1a1b85b0..6506a0664d 100644 --- a/Core/MIPS/MIPSVFPUUtils.h +++ b/Core/MIPS/MIPSVFPUUtils.h @@ -63,7 +63,7 @@ inline float vfpu_clamp(float v, float min, float max) { return v >= max ? max : (v <= min ? min : v); } -float vfpu_dot(float a[4], float b[4]); +float vfpu_dot(const float a[4], const float b[4]); float vfpu_sqrt(float a); float vfpu_rsqrt(float a); diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index f2380c8499..5af118061e 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -220,7 +220,7 @@ void Jit::ApplyPrefixD(const u8 *vregs, VectorSize sz) { // Vector regs can overlap in all sorts of swizzled ways. // This does allow a single overlap in sregs[i]. -bool IsOverlapSafeAllowS(int dreg, int di, int sn, u8 sregs[], int tn = 0, u8 tregs[] = NULL) { +bool IsOverlapSafeAllowS(int dreg, int di, int sn, const u8 sregs[], int tn = 0, const u8 tregs[] = NULL) { for (int i = 0; i < sn; ++i) { if (sregs[i] == dreg && i != di) return false; @@ -234,7 +234,7 @@ bool IsOverlapSafeAllowS(int dreg, int di, int sn, u8 sregs[], int tn = 0, u8 tr return true; } -bool IsOverlapSafe(int dreg, int di, int sn, u8 sregs[], int tn = 0, u8 tregs[] = NULL) { +bool IsOverlapSafe(int dreg, int di, int sn, const u8 sregs[], int tn = 0, const u8 tregs[] = NULL) { return IsOverlapSafeAllowS(dreg, di, sn, sregs, tn, tregs) && sregs[di] != dreg; } diff --git a/GPU/Common/Draw2D.cpp b/GPU/Common/Draw2D.cpp index b8b3722610..ddc752ae21 100644 --- a/GPU/Common/Draw2D.cpp +++ b/GPU/Common/Draw2D.cpp @@ -303,7 +303,7 @@ void Draw2D::Blit(Draw2DPipeline *pipeline, float srcX1, float srcY1, float srcX DrawStrip2D(nullptr, vtx, 4, linear, pipeline, srcWidth, srcHeight, scaleFactor); } -void Draw2D::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DPipeline *pipeline, float texW, float texH, int scaleFactor) { +void Draw2D::DrawStrip2D(Draw::Texture *tex, const Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DPipeline *pipeline, float texW, float texH, int scaleFactor) { using namespace Draw; _dbg_assert_(pipeline); diff --git a/GPU/Common/Draw2D.h b/GPU/Common/Draw2D.h index bf156e6d39..4d7d728404 100644 --- a/GPU/Common/Draw2D.h +++ b/GPU/Common/Draw2D.h @@ -61,7 +61,7 @@ public: Draw2DPipeline *Create2DPipeline(std::function generate); - void DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DPipeline *pipeline, float texW = 0.0f, float texH = 0.0f, int scaleFactor = 0); + void DrawStrip2D(Draw::Texture *tex, const Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DPipeline *pipeline, float texW = 0.0f, float texH = 0.0f, int scaleFactor = 0); void Blit(Draw2DPipeline *pipeline, float srcX1, float srcY1, float srcX2, float srcY2, float dstX1, float dstY1, float dstX2, float dstY2, float srcWidth, float srcHeight, float dstWidth, float dstHeight, bool linear, int scaleFactor); void Ensure2DResources(); diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index f5579de741..762acf0668 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -132,10 +132,10 @@ std::string DrawEngineCommon::DebugGetVertexLoaderString(std::string id, DebugSh struct Plane { float x, y, z, w; void Set(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } - float Test(float f[3]) const { return x * f[0] + y * f[1] + z * f[2] + w; } + float Test(const float f[3]) const { return x * f[0] + y * f[1] + z * f[2] + w; } }; -static void PlanesFromMatrix(float mtx[16], Plane planes[6]) { +static void PlanesFromMatrix(const float mtx[16], Plane planes[6]) { planes[0].Set(mtx[3]-mtx[0], mtx[7]-mtx[4], mtx[11]-mtx[8], mtx[15]-mtx[12]); // Right planes[1].Set(mtx[3]+mtx[0], mtx[7]+mtx[4], mtx[11]+mtx[8], mtx[15]+mtx[12]); // Left planes[2].Set(mtx[3]+mtx[1], mtx[7]+mtx[5], mtx[11]+mtx[9], mtx[15]+mtx[13]); // Bottom diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 685b70c851..d3bfa8677f 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -50,7 +50,7 @@ #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" -static size_t FormatFramebufferName(VirtualFramebuffer *vfb, char *tag, size_t len) { +static size_t FormatFramebufferName(const VirtualFramebuffer *vfb, char *tag, size_t len) { return snprintf(tag, len, "FB_%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, vfb->bufferWidth, vfb->bufferHeight, GeBufferFormatToString(vfb->fb_format)); } diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index b85dc342d7..28cdef056e 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -149,7 +149,7 @@ static int ColorIndexOffset(int prim, GEShadeMode shadeMode, bool clearMode) { return 0; } -void SoftwareTransform::SetProjMatrix(float mtx[14], bool invertedX, bool invertedY, const Lin::Vec3 &trans, const Lin::Vec3 &scale) { +void SoftwareTransform::SetProjMatrix(const float mtx[14], bool invertedX, bool invertedY, const Lin::Vec3 &trans, const Lin::Vec3 &scale) { memcpy(&projMatrix_.m, mtx, 16 * sizeof(float)); if (invertedY) { @@ -673,7 +673,7 @@ void SoftwareTransform::CalcCullParams(float &minZValue, float &maxZValue) { std::swap(minZValue, maxZValue); } -void SoftwareTransform::ExpandRectangles(int vertexCount, int &maxIndex, u16 *&inds, TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { +void SoftwareTransform::ExpandRectangles(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { // Rectangles always need 2 vertices, disregard the last one if there's an odd number. vertexCount = vertexCount & ~1; numTrans = 0; @@ -734,7 +734,7 @@ void SoftwareTransform::ExpandRectangles(int vertexCount, int &maxIndex, u16 *&i inds = newInds; } -void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { +void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { // Lines always need 2 vertices, disregard the last one if there's an odd number. vertexCount = vertexCount & ~1; numTrans = 0; @@ -857,7 +857,7 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, inds = newInds; } -void SoftwareTransform::ExpandPoints(int vertexCount, int &maxIndex, u16 *&inds, TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { +void SoftwareTransform::ExpandPoints(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { numTrans = 0; TransformedVertex *trans = &transformedExpanded[0]; diff --git a/GPU/Common/SoftwareTransformCommon.h b/GPU/Common/SoftwareTransformCommon.h index 37dbca399b..480bd18e51 100644 --- a/GPU/Common/SoftwareTransformCommon.h +++ b/GPU/Common/SoftwareTransformCommon.h @@ -65,16 +65,16 @@ public: SoftwareTransform(SoftwareTransformParams ¶ms) : params_(params) { } - void SetProjMatrix(float mtx[14], bool invertedX, bool invertedY, const Lin::Vec3 &trans, const Lin::Vec3 &scale); + void SetProjMatrix(const float mtx[14], bool invertedX, bool invertedY, const Lin::Vec3 &trans, const Lin::Vec3 &scale); void Decode(int prim, u32 vertexType, const DecVtxFormat &decVtxFormat, int maxIndex, SoftwareTransformResult *result); void DetectOffsetTexture(int maxIndex); void BuildDrawingParams(int prim, int vertexCount, u32 vertType, u16 *&inds, int &maxIndex, SoftwareTransformResult *result); protected: void CalcCullParams(float &minZValue, float &maxZValue); - void ExpandRectangles(int vertexCount, int &maxIndex, u16 *&inds, TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode); - void ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode); - void ExpandPoints(int vertexCount, int &maxIndex, u16 *&inds, TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode); + void ExpandRectangles(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode); + void ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode); + void ExpandPoints(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode); const SoftwareTransformParams ¶ms_; Lin::Matrix4x4 projMatrix_; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index bbaf0eecde..7e20739eee 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -410,7 +410,7 @@ protected: static CheckAlphaResult CheckCLUTAlpha(const uint8_t *pixelData, GEPaletteFormat clutFmt, int w); - inline u32 QuickTexHash(TextureReplacer &replacer, u32 addr, int bufw, int w, int h, GETextureFormat format, TexCacheEntry *entry) const { + inline u32 QuickTexHash(TextureReplacer &replacer, u32 addr, int bufw, int w, int h, GETextureFormat format, const TexCacheEntry *entry) const { if (replacer.Enabled()) { return replacer.ComputeHash(addr, bufw, w, h, format, entry->maxSeenV); } diff --git a/GPU/Common/TextureScalerCommon.cpp b/GPU/Common/TextureScalerCommon.cpp index 257836d4f3..a2662a4c04 100644 --- a/GPU/Common/TextureScalerCommon.cpp +++ b/GPU/Common/TextureScalerCommon.cpp @@ -71,7 +71,7 @@ namespace { // 3x3 convolution with Neumann boundary conditions, parallelizable // quite slow, could be sped up a lot // especially handling of separable kernels -void convolve3x3(u32* data, u32* out, const int kernel[3][3], int width, int height, int l, int u) { +void convolve3x3(const u32 *data, u32 *out, const int kernel[3][3], int width, int height, int l, int u) { for (int yb = 0; yb < (u - l) / BLOCK_SIZE + 1; ++yb) { for (int xb = 0; xb < width / BLOCK_SIZE + 1; ++xb) { for (int y = l + yb*BLOCK_SIZE; y < l + (yb + 1)*BLOCK_SIZE && y < u; ++y) { @@ -92,7 +92,7 @@ void convolve3x3(u32* data, u32* out, const int kernel[3][3], int width, int hei } // deposterization: smoothes posterized gradients from low-color-depth (e.g. 444, 565, compressed) sources -void deposterizeH(u32* data, u32* out, int w, int l, int u) { +void deposterizeH(const u32 *data, u32 *out, int w, int l, int u) { static const int T = 8; for (int y = l; y < u; ++y) { for (int x = 0; x < w; ++x) { @@ -120,7 +120,7 @@ void deposterizeH(u32* data, u32* out, int w, int l, int u) { } } } -void deposterizeV(u32* data, u32* out, int w, int h, int l, int u) { +void deposterizeV(const u32 *data, u32 *out, int w, int h, int l, int u) { static const int T = 8; for (int xb = 0; xb < w / BLOCK_SIZE + 1; ++xb) { for (int y = l; y < u; ++y) { @@ -152,7 +152,7 @@ void deposterizeV(u32* data, u32* out, int w, int h, int l, int u) { // generates a distance mask value for each pixel in data // higher values -> larger distance to the surrounding pixels -void generateDistanceMask(u32* data, u32* out, int width, int height, int l, int u) { +void generateDistanceMask(const u32 *data, u32 *out, int width, int height, int l, int u) { for (int yb = 0; yb < (u - l) / BLOCK_SIZE + 1; ++yb) { for (int xb = 0; xb < width / BLOCK_SIZE + 1; ++xb) { for (int y = l + yb*BLOCK_SIZE; y < l + (yb + 1)*BLOCK_SIZE && y < u; ++y) { @@ -183,7 +183,7 @@ void generateDistanceMask(u32* data, u32* out, int width, int height, int l, int } // mix two images based on a mask -void mix(u32* data, u32* source, u32* mask, u32 maskmax, int width, int l, int u) { +void mix(u32 *data, const u32 *source, const u32 *mask, u32 maskmax, int width, int l, int u) { for (int y = l; y < u; ++y) { for (int x = 0; x < width; ++x) { int pos = y*width + x; @@ -448,7 +448,7 @@ static void upscale_cubic( // End of pasted cubic upscaler. -void scaleBicubicBSpline(int factor, u32* data, u32* out, int w, int h, int l, int u) { +void scaleBicubicBSpline(int factor, const u32 *data, u32 *out, int w, int h, int l, int u) { const float B = 1.0f, C = 0.0f; const int wrap_mode = 1; // Clamp upscale_cubic( @@ -458,7 +458,7 @@ void scaleBicubicBSpline(int factor, u32* data, u32* out, int w, int h, int l, i 0, factor*l, factor*w, factor*u); } -void scaleBicubicMitchell(int factor, u32* data, u32* out, int w, int h, int l, int u) { +void scaleBicubicMitchell(int factor, const u32 *data, u32 *out, int w, int h, int l, int u) { const float B = 0.0f, C = 0.5f; // Actually, Catmull-Rom const int wrap_mode = 1; // Clamp upscale_cubic( @@ -478,7 +478,7 @@ const static u8 BILINEAR_FACTORS[4][3][2] = { }; // integral bilinear upscaling by factor f, horizontal part template -void bilinearHt(u32* data, u32* out, int w, int l, int u) { +void bilinearHt(const u32 *data, u32 *out, int w, int l, int u) { static_assert(f > 1 && f <= 5, "Bilinear scaling only implemented for factors 2 to 5"); int outw = w*f; for (int y = l; y < u; ++y) { @@ -497,7 +497,7 @@ void bilinearHt(u32* data, u32* out, int w, int l, int u) { } } } -void bilinearH(int factor, u32* data, u32* out, int w, int l, int u) { +void bilinearH(int factor, const u32 *data, u32 *out, int w, int l, int u) { switch (factor) { case 2: bilinearHt<2>(data, out, w, l, u); break; case 3: bilinearHt<3>(data, out, w, l, u); break; @@ -509,7 +509,7 @@ void bilinearH(int factor, u32* data, u32* out, int w, int l, int u) { // integral bilinear upscaling by factor f, vertical part // gl/gu == global lower and upper bound template -void bilinearVt(u32* data, u32* out, int w, int gl, int gu, int l, int u) { +void bilinearVt(const u32 *data, u32 *out, int w, int gl, int gu, int l, int u) { static_assert(f>1 && f <= 5, "Bilinear scaling only implemented for 2x, 3x, 4x, and 5x"); int outw = w*f; for (int xb = 0; xb < outw / BLOCK_SIZE + 1; ++xb) { @@ -531,7 +531,7 @@ void bilinearVt(u32* data, u32* out, int w, int gl, int gu, int l, int u) { } } } -void bilinearV(int factor, u32* data, u32* out, int w, int gl, int gu, int l, int u) { +void bilinearV(int factor, const u32 *data, u32 *out, int w, int gl, int gu, int l, int u) { switch (factor) { case 2: bilinearVt<2>(data, out, w, gl, gu, l, u); break; case 3: bilinearVt<3>(data, out, w, gl, gu, l, u); break; diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index a1ba51de53..b706edae66 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -53,7 +53,7 @@ void TextureShaderCache::DeviceLost() { draw_ = nullptr; } -ClutTexture TextureShaderCache::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut) { +ClutTexture TextureShaderCache::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, const u32 *rawClut) { // Simplistic, but works well enough. u32 clutId = clutHash ^ (uint32_t)clutFormat; diff --git a/GPU/Common/TextureShaderCommon.h b/GPU/Common/TextureShaderCommon.h index a11ee81210..d6a6096f09 100644 --- a/GPU/Common/TextureShaderCommon.h +++ b/GPU/Common/TextureShaderCommon.h @@ -44,7 +44,7 @@ public: ~TextureShaderCache(); Draw2DPipeline *GetDepalettizeShader(uint32_t clutMode, GETextureFormat texFormat, GEBufferFormat pixelFormat, bool smoothedDepal, u32 depthUpperBits); - ClutTexture GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut); + ClutTexture GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, const u32 *rawClut); Draw::SamplerState *GetSampler(bool linearFilter); diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index 3a77375cba..ca38580d65 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -149,7 +149,7 @@ void GetIndexBounds(const void *inds, int count, u32 vertType, u16 *indexLowerBo *indexUpperBound = (u16)upperBound; } -void PrintDecodedVertex(VertexReader &vtx) { +void PrintDecodedVertex(const VertexReader &vtx) { if (vtx.hasNormal()) { float nrm[3]; vtx.ReadNrm(nrm); diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index 33986f382b..a326c0e75e 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -301,7 +301,7 @@ private: int vtype_; }; // Debugging utilities -void PrintDecodedVertex(VertexReader &vtx); +void PrintDecodedVertex(const VertexReader &vtx); class VertexDecoder; diff --git a/GPU/Directx9/ShaderManagerDX9.cpp b/GPU/Directx9/ShaderManagerDX9.cpp index d7f31b8852..27a42d809b 100644 --- a/GPU/Directx9/ShaderManagerDX9.cpp +++ b/GPU/Directx9/ShaderManagerDX9.cpp @@ -197,7 +197,7 @@ void ShaderManagerDX9::VSSetColorUniform3(int creg, u32 color) { device_->SetVertexShaderConstantF(creg, f, 1); } -void ShaderManagerDX9::VSSetFloatUniform4(int creg, float data[4]) { +void ShaderManagerDX9::VSSetFloatUniform4(int creg, const float data[4]) { device_->SetVertexShaderConstantF(creg, data, 1); } diff --git a/GPU/Directx9/ShaderManagerDX9.h b/GPU/Directx9/ShaderManagerDX9.h index 6ee812b2e6..5dcdddfbce 100644 --- a/GPU/Directx9/ShaderManagerDX9.h +++ b/GPU/Directx9/ShaderManagerDX9.h @@ -104,7 +104,7 @@ private: void VSSetFloat(int creg, float value); void VSSetFloatArray(int creg, const float *value, int count); void VSSetFloat24Uniform3(int creg, const u32 data[3]); - void VSSetFloatUniform4(int creg, float data[4]); + void VSSetFloatUniform4(int creg, const float data[4]); void Clear(); diff --git a/GPU/GPUState.cpp b/GPU/GPUState.cpp index ba0e650bb6..28c13b871a 100644 --- a/GPU/GPUState.cpp +++ b/GPU/GPUState.cpp @@ -213,7 +213,7 @@ void GPUgstate::FastLoadBoneMatrix(u32 addr) { gstate.boneMatrixNumber = (GE_CMD_BONEMATRIXNUMBER << 24) | (num & 0x00FFFFFF); } -void GPUgstate::Restore(u32_le *ptr) { +void GPUgstate::Restore(const u32_le *ptr) { // Not sure what the first 10 values are, exactly, but these seem right. gstate_c.vertexAddr = ptr[5]; gstate_c.indexAddr = ptr[6]; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index e5acb39a18..bc889e542f 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -445,7 +445,7 @@ struct GPUgstate { void Reset(); void Save(u32_le *ptr); - void Restore(u32_le *ptr); + void Restore(const u32_le *ptr); }; bool vertTypeIsSkinningEnabled(u32 vertType); diff --git a/GPU/Math3D.cpp b/GPU/Math3D.cpp index ecb959ec2c..fec4c887bd 100644 --- a/GPU/Math3D.cpp +++ b/GPU/Math3D.cpp @@ -50,8 +50,7 @@ Vec2 Vec2::WithLength(const float l) const } template<> -float Vec2::Distance2To(Vec2 &other) -{ +float Vec2::Distance2To(const Vec2 &other) const { return Vec2(other-(*this)).Length2(); } @@ -99,8 +98,7 @@ Vec3 Vec3::WithLength(const float l) const } template<> -float Vec3::Distance2To(Vec3 &other) -{ +float Vec3::Distance2To(const Vec3 &other) const { return Vec3(other-(*this)).Length2(); } @@ -231,8 +229,7 @@ Vec3Packed Vec3Packed::WithLength(const float l) const } template<> -float Vec3Packed::Distance2To(Vec3Packed &other) -{ +float Vec3Packed::Distance2To(const Vec3Packed &other) const { return Vec3Packed(other-(*this)).Length2(); } @@ -279,8 +276,7 @@ Vec4 Vec4::WithLength(const float l) const } template<> -float Vec4::Distance2To(Vec4 &other) -{ +float Vec4::Distance2To(const Vec4 &other) const { return Vec4(other-(*this)).Length2(); } diff --git a/GPU/Math3D.h b/GPU/Math3D.h index b3a94ba56c..88a62c72da 100644 --- a/GPU/Math3D.h +++ b/GPU/Math3D.h @@ -145,7 +145,7 @@ public: float Length() const; void SetLength(const float l); Vec2 WithLength(const float l) const; - float Distance2To(Vec2 &other); + float Distance2To(const Vec2 &other) const; Vec2 Normalized() const; float Normalize(); // returns the previous length, which is often useful @@ -310,7 +310,7 @@ public: float Length() const; void SetLength(const float l); Vec3 WithLength(const float l) const; - float Distance2To(Vec3 &other); + float Distance2To(const Vec3 &other) const; Vec3 Normalized(bool useSSE4 = false) const; Vec3 NormalizedOr001(bool useSSE4 = false) const; float Normalize(); // returns the previous length, which is often useful @@ -478,7 +478,7 @@ public: float Length() const; void SetLength(const float l); Vec3Packed WithLength(const float l) const; - float Distance2To(Vec3Packed &other); + float Distance2To(const Vec3Packed &other) const; Vec3Packed Normalized() const; float Normalize(); // returns the previous length, which is often useful @@ -674,7 +674,7 @@ public: float Length() const; void SetLength(const float l); Vec4 WithLength(const float l) const; - float Distance2To(Vec4 &other); + float Distance2To(const Vec4 &other) const; Vec4 Normalized() const; float Normalize(); // returns the previous length, which is often useful diff --git a/GPU/Software/BinManager.cpp b/GPU/Software/BinManager.cpp index 7906cbe79f..1978d32edc 100644 --- a/GPU/Software/BinManager.cpp +++ b/GPU/Software/BinManager.cpp @@ -333,7 +333,7 @@ void BinManager::MarkPendingWrites(const Rasterizer::RasterizerState &state) { pendingWrites_[1].Expand(gstate.getDepthBufAddress() & mirrorMask, 2, gstate.DepthBufStride(), scissorTL, scissorBR); } -inline void BinDirtyRange::Expand(uint32_t newBase, uint32_t bpp, uint32_t stride, DrawingCoords &tl, DrawingCoords &br) { +inline void BinDirtyRange::Expand(uint32_t newBase, uint32_t bpp, uint32_t stride, const DrawingCoords &tl, const DrawingCoords &br) { const uint32_t w = br.x - tl.x + 1; const uint32_t h = br.y - tl.y + 1; diff --git a/GPU/Software/BinManager.h b/GPU/Software/BinManager.h index 9252d835cc..116fb19e27 100644 --- a/GPU/Software/BinManager.h +++ b/GPU/Software/BinManager.h @@ -177,7 +177,7 @@ struct BinDirtyRange { uint32_t widthBytes; uint32_t height; - void Expand(uint32_t newBase, uint32_t bpp, uint32_t stride, DrawingCoords &tl, DrawingCoords &br); + void Expand(uint32_t newBase, uint32_t bpp, uint32_t stride, const DrawingCoords &tl, const DrawingCoords &br); }; class BinManager { diff --git a/GPU/Software/Lighting.cpp b/GPU/Software/Lighting.cpp index 32596989fe..82315b1b20 100644 --- a/GPU/Software/Lighting.cpp +++ b/GPU/Software/Lighting.cpp @@ -24,7 +24,7 @@ namespace Lighting { -static inline Vec3f GetLightVec(u32 lparams[12], int light) { +static inline Vec3f GetLightVec(const u32 lparams[12], int light) { #if defined(_M_SSE) && !PPSSPP_ARCH(X86) __m128i values = _mm_loadu_si128((__m128i *)&lparams[3 * light]); __m128i from24 = _mm_slli_epi32(values, 8); diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index b7c9401219..e109f6d87a 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -335,7 +335,7 @@ void ComputeTransformState(TransformState *state, const VertexReader &vreader) { state->roundToScreen = &ClipToScreenInternal; } -ClipVertexData TransformUnit::ReadVertex(VertexReader &vreader, const TransformState &state) { +ClipVertexData TransformUnit::ReadVertex(const VertexReader &vreader, const TransformState &state) { PROFILE_THIS_SCOPE("read_vert"); // If we ever thread this, we'll have to change this. ClipVertexData vertex; diff --git a/GPU/Software/TransformUnit.h b/GPU/Software/TransformUnit.h index 5ed9994f92..ed7476a13b 100644 --- a/GPU/Software/TransformUnit.h +++ b/GPU/Software/TransformUnit.h @@ -149,7 +149,7 @@ public: SoftDirty GetDirty(); private: - ClipVertexData ReadVertex(VertexReader &vreader, const TransformState &state); + ClipVertexData ReadVertex(const VertexReader &vreader, const TransformState &state); void SendTriangle(CullType cullType, const ClipVertexData *verts, int provoking = 2); u8 *decoded_ = nullptr; diff --git a/UI/ComboKeyMappingScreen.cpp b/UI/ComboKeyMappingScreen.cpp index d4c8a814b6..4af85552c1 100644 --- a/UI/ComboKeyMappingScreen.cpp +++ b/UI/ComboKeyMappingScreen.cpp @@ -271,7 +271,7 @@ void ComboKeyScreen::CreateViews() { } } -static uint64_t arrayToInt(bool ary[ARRAY_SIZE(CustomKey::comboKeyList)]) { +static uint64_t arrayToInt(const bool ary[ARRAY_SIZE(CustomKey::comboKeyList)]) { uint64_t value = 0; for (int i = ARRAY_SIZE(CustomKey::comboKeyList)-1; i >= 0; i--) { value |= ary[i] ? 1 : 0; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 4bcfb1cb83..d1dbb2dd1b 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -354,7 +354,7 @@ void DrawBackground(UIContext &dc, float alpha, float x, float y, float z) { } } -uint32_t GetBackgroundColorWithAlpha(UIContext &dc) { +uint32_t GetBackgroundColorWithAlpha(const UIContext &dc) { return colorAlpha(colorBlend(dc.GetTheme().backgroundColor, 0, 0.5f), 0.65f); // 0.65 = 166 = A6 } @@ -407,7 +407,7 @@ void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, f } } -void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager, Screen *activeScreen) { +void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager, const Screen *activeScreen) { bool isActiveScreen = manager->topScreen() == activeScreen; if (!strcmp(message, "clear jit") && PSP_IsInited()) { @@ -1070,7 +1070,7 @@ SettingInfoMessage::SettingInfoMessage(int align, UI::AnchorLayoutParams *lp) Add(new UI::Spacer(10.0f)); } -void SettingInfoMessage::Show(const std::string &text, UI::View *refView) { +void SettingInfoMessage::Show(const std::string &text, const UI::View *refView) { if (refView) { Bounds b = refView->GetBounds(); const UI::AnchorLayoutParams *lp = GetLayoutParams()->As(); diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 32fe101973..f91cfa6bfe 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -179,7 +179,7 @@ public: void SetBottomCutoff(float y) { cutOffY_ = y; } - void Show(const std::string &text, UI::View *refView = nullptr); + void Show(const std::string &text, const UI::View *refView = nullptr); void Draw(UIContext &dc) override; std::string GetText() const; @@ -191,4 +191,4 @@ private: bool showing_ = false; }; -uint32_t GetBackgroundColorWithAlpha(UIContext &dc); +uint32_t GetBackgroundColorWithAlpha(const UIContext &dc); diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 7faf3b6f2b..a179749ecf 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -332,8 +332,7 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText) } -void CtrlDisAsmView::drawBranchLine(HDC hdc, std::map& addressPositions, BranchLine& line) -{ +void CtrlDisAsmView::drawBranchLine(HDC hdc, std::map &addressPositions, const BranchLine &line) { HPEN pen; u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows); diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h index 9d58de1935..2930e41544 100644 --- a/Windows/Debugger/CtrlDisAsmView.h +++ b/Windows/Debugger/CtrlDisAsmView.h @@ -72,7 +72,7 @@ class CtrlDisAsmView void calculatePixelPositions(); bool getDisasmAddressText(u32 address, char* dest, bool abbreviateLabels, bool showData); void updateStatusBarText(); - void drawBranchLine(HDC hdc, std::map& addressPositions, BranchLine& line); + void drawBranchLine(HDC hdc, std::map &addressPositions, const BranchLine &line); void copyInstructions(u32 startAddr, u32 endAddr, bool withDisasm); std::set getSelectedLineArguments(); void drawArguments(HDC hdc, const DisassemblyLineInfo &line, int x, int y, int textColor, const std::set ¤tArguments); diff --git a/Windows/RawInput.cpp b/Windows/RawInput.cpp index c23efbcf88..b9853c1a79 100644 --- a/Windows/RawInput.cpp +++ b/Windows/RawInput.cpp @@ -251,7 +251,7 @@ namespace WindowsRawInput { return windowsTransTable[vKey]; } - void ProcessKeyboard(RAWINPUT *raw, bool foreground) { + void ProcessKeyboard(const RAWINPUT *raw, bool foreground) { if (menuActive && UpdateMenuActive()) { // Ignore keyboard input while a menu is active, it's probably interacting with the menu. return; @@ -302,7 +302,7 @@ namespace WindowsRawInput { return true; } - void ProcessMouse(HWND hWnd, RAWINPUT *raw, bool foreground) { + void ProcessMouse(HWND hWnd, const RAWINPUT *raw, bool foreground) { if (menuActive && UpdateMenuActive()) { // Ignore mouse input while a menu is active, it's probably interacting with the menu. return; diff --git a/unittest/TestArm64Emitter.cpp b/unittest/TestArm64Emitter.cpp index af0f37ca45..a795cfbb2f 100644 --- a/unittest/TestArm64Emitter.cpp +++ b/unittest/TestArm64Emitter.cpp @@ -8,7 +8,7 @@ #include "UnitTest.h" -static bool CheckLast(Arm64Gen::ARM64XEmitter &emit, const char *comp) { +static bool CheckLast(const Arm64Gen::ARM64XEmitter &emit, const char *comp) { u32 instr; memcpy(&instr, emit.GetCodePointer() - 4, 4); char disasm[512]; diff --git a/unittest/TestArmEmitter.cpp b/unittest/TestArmEmitter.cpp index 8932ba7c9c..848655058a 100644 --- a/unittest/TestArmEmitter.cpp +++ b/unittest/TestArmEmitter.cpp @@ -10,7 +10,7 @@ #include "UnitTest.h" -static bool CheckLast(ArmGen::ARMXEmitter &emit, const char *comp) { +static bool CheckLast(const ArmGen::ARMXEmitter &emit, const char *comp) { u32 instr; memcpy(&instr, emit.GetCodePointer() - 4, 4); char disasm[512]; diff --git a/unittest/TestX64Emitter.cpp b/unittest/TestX64Emitter.cpp index c92b415d12..14f1a003c2 100644 --- a/unittest/TestX64Emitter.cpp +++ b/unittest/TestX64Emitter.cpp @@ -14,13 +14,13 @@ static const u8 *prevStart = NULL; -bool CheckLast(Gen::XEmitter &emit, const char *comp) { +static bool CheckLast(const Gen::XEmitter &emit, const char *comp) { auto vec = DisassembleX86(prevStart, (int)(emit.GetCodePointer() - prevStart)); EXPECT_EQ_STR(vec[0], std::string(comp)); return true; } -void PrintLast(Gen::XEmitter &emit) { +static void PrintLast(const Gen::XEmitter &emit) { for (const u8 *p = prevStart; p < emit.GetCodePointer(); p++) { printf("%02x ", *p); } From 9cfcbc46e6bcd585916732c027fe844ffae060bd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Dec 2022 21:09:50 -0800 Subject: [PATCH 4/6] Global: Cleanup initialization/pointer checks. Cleaning up a lot of cases of uninitialized data, unchecked return values for failures, and similar. --- Common/Arm64Emitter.h | 2 +- Common/ArmEmitter.h | 29 ++++++------- Common/CPUDetect.cpp | 5 ++- Common/ConsoleListener.h | 4 +- Common/Data/Format/JSONReader.h | 8 ++-- Common/File/FileUtil.cpp | 5 ++- Common/GPU/D3D11/thin3d_d3d11.cpp | 6 ++- Common/GPU/D3D9/thin3d_d3d9.cpp | 9 ++-- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 9 ++-- Common/GPU/Vulkan/thin3d_vulkan.cpp | 12 ++---- Common/Math/expression_parser.cpp | 4 +- Common/Net/HTTPClient.cpp | 2 +- Common/Render/Text/draw_text_win.cpp | 1 + Common/RiscVEmitter.h | 2 +- Common/UI/ViewGroup.cpp | 2 +- Core/Debugger/DisassemblyManager.cpp | 2 +- Core/Debugger/SymbolMap.cpp | 8 ++-- Core/ELF/ElfReader.cpp | 6 +-- Core/FileSystems/MetaFileSystem.h | 2 +- Core/HLE/sceIo.cpp | 5 ++- Core/HW/Camera.cpp | 6 ++- Core/MIPS/IR/IRCompVFPU.cpp | 4 +- Core/Util/BlockAllocator.cpp | 1 + Core/Util/PortManager.cpp | 6 +++ GPU/Common/TextureShaderCommon.cpp | 2 +- GPU/D3D11/DrawEngineD3D11.cpp | 55 +++++++++++++++++-------- GPU/D3D11/TextureCacheD3D11.cpp | 6 ++- GPU/Debugger/Record.cpp | 2 + Windows/DSoundStream.cpp | 2 + Windows/Debugger/Debugger_Disasm.cpp | 4 +- Windows/Debugger/DumpMemoryWindow.cpp | 4 +- Windows/GPU/WindowsGLContext.h | 3 -- Windows/MainWindow.cpp | 2 +- Windows/RawInput.cpp | 10 ++++- Windows/TouchInputHandler.cpp | 15 +++---- Windows/W32Util/Misc.cpp | 12 +++--- Windows/W32Util/ShellUtil.cpp | 8 +++- Windows/WASAPIStream.cpp | 21 ++++++---- Windows/WindowsHost.cpp | 14 ++++--- Windows/XinputDevice.cpp | 6 +-- Windows/main.cpp | 22 ++++------ 41 files changed, 190 insertions(+), 138 deletions(-) diff --git a/Common/Arm64Emitter.h b/Common/Arm64Emitter.h index 66add4e269..aaeb24fb1d 100644 --- a/Common/Arm64Emitter.h +++ b/Common/Arm64Emitter.h @@ -253,7 +253,7 @@ public: private: ARM64Reg m_destReg; WidthSpecifier m_width; - ExtendSpecifier m_extend; + ExtendSpecifier m_extend = EXTEND_UXTB; TypeSpecifier m_type; ShiftType m_shifttype; u32 m_shift; diff --git a/Common/ArmEmitter.h b/Common/ArmEmitter.h index d71c1efdf2..46a36c8805 100644 --- a/Common/ArmEmitter.h +++ b/Common/ArmEmitter.h @@ -112,32 +112,29 @@ private: OpType Type; // IMM types - u8 Rotation; // Only for u8 values + u8 Rotation = 0; // Only for u8 values // Register types - u8 IndexOrShift; - ShiftType Shift; + u8 IndexOrShift = 0; + ShiftType Shift = ST_LSL; public: - OpType GetType() const - { + OpType GetType() const { return Type; } - Operand2() {} - Operand2(u32 imm, OpType type = TYPE_IMM) - { - Type = type; - Value = imm; - Rotation = 0; + Operand2() { + Type = TYPE_IMM; + Value = 0; + } + Operand2(u32 imm, OpType type = TYPE_IMM) { + Type = type; + Value = imm; } - Operand2(ARMReg Reg) - { + Operand2(ARMReg Reg) { Type = TYPE_REG; Value = Reg; - Rotation = 0; } - Operand2(u8 imm, u8 rotation) - { + Operand2(u8 imm, u8 rotation) { Type = TYPE_IMM; Value = imm; Rotation = rotation; diff --git a/Common/CPUDetect.cpp b/Common/CPUDetect.cpp index 262bbf4def..ebf78012b6 100644 --- a/Common/CPUDetect.cpp +++ b/Common/CPUDetect.cpp @@ -321,7 +321,10 @@ void CPUInfo::Detect() { #if PPSSPP_PLATFORM(WINDOWS) #if !PPSSPP_PLATFORM(UWP) typedef BOOL (WINAPI *getLogicalProcessorInformationEx_f)(LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer, PDWORD ReturnedLength); - auto getLogicalProcessorInformationEx = (getLogicalProcessorInformationEx_f)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetLogicalProcessorInformationEx"); + getLogicalProcessorInformationEx_f getLogicalProcessorInformationEx = nullptr; + HMODULE kernel32 = GetModuleHandle(L"kernel32.dll"); + if (kernel32) + getLogicalProcessorInformationEx = (getLogicalProcessorInformationEx_f)GetProcAddress(kernel32, "GetLogicalProcessorInformationEx"); #else void *getLogicalProcessorInformationEx = nullptr; #endif diff --git a/Common/ConsoleListener.h b/Common/ConsoleListener.h index 32a32b7981..99c6730750 100644 --- a/Common/ConsoleListener.h +++ b/Common/ConsoleListener.h @@ -66,8 +66,8 @@ private: static std::atomic logPendingReadPos; static std::atomic logPendingWritePos; - int openWidth_; - int openHeight_; + int openWidth_ = 0; + int openHeight_ = 0; std::wstring title_; #endif bool bHidden; diff --git a/Common/Data/Format/JSONReader.h b/Common/Data/Format/JSONReader.h index 4156650301..792d6a669a 100644 --- a/Common/Data/Format/JSONReader.h +++ b/Common/Data/Format/JSONReader.h @@ -47,9 +47,11 @@ public: JsonReader(const std::string &filename); JsonReader(const void *data, size_t size) { buffer_ = (char *)malloc(size + 1); - memcpy(buffer_, data, size); - buffer_[size] = 0; - parse(); + if (buffer_) { + memcpy(buffer_, data, size); + buffer_[size] = 0; + parse(); + } } JsonReader(const JsonNode *node) { ok_ = true; diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 8bab82ae6e..e8088e90bc 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -141,7 +141,7 @@ FILE *OpenCFile(const Path &path, const char *mode) { return nullptr; } FILE *f = fdopen(descriptor, "wb"); - if (!strcmp(mode, "at") || !strcmp(mode, "a")) { + if (f && (!strcmp(mode, "at") || !strcmp(mode, "a"))) { // Append mode. fseek(f, 0, SEEK_END); } @@ -250,7 +250,8 @@ static bool ResolvePathVista(const std::wstring &path, wchar_t *buf, DWORD bufSi #else if (!getFinalPathNameByHandleW) { HMODULE kernel32 = GetModuleHandle(L"kernel32.dll"); - getFinalPathNameByHandleW = (getFinalPathNameByHandleW_f)GetProcAddress(kernel32, "GetFinalPathNameByHandleW"); + if (kernel32) + getFinalPathNameByHandleW = (getFinalPathNameByHandleW_f)GetProcAddress(kernel32, "GetFinalPathNameByHandleW"); } #endif diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 43e6c2b653..faafc4998e 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -1476,6 +1476,7 @@ void D3D11DrawContext::CopyFramebufferImage(Framebuffer *srcfb, int level, int x dstTex = dst->depthStencilTex; break; } + _assert_(srcTex && dstTex); // TODO: Check for level too! if (width == src->Width() && width == dst->Width() && height == src->Height() && height == dst->Height() && x == 0 && y == 0 && z == 0 && dstX == 0 && dstY == 0 && dstZ == 0) { @@ -1534,7 +1535,7 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel bool useGlobalPacktex = (bx + bw <= 512 && by + bh <= 512) && channelBits == FB_COLOR_BIT; - ID3D11Texture2D *packTex; + ID3D11Texture2D *packTex = nullptr; if (!useGlobalPacktex) { D3D11_TEXTURE2D_DESC packDesc{}; packDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; @@ -1573,6 +1574,9 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel packTex = packTexture_; } + if (!packTex) + return false; + D3D11_BOX srcBox{ (UINT)bx, (UINT)by, 0, (UINT)(bx + bw), (UINT)(by + bh), 1 }; DataFormat srcFormat = DataFormat::UNDEFINED; switch (channelBits) { diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 94bce31760..bc0135e834 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -1072,16 +1072,16 @@ void D3D9Context::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offse return; } if (buf->vbuffer_) { - void *ptr; + void *ptr = nullptr; HRESULT res = buf->vbuffer_->Lock((UINT)offset, (UINT)size, &ptr, (flags & UPDATE_DISCARD) ? D3DLOCK_DISCARD : 0); - if (!FAILED(res)) { + if (!FAILED(res) && ptr) { memcpy(ptr, data, size); buf->vbuffer_->Unlock(); } } else if (buf->ibuffer_) { - void *ptr; + void *ptr = nullptr; HRESULT res = buf->ibuffer_->Lock((UINT)offset, (UINT)size, &ptr, (flags & UPDATE_DISCARD) ? D3DLOCK_DISCARD : 0); - if (!FAILED(res)) { + if (!FAILED(res) && ptr) { memcpy(ptr, data, size); buf->ibuffer_->Unlock(); } @@ -1438,6 +1438,7 @@ bool D3D9Context::CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, LPDIRECT3DSURFACE9 offscreen = nullptr; HRESULT hr = E_UNEXPECTED; + _assert_(fb != nullptr); if (channelBits == FB_COLOR_BIT) { fb->tex->GetLevelDesc(0, &desc); diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index ec38cabecd..53f5615931 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1324,7 +1324,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c { VKRGraphicsPipeline *graphicsPipeline = c.graphics_pipeline.pipeline; if (graphicsPipeline != lastGraphicsPipeline) { - VkSampleCountFlagBits fbSampleCount = step.render.framebuffer ? step.render.framebuffer->sampleCount : VK_SAMPLE_COUNT_1_BIT; + VkSampleCountFlagBits fbSampleCount = fb ? fb->sampleCount : VK_SAMPLE_COUNT_1_BIT; if (RenderPassTypeHasMultisample(rpType) && fbSampleCount != graphicsPipeline->SampleCount()) { // should have been invalidated. @@ -1421,12 +1421,13 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c case VKRRenderCommand::SELF_DEPENDENCY_BARRIER: { _assert_(step.render.pipelineFlags & PipelineFlags::USES_INPUT_ATTACHMENT); + _assert_(fb); VulkanBarrier barrier; - if (step.render.framebuffer->sampleCount != VK_SAMPLE_COUNT_1_BIT) { + if (fb->sampleCount != VK_SAMPLE_COUNT_1_BIT) { // Rendering is happening to the multisample buffer, not the color buffer. - SelfDependencyBarrier(step.render.framebuffer->msaaColor, VK_IMAGE_ASPECT_COLOR_BIT, &barrier); + SelfDependencyBarrier(fb->msaaColor, VK_IMAGE_ASPECT_COLOR_BIT, &barrier); } else { - SelfDependencyBarrier(step.render.framebuffer->color, VK_IMAGE_ASPECT_COLOR_BIT, &barrier); + SelfDependencyBarrier(fb->color, VK_IMAGE_ASPECT_COLOR_BIT, &barrier); } barrier.Flush(cmd); break; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index bb57abdea4..4cc760f429 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1184,16 +1184,12 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char } } - if (input) { - for (int i = 0; i < (int)input->bindings.size(); i++) { - pipeline->stride[i] = input->bindings[i].stride; - } - } else { - pipeline->stride[0] = 0; - } - _dbg_assert_(input->bindings.size() == 1); + _dbg_assert_(input && input->bindings.size() == 1); _dbg_assert_((int)input->attributes.size() == (int)input->visc.vertexAttributeDescriptionCount); + for (int i = 0; i < (int)input->bindings.size(); i++) { + pipeline->stride[i] = input->bindings[i].stride; + } gDesc.ibd = input->bindings[0]; for (size_t i = 0; i < input->attributes.size(); i++) { gDesc.attrs[i] = input->attributes[i]; diff --git a/Common/Math/expression_parser.cpp b/Common/Math/expression_parser.cpp index 75e0720c60..b591845bce 100644 --- a/Common/Math/expression_parser.cpp +++ b/Common/Math/expression_parser.cpp @@ -406,8 +406,8 @@ bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, size_t num = 0; uint32_t opcode; std::vector valueStack; - unsigned int arg[5]; - float fArg[5]; + unsigned int arg[5]{}; + float fArg[5]{}; bool useFloat = false; while (num < exp.size()) diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index fec31dabb8..bac18da12d 100644 --- a/Common/Net/HTTPClient.cpp +++ b/Common/Net/HTTPClient.cpp @@ -224,7 +224,7 @@ void DeChunk(Buffer *inbuffer, Buffer *outbuffer, int contentLength, float *prog inbuffer->TakeLineCRLF(&line); if (!line.size()) return; - unsigned int chunkSize; + unsigned int chunkSize = 0; sscanf(line.c_str(), "%x", &chunkSize); if (chunkSize) { std::string data; diff --git a/Common/Render/Text/draw_text_win.cpp b/Common/Render/Text/draw_text_win.cpp index d5af5af762..6cd9885fee 100644 --- a/Common/Render/Text/draw_text_win.cpp +++ b/Common/Render/Text/draw_text_win.cpp @@ -69,6 +69,7 @@ TextDrawerWin32::TextDrawerWin32(Draw::DrawContext *draw) : TextDrawer(draw), ct bmi.bmiHeader.biBitCount = 32; ctx_->hbmBitmap = CreateDIBSection(ctx_->hDC, &bmi, DIB_RGB_COLORS, (VOID**)&ctx_->pBitmapBits, NULL, 0); + _assert_(ctx_->hbmBitmap != nullptr); SetMapMode(ctx_->hDC, MM_TEXT); SelectObject(ctx_->hDC, ctx_->hbmBitmap); diff --git a/Common/RiscVEmitter.h b/Common/RiscVEmitter.h index f2e512a32c..e1b8266a56 100644 --- a/Common/RiscVEmitter.h +++ b/Common/RiscVEmitter.h @@ -113,7 +113,7 @@ struct FixupBranch { ~FixupBranch(); const u8 *ptr = nullptr; - FixupBranchType type; + FixupBranchType type = FixupBranchType::B; }; class RiscVEmitter { diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index de556ad5d9..f7b6f49d11 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -963,7 +963,7 @@ bool ScrollView::SubviewFocused(View *view) { float visibleSize = orientation_ == ORIENT_VERTICAL ? bounds_.h : bounds_.w; float visibleEnd = scrollPos_ + visibleSize; - float viewStart, viewEnd; + float viewStart = 0.0f, viewEnd = 0.0f; switch (orientation_) { case ORIENT_HORIZONTAL: viewStart = layoutScrollPos_ + vBounds.x - bounds_.x; diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index b57e52610d..667ba134ab 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -122,7 +122,7 @@ void parseDisasm(const char* disasm, char* opcode, char* arguments, bool insertS // parse symbol if (disasm == jumpAddress) { - u32 branchTarget; + u32 branchTarget = 0; sscanf(disasm+3,"%08x",&branchTarget); const std::string addressSymbol = g_symbolMap->GetLabelString(branchTarget); diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index 63e087d7a8..93a3d238e2 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -127,9 +127,9 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) { if (!started) continue; - u32 address = -1, size, vaddress = -1; + u32 address = -1, size = 0, vaddress = -1; int moduleIndex = 0; - int typeInt; + int typeInt = ST_NONE; SymbolType type; char name[128] = {0}; @@ -145,7 +145,9 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) { continue; } - sscanf(line, "%08x %08x %x %i %127c", &address, &size, &vaddress, &typeInt, name); + int matched = sscanf(line, "%08x %08x %x %i %127c", &address, &size, &vaddress, &typeInt, name); + if (matched < 1) + continue; type = (SymbolType) typeInt; if (!hasModules) { if (!Memory::IsValidAddress(vaddress)) { diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index a4a6bfb856..2baf2690d6 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -128,7 +128,7 @@ bool ElfReader::LoadRelocations(const Elf32_Rel *rels, int numRelocs) { if (log) { DEBUG_LOG(LOADER, "rel at: %08x info: %08x type: %i", addr, info, type); } - u32 relocateTo = segmentVAddr[relative]; + u32 relocateTo = relative >= (int)ARRAY_SIZE(segmentVAddr) ? 0 : segmentVAddr[relative]; switch (type) { case R_MIPS_32: @@ -289,9 +289,9 @@ void ElfReader::LoadRelocations2(int rel_seg) } }else{ addr_seg = seg; - relocate_to = segmentVAddr[addr_seg]; + relocate_to = addr_seg >= (int)ARRAY_SIZE(segmentVAddr) ? 0 : segmentVAddr[addr_seg]; if (!Memory::IsValidAddress(relocate_to)) { - ERROR_LOG(LOADER, "ELF: Bad address to relocate to: %08x", relocate_to); + ERROR_LOG(LOADER, "ELF: Bad address to relocate to: %08x (segment %d)", relocate_to, addr_seg); continue; } diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 545f21bddc..e574423dd6 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -91,7 +91,7 @@ public: int MapFilePath(const std::string &inpath, std::string &outpath, MountPoint **system); inline int MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system) { - MountPoint *mountPoint; + MountPoint *mountPoint = nullptr; int error = MapFilePath(_inpath, outpath, &mountPoint); if (error == 0) { *system = mountPoint->system.get(); diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index e6fbd166e7..d2cf9ec311 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -271,8 +271,9 @@ public: if (p.mode == p.MODE_READ) { pgdInfo = (PGD_DESC*) malloc(sizeof(PGD_DESC)); } - p.DoVoid(pgdInfo, sizeof(PGD_DESC)); - if (p.mode == p.MODE_READ) { + if (pgdInfo) + p.DoVoid(pgdInfo, sizeof(PGD_DESC)); + if (p.mode == p.MODE_READ && pgdInfo) { pgdInfo->block_buf = (u8 *)malloc(pgdInfo->block_size * 2); } } diff --git a/Core/HW/Camera.cpp b/Core/HW/Camera.cpp index 3b99eab646..9cf8138e21 100644 --- a/Core/HW/Camera.cpp +++ b/Core/HW/Camera.cpp @@ -60,7 +60,11 @@ void convert_frame(int inw, int inh, unsigned char *inData, AVPixelFormat inForm void __cameraDummyImage(int width, int height, unsigned char** outData, int* outLen) { #ifdef USE_FFMPEG - unsigned char* rgbData = (unsigned char*)malloc(3 * width * height); + unsigned char *rgbData = (unsigned char *)malloc(3 * width * height); + if (!rgbData) { + *outData = nullptr; + return; + } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { rgbData[3 * (y * width + x) + 0] = x*255/width; diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 11050c44cc..bfdcf69bed 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -184,7 +184,7 @@ namespace MIPSComp { return; int n = GetNumVectorElements(sz); - u8 origV[4]; + u8 origV[4]{}; static const float constantArray[8] = { 0.f, 1.f, 2.f, 0.5f, 3.f, 1.f / 3.f, 0.25f, 1.f / 6.f }; for (int i = 0; i < n; i++) @@ -1697,7 +1697,7 @@ namespace MIPSComp { GetVectorRegs(tregs, sz, _VT); GetVectorRegs(dregs, sz, _VD); - u8 tempregs[4]; + u8 tempregs[4]{}; for (int i = 0; i < n; ++i) { if (!IsOverlapSafe(dregs[i], n, sregs, n, tregs)) { tempregs[i] = IRVTEMP_PFX_T + i; // using IRTEMP0 for other things diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 696a43513d..270cca6508 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -462,6 +462,7 @@ void BlockAllocator::DoState(PointerWrap &p) } else { + _assert_(bottom_ != nullptr); for (const Block *bp = bottom_; bp != NULL; bp = bp->next) ++count; Do(p, count); diff --git a/Core/Util/PortManager.cpp b/Core/Util/PortManager.cpp index 79120053c8..b0c2bfe487 100644 --- a/Core/Util/PortManager.cpp +++ b/Core/Util/PortManager.cpp @@ -127,7 +127,13 @@ bool PortManager::Initialize(const unsigned int timeout) { m_leaseDuration = "43200"; // 12 hours m_InitState = UPNP_INITSTATE_BUSY; urls = (UPNPUrls*)malloc(sizeof(struct UPNPUrls)); + if (!urls) + return false; datas = (IGDdatas*)malloc(sizeof(struct IGDdatas)); + if (!datas) { + free(urls); + return false; + } memset(urls, 0, sizeof(struct UPNPUrls)); memset(datas, 0, sizeof(struct IGDdatas)); diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index b706edae66..93428a2238 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -233,7 +233,7 @@ std::vector TextureShaderCache::DebugGetShaderIDs(DebugShaderType t } std::string TextureShaderCache::DebugGetShaderString(std::string idstr, DebugShaderType type, DebugShaderStringType stringType) { - uint32_t id; + uint32_t id = 0; sscanf(idstr.c_str(), "%08x", &id); auto iter = depalCache_.find(id); if (iter == depalCache_.end()) diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 304d325ea9..87b7d866b8 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -760,6 +760,14 @@ TessellationDataTransferD3D11::~TessellationDataTransferD3D11() { } } +template +static void DoRelease(T *&ptr) { + if (ptr) { + ptr->Release(); + ptr = nullptr; + } +} + void TessellationDataTransferD3D11::SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) { struct TessData { float pos[3]; float pad1; @@ -769,19 +777,24 @@ void TessellationDataTransferD3D11::SendDataToShader(const SimpleVertex *const * int size = size_u * size_v; - if (prevSize < size) { + if (prevSize < size || !buf[0]) { prevSize = size; - if (buf[0]) buf[0]->Release(); - if (view[0]) view[0]->Release(); + DoRelease(buf[0]); + DoRelease(view[0]); desc.ByteWidth = size * sizeof(TessData); desc.StructureByteStride = sizeof(TessData); device_->CreateBuffer(&desc, nullptr, &buf[0]); - device_->CreateShaderResourceView(buf[0], nullptr, &view[0]); + if (buf[0]) + device_->CreateShaderResourceView(buf[0], nullptr, &view[0]); + if (!buf[0] || !view[0]) + return; context_->VSSetShaderResources(0, 1, &view[0]); } - D3D11_MAPPED_SUBRESOURCE map; - context_->Map(buf[0], 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + D3D11_MAPPED_SUBRESOURCE map{}; + HRESULT hr = context_->Map(buf[0], 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + if (FAILED(hr)) + return; uint8_t *data = (uint8_t *)map.pData; float *pos = (float *)(data); @@ -796,34 +809,42 @@ void TessellationDataTransferD3D11::SendDataToShader(const SimpleVertex *const * using Spline::Weight; // Weights U - if (prevSizeWU < weights.size_u) { + if (prevSizeWU < weights.size_u || !buf[1]) { prevSizeWU = weights.size_u; - if (buf[1]) buf[1]->Release(); - if (view[1]) view[1]->Release(); + DoRelease(buf[1]); + DoRelease(view[1]); desc.ByteWidth = weights.size_u * sizeof(Weight); desc.StructureByteStride = sizeof(Weight); device_->CreateBuffer(&desc, nullptr, &buf[1]); - device_->CreateShaderResourceView(buf[1], nullptr, &view[1]); + if (buf[1]) + device_->CreateShaderResourceView(buf[1], nullptr, &view[1]); + if (!buf[1] || !view[1]) + return; context_->VSSetShaderResources(1, 1, &view[1]); } - context_->Map(buf[1], 0, D3D11_MAP_WRITE_DISCARD, 0, &map); - memcpy(map.pData, weights.u, weights.size_u * sizeof(Weight)); + hr = context_->Map(buf[1], 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + if (SUCCEEDED(hr)) + memcpy(map.pData, weights.u, weights.size_u * sizeof(Weight)); context_->Unmap(buf[1], 0); // Weights V if (prevSizeWV < weights.size_v) { prevSizeWV = weights.size_v; - if (buf[2]) buf[2]->Release(); - if (view[2]) view[2]->Release(); + DoRelease(buf[2]); + DoRelease(view[2]); desc.ByteWidth = weights.size_v * sizeof(Weight); desc.StructureByteStride = sizeof(Weight); device_->CreateBuffer(&desc, nullptr, &buf[2]); - device_->CreateShaderResourceView(buf[2], nullptr, &view[2]); + if (buf[2]) + device_->CreateShaderResourceView(buf[2], nullptr, &view[2]); + if (!buf[2] || !view[2]) + return; context_->VSSetShaderResources(2, 1, &view[2]); } - context_->Map(buf[2], 0, D3D11_MAP_WRITE_DISCARD, 0, &map); - memcpy(map.pData, weights.v, weights.size_v * sizeof(Weight)); + hr = context_->Map(buf[2], 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + if (SUCCEEDED(hr)) + memcpy(map.pData, weights.v, weights.size_v * sizeof(Weight)); context_->Unmap(buf[2], 0); } diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 486ad9417f..b8e799b476 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -314,7 +314,7 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) { // We don't yet have mip generation, so clamp the number of levels to the ones we can load directly. levels = std::min(plan.levelsToCreate, plan.levelsToLoad); - ID3D11Texture2D *tex; + ID3D11Texture2D *tex = nullptr; D3D11_TEXTURE2D_DESC desc{}; desc.CPUAccessFlags = 0; desc.Usage = D3D11_USAGE_DEFAULT; @@ -329,7 +329,7 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) { ASSERT_SUCCESS(device_->CreateTexture2D(&desc, nullptr, &tex)); texture = tex; } else { - ID3D11Texture3D *tex; + ID3D11Texture3D *tex = nullptr; D3D11_TEXTURE3D_DESC desc{}; desc.CPUAccessFlags = 0; desc.Usage = D3D11_USAGE_DEFAULT; @@ -504,6 +504,8 @@ bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level ID3D11Texture2D *stagingCopy = nullptr; device_->CreateTexture2D(&desc, nullptr, &stagingCopy); + if (!stagingCopy) + return false; context_->CopyResource(stagingCopy, texture); D3D11_MAPPED_SUBRESOURCE map; diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index e5fa0b7d1d..391b031974 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -373,6 +373,8 @@ static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) { bool isDrawnVRAM = false; uint32_t start = (addr >> DIRTY_VRAM_SHIFT) & DIRTY_VRAM_MASK; uint32_t blocks = (sizeInRAM + DIRTY_VRAM_ROUND) >> DIRTY_VRAM_SHIFT; + if (start + blocks >= DIRTY_VRAM_SIZE) + return 0; bool startEven = (addr & DIRTY_VRAM_ROUND) == 0; bool endEven = ((addr + sizeInRAM) & DIRTY_VRAM_ROUND) == 0; for (uint32_t i = 0; i < blocks; ++i) { diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 96265d5eac..9144a3be4f 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -183,6 +183,8 @@ bool DSoundAudioBackend::Init(HWND window, StreamCallback _callback, int sampleR sampleRate_ = sampleRate; threadData_ = 0; hThread_ = (HANDLE)_beginthreadex(0, 0, soundThread, (void *)this, 0, 0); + if (!hThread_) + return false; SetThreadPriority(hThread_, THREAD_PRIORITY_ABOVE_NORMAL); return true; } diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index c7b98f52c5..00a7b1ed51 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -901,8 +901,8 @@ void CDisasm::ProcessUpdateDialog() { // Update Debug Counter if (PSP_IsInited()) { - wchar_t tempTicks[24]; - _snwprintf(tempTicks, 24, L"%lld", CoreTiming::GetTicks() - lastTicks); + wchar_t tempTicks[24]{}; + _snwprintf(tempTicks, 23, L"%lld", CoreTiming::GetTicks() - lastTicks); SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks); } diff --git a/Windows/Debugger/DumpMemoryWindow.cpp b/Windows/Debugger/DumpMemoryWindow.cpp index 1f852611c2..884ba3bccf 100644 --- a/Windows/Debugger/DumpMemoryWindow.cpp +++ b/Windows/Debugger/DumpMemoryWindow.cpp @@ -229,8 +229,8 @@ void DumpMemoryWindow::changeMode(HWND hwnd, Mode newMode) if (filenameChosen_ == false) SetWindowTextA(GetDlgItem(hwnd,IDC_DUMP_FILENAME),"Custom.dump"); } else { - u32 start, size; - const char* defaultFileName; + u32 start = 0, size = 0; + const char *defaultFileName = ""; switch (selectedMode) { diff --git a/Windows/GPU/WindowsGLContext.h b/Windows/GPU/WindowsGLContext.h index df8190f9dc..2909be60f1 100644 --- a/Windows/GPU/WindowsGLContext.h +++ b/Windows/GPU/WindowsGLContext.h @@ -47,7 +47,4 @@ private: volatile bool resumeRequested; HANDLE pauseEvent; HANDLE resumeEvent; - - int xres; - int yres; }; diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 1eb68f441f..9f3a66e090 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -195,7 +195,7 @@ namespace MainWindow if (g_Config.UseFullScreen() || inFullscreenResize) return; - WINDOWPLACEMENT placement; + WINDOWPLACEMENT placement{}; GetWindowPlacement(hwndMain, &placement); if (placement.showCmd == SW_SHOWNORMAL) { RECT rc; diff --git a/Windows/RawInput.cpp b/Windows/RawInput.cpp index b9853c1a79..6a5d779203 100644 --- a/Windows/RawInput.cpp +++ b/Windows/RawInput.cpp @@ -379,15 +379,21 @@ namespace WindowsRawInput { } LRESULT Process(HWND hWnd, WPARAM wParam, LPARAM lParam) { - UINT dwSize; + UINT dwSize = 0; GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); if (!rawInputBuffer) { rawInputBuffer = malloc(dwSize); + if (!rawInputBuffer) + return DefWindowProc(hWnd, WM_INPUT, wParam, lParam); memset(rawInputBuffer, 0, dwSize); rawInputBufferSize = dwSize; } if (dwSize > rawInputBufferSize) { - rawInputBuffer = realloc(rawInputBuffer, dwSize); + void *newBuf = realloc(rawInputBuffer, dwSize); + if (!newBuf) + return DefWindowProc(hWnd, WM_INPUT, wParam, lParam); + rawInputBuffer = newBuf; + rawInputBufferSize = dwSize; memset(rawInputBuffer, 0, dwSize); } GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBuffer, &dwSize, sizeof(RAWINPUTHEADER)); diff --git a/Windows/TouchInputHandler.cpp b/Windows/TouchInputHandler.cpp index d27850c759..d0f00e59f6 100644 --- a/Windows/TouchInputHandler.cpp +++ b/Windows/TouchInputHandler.cpp @@ -15,15 +15,12 @@ #include "Windows/MainWindow.h" TouchInputHandler::TouchInputHandler() { - touchInfo = (getTouchInputProc) GetProcAddress( - GetModuleHandle(TEXT("User32.dll")), - "GetTouchInputInfo"); - closeTouch = (closeTouchInputProc) GetProcAddress( - GetModuleHandle(TEXT("User32.dll")), - "CloseTouchInputHandle"); - registerTouch = (registerTouchProc) GetProcAddress( - GetModuleHandle(TEXT("User32.dll")), - "RegisterTouchWindow"); + HMODULE user32 = GetModuleHandle(TEXT("User32.dll")); + if (!user32) + return; + touchInfo = (getTouchInputProc)GetProcAddress(user32, "GetTouchInputInfo"); + closeTouch = (closeTouchInputProc)GetProcAddress(user32, "CloseTouchInputHandle"); + registerTouch = (registerTouchProc)GetProcAddress(user32, "RegisterTouchWindow"); } int TouchInputHandler::ToTouchID(int windowsID, bool allowAllocate) { diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index 4d9d101e41..2d7399f2e2 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -71,12 +71,14 @@ namespace W32Util // Lock the handle and copy the text to the buffer. wchar_t *lptstrCopy = (wchar_t *)GlobalLock(hglbCopy); - wcscpy(lptstrCopy, wtext.c_str()); - lptstrCopy[wtext.size()] = (wchar_t) 0; // null character - GlobalUnlock(hglbCopy); - SetClipboardData(CF_UNICODETEXT, hglbCopy); + if (lptstrCopy) { + wcscpy(lptstrCopy, wtext.c_str()); + lptstrCopy[wtext.size()] = (wchar_t) 0; // null character + GlobalUnlock(hglbCopy); + SetClipboardData(CF_UNICODETEXT, hglbCopy); + } CloseClipboard(); - return TRUE; + return lptstrCopy ? TRUE : FALSE; } void MakeTopMost(HWND hwnd, bool topMost) { diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index bd53935d27..2111a24674 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -33,7 +33,9 @@ namespace W32Util auto idList = SHBrowseForFolder(&info); HMODULE shell32 = GetModuleHandle(L"shell32.dll"); typedef BOOL (WINAPI *SHGetPathFromIDListEx_f)(PCIDLIST_ABSOLUTE pidl, PWSTR pszPath, DWORD cchPath, GPFIDL_FLAGS uOpts); - SHGetPathFromIDListEx_f SHGetPathFromIDListEx_ = (SHGetPathFromIDListEx_f)GetProcAddress(shell32, "SHGetPathFromIDListEx"); + SHGetPathFromIDListEx_f SHGetPathFromIDListEx_ = nullptr; + if (shell32) + SHGetPathFromIDListEx_ = (SHGetPathFromIDListEx_f)GetProcAddress(shell32, "SHGetPathFromIDListEx"); std::string result; if (SHGetPathFromIDListEx_) { @@ -156,7 +158,9 @@ namespace W32Util std::string result; HMODULE shell32 = GetModuleHandle(L"shell32.dll"); typedef HRESULT(WINAPI *SHGetKnownFolderPath_f)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); - SHGetKnownFolderPath_f SHGetKnownFolderPath_ = (SHGetKnownFolderPath_f)GetProcAddress(shell32, "SHGetKnownFolderPath"); + SHGetKnownFolderPath_f SHGetKnownFolderPath_ = nullptr; + if (shell32) + SHGetKnownFolderPath_ = (SHGetKnownFolderPath_f)GetProcAddress(shell32, "SHGetKnownFolderPath"); if (SHGetKnownFolderPath_) { PWSTR path = nullptr; if (SHGetKnownFolderPath_(FOLDERID_Documents, 0, nullptr, &path) == S_OK) { diff --git a/Windows/WASAPIStream.cpp b/Windows/WASAPIStream.cpp index 6079c030de..53f02245b9 100644 --- a/Windows/WASAPIStream.cpp +++ b/Windows/WASAPIStream.cpp @@ -159,16 +159,13 @@ public: __uuidof(IMMDeviceEnumerator), (void**)&_pEnumerator); } - if (hr == S_OK) - { + if (hr == S_OK && _pEnumerator) { hr = _pEnumerator->GetDevice(pwstrId, &pDevice); } - if (hr == S_OK) - { + if (hr == S_OK && pDevice) { hr = pDevice->OpenPropertyStore(STGM_READ, &pProps); } - if (hr == S_OK) - { + if (hr == S_OK && pProps) { // Get the endpoint device's friendly-name property. hr = pProps->GetValue(PKEY_Device_FriendlyName, &varString); } @@ -224,6 +221,8 @@ bool WASAPIAudioBackend::Init(HWND window, StreamCallback callback, int sampleRa callback_ = callback; sampleRate_ = sampleRate; hThread_ = (HANDLE)_beginthreadex(0, 0, soundThread, (void *)this, 0, 0); + if (!hThread_) + return false; SetThreadPriority(hThread_, THREAD_PRIORITY_ABOVE_NORMAL); return true; } @@ -333,7 +332,7 @@ void WASAPIAudioThread::ShutdownAudioDevice() { } bool WASAPIAudioThread::DetectFormat() { - if (!ValidateFormat(deviceFormat_)) { + if (deviceFormat_ && !ValidateFormat(deviceFormat_)) { // Last chance, let's try to ask for one we support instead. WAVEFORMATEXTENSIBLE fmt{}; fmt.Format.cbSize = sizeof(fmt); @@ -356,7 +355,8 @@ bool WASAPIAudioThread::DetectFormat() { CoTaskMemFree(closest); CoTaskMemFree(deviceFormat_); deviceFormat_ = (WAVEFORMATEXTENSIBLE *)CoTaskMemAlloc(sizeof(fmt)); - memcpy(deviceFormat_, &fmt, sizeof(fmt)); + if (deviceFormat_) + memcpy(deviceFormat_, &fmt, sizeof(fmt)); // In case something above gets out of date. return ValidateFormat(deviceFormat_); @@ -387,6 +387,8 @@ bool WASAPIAudioThread::ValidateFormat(const WAVEFORMATEXTENSIBLE *fmt) { // Don't know if PCM16 ever shows up here, the documentation only talks about float... but let's blindly // try to support it :P format_ = Format::UNKNOWN; + if (!fmt) + return false; if (fmt->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) { if (!memcmp(&fmt->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, sizeof(fmt->SubFormat))) { @@ -572,7 +574,8 @@ void WASAPIAudioThread::Run() { } int WASAPIAudioBackend::RunThread() { - CoInitializeEx(nullptr, COINIT_MULTITHREADED); + HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); + _dbg_assert_(SUCCEEDED(hr)); SetCurrentThreadName("WASAPI_audio"); if (threadData_ == 0) { diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 610b79890b..06e9ef1662 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -269,7 +269,7 @@ void WindowsHost::BootDone() { } static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { - File::FileInfo info; + File::FileInfo info{}; // can't fail, definitely exists if it gets this far File::GetFileInfo(currentFilename, &info); if (info.isDirectory) { @@ -311,14 +311,16 @@ bool WindowsHost::IsDebuggingEnabled() { // http://msdn.microsoft.com/en-us/library/aa969393.aspx HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) { HRESULT hres; - IShellLink* psl; - CoInitializeEx(NULL, COINIT_MULTITHREADED); + IShellLink *psl = nullptr; + hres = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if (FAILED(hres)) + return hres; // Get a pointer to the IShellLink interface. It is assumed that CoInitialize // has already been called. hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); - if (SUCCEEDED(hres)) { - IPersistFile* ppf; + if (SUCCEEDED(hres) && psl) { + IPersistFile *ppf = nullptr; // Set the path to the shortcut target and add the description. psl->SetPath(lpszPathObj); @@ -329,7 +331,7 @@ HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathL // shortcut in persistent storage. hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); - if (SUCCEEDED(hres)) { + if (SUCCEEDED(hres) && ppf) { // Save the link by calling IPersistFile::Save. hres = ppf->Save(lpszPathLink, TRUE); ppf->Release(); diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index b9d73c8ecd..3e82015921 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -38,7 +38,7 @@ static XInputGetState_t PPSSPP_XInputGetState = nullptr; static XInputSetState_t PPSSPP_XInputSetState = nullptr; static XInputGetCapabilitiesEx_t PPSSPP_XInputGetCapabilitiesEx = nullptr; static DWORD PPSSPP_XInputVersion = 0; -static HMODULE s_pXInputDLL = 0; +static HMODULE s_pXInputDLL = nullptr; static int s_XInputDLLRefCount = 0; static void UnloadXInputDLL(); @@ -105,7 +105,7 @@ static void UnloadXInputDLL() { if ( s_pXInputDLL ) { if (--s_XInputDLLRefCount == 0) { FreeLibrary( s_pXInputDLL ); - s_pXInputDLL = NULL; + s_pXInputDLL = nullptr; } } } @@ -206,7 +206,7 @@ void XinputDevice::UpdatePad(int pad, const XINPUT_STATE &state, XINPUT_VIBRATIO if (!notified[pad]) { notified[pad] = true; #if !PPSSPP_PLATFORM(UWP) - XINPUT_CAPABILITIES_EX caps; + XINPUT_CAPABILITIES_EX caps{}; if (PPSSPP_XInputGetCapabilitiesEx != nullptr && PPSSPP_XInputGetCapabilitiesEx(1, pad, 0, &caps) == ERROR_SUCCESS) { KeyMap::NotifyPadConnected(DEVICE_ID_XINPUT_0 + pad, StringFromFormat("Xbox 360 Pad: %d/%d", caps.vendorId, caps.productId)); } else { diff --git a/Windows/main.cpp b/Windows/main.cpp index 6584f0cf65..dc790cd7f8 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -113,7 +113,7 @@ void OpenDirectory(const char *path) { // SHParseDisplayName can't handle relative paths, so normalize first. std::string resolved = ReplaceAll(File::ResolvePath(path), "/", "\\"); - SFGAOF flags; + SFGAOF flags{}; PIDLIST_ABSOLUTE pidl = nullptr; HRESULT hr = SHParseDisplayName(ConvertUTF8ToWString(resolved).c_str(), nullptr, &pidl, 0, &flags); @@ -174,8 +174,8 @@ std::string GetVideoCardDriverVersion() { IEnumWbemClassObject* pEnum; hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum); - ULONG uReturned; - VARIANT var; + ULONG uReturned = 0; + VARIANT var{}; IWbemClassObject* pObj = NULL; if (!FAILED(hr)) { hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &uReturned); @@ -372,16 +372,8 @@ void System_SendMessage(const char *command, const char *parameter) { std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error")); MessageBox(MainWindow::GetHWND(), full_error.c_str(), title.c_str(), MB_OK); } else if (!strcmp(command, "setclipboardtext")) { - if (OpenClipboard(MainWindow::GetDisplayHWND())) { - std::wstring data = ConvertUTF8ToWString(parameter); - HANDLE handle = GlobalAlloc(GMEM_MOVEABLE, (data.size() + 1) * sizeof(wchar_t)); - wchar_t *wstr = (wchar_t *)GlobalLock(handle); - memcpy(wstr, data.c_str(), (data.size() + 1) * sizeof(wchar_t)); - GlobalUnlock(wstr); - SetClipboardData(CF_UNICODETEXT, handle); - GlobalFree(handle); - CloseClipboard(); - } + std::wstring data = ConvertUTF8ToWString(parameter); + W32Util::CopyTextToClipboard(MainWindow::GetDisplayHWND(), data); } else if (!strcmp(command, "browse_file")) { MainWindow::BrowseAndBoot(""); } else if (!strcmp(command, "browse_folder")) { @@ -411,6 +403,8 @@ void EnableCrashingOnCrashes() { const DWORD EXCEPTION_SWALLOWING = 0x1; HMODULE kernel32 = LoadLibrary(L"kernel32.dll"); + if (!kernel32) + return; tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32, "GetProcessUserModeExceptionPolicy"); tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32, @@ -773,7 +767,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin break; } - if (!TranslateAccelerator(wnd, accel, &msg)) { + if (!wnd || !accel || !TranslateAccelerator(wnd, accel, &msg)) { if (!DialogManager::IsDialogMessage(&msg)) { //and finally translate and dispatch TranslateMessage(&msg); From 18106922366ff5ddf8d1995919f231334b9d4b76 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Dec 2022 21:12:36 -0800 Subject: [PATCH 5/6] Global: Cleanup some type/range checks. --- Common/Buffer.cpp | 4 +++- Common/RiscVEmitter.cpp | 4 ++-- Core/Util/DisArm64.cpp | 8 ++++---- GPU/Common/FramebufferManagerCommon.cpp | 2 +- Windows/CaptureDevice.cpp | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Common/Buffer.cpp b/Common/Buffer.cpp index 6dc6b74c5a..58a485593c 100644 --- a/Common/Buffer.cpp +++ b/Common/Buffer.cpp @@ -67,7 +67,9 @@ int Buffer::TakeLineCRLF(std::string *dest) { if (after_next_line < 0) { return after_next_line; } else { - Take(after_next_line - 2, dest); + _dbg_assert_(after_next_line >= 2); + if (after_next_line != 2) + Take((size_t)after_next_line - 2, dest); Skip(2); // Skip the CRLF return after_next_line - 2; } diff --git a/Common/RiscVEmitter.cpp b/Common/RiscVEmitter.cpp index 3f0d47499b..6849acbd19 100644 --- a/Common/RiscVEmitter.cpp +++ b/Common/RiscVEmitter.cpp @@ -615,7 +615,7 @@ const u8 *RiscVEmitter::AlignCode16() { const u8 *RiscVEmitter::AlignCodePage() { int page_size = GetMemoryProtectPageSize(); - int c = int((u64)code_ & (page_size - 1)); + int c = int((intptr_t)code_ & ((intptr_t)page_size - 1)); if (c) ReserveCodeSpace(page_size - c); return code_; @@ -747,7 +747,7 @@ void RiscVEmitter::SetRegToImmediate(RiscVReg rd, uint64_t value, RiscVReg temp) if (SignReduce64(v, 32) == v || force) { int32_t lower = (int32_t)SignReduce64(svalue, 12); int32_t upper = ((v - lower) >> 12) << 12; - _assert_msg_(force || upper + lower == v, "Upper + ADDI immediate math mistake?"); + _assert_msg_(force || (int64_t)upper + lower == v, "Upper + ADDI immediate math mistake?"); // Should be fused on some processors. (this->*upperOp)(rd, upper); diff --git a/Core/Util/DisArm64.cpp b/Core/Util/DisArm64.cpp index eac1edaed5..050589f2f0 100644 --- a/Core/Util/DisArm64.cpp +++ b/Core/Util/DisArm64.cpp @@ -421,14 +421,14 @@ static void DataProcessingRegister(uint32_t w, uint64_t addr, Instruction *instr const char *op = opcode2 >= 8 ? "unk" : opname[opcode]; snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d", op, r, Rd, r, Rn); } else if (((w >> 21) & 0x2FF) == 0x0D6) { - const char *opname[32] = { + const char *opname[64] = { 0, 0, "udiv", "sdiv", 0, 0, 0, 0, "lslv", "lsrv", "asrv", "rorv", 0, 0, 0, 0, "crc32b", "crc32h", "crc32w", 0, "crc32cb", "crc32ch", "crc32cw", 0, }; int opcode = (w >> 10) & 0x3F; // Data processing (2 source) - snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d, %c%d", opname[opcode], r, Rd, r, Rn, r, Rm); + snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d, %c%d", opname[opcode] ? opname[opcode] : "?", r, Rd, r, Rn, r, Rm); } else if (((w >> 24) & 0x1f) == 0xA) { // Logical (shifted register) int shift = (w >> 22) & 0x3; @@ -929,9 +929,9 @@ static void FPandASIMD2(uint32_t w, uint64_t addr, Instruction *instr) { snprintf(instr->text, sizeof(instr->text), "(float cond compare %08x)", w); } else if (((w >> 10) & 3) == 2) { int opc = (w >> 12) & 0xf; - const char *opnames[9] = { "fmul", "fdiv", "fadd", "fsub", "fmax", "fmin", "fmaxnm", "fminnm", "fnmul" }; + const char *opnames[16] = { "fmul", "fdiv", "fadd", "fsub", "fmax", "fmin", "fmaxnm", "fminnm", "fnmul" }; char r = ((w >> 22) & 1) ? 'd' : 's'; - snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d, %c%d", opnames[opc], r, Rd, r, Rn, r, Rm); + snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d, %c%d", opnames[opc] ? opnames[opc] : "?", r, Rd, r, Rn, r, Rm); } else if (((w >> 10) & 3) == 3) { char fr = ((w >> 22) & 1) ? 'd' : 's'; int cond = (w >> 12) & 0xf; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index d3bfa8677f..1fa20e2733 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1999,7 +1999,7 @@ bool FramebufferManagerCommon::FindTransferFramebuffer(u32 basePtr, int stride_p } } - if (!candidates.empty()) { + if (best) { *rect = *best; return true; } else { diff --git a/Windows/CaptureDevice.cpp b/Windows/CaptureDevice.cpp index e522c7b24e..7b61fa6fa0 100644 --- a/Windows/CaptureDevice.cpp +++ b/Windows/CaptureDevice.cpp @@ -716,7 +716,7 @@ std::vector WindowsCaptureDevice::getDeviceList(bool forceEnum, int // Get the size needed first dwMinSize = WideCharToMultiByte(CP_UTF8, NULL, pwstrName, -1, nullptr, 0, nullptr, FALSE); if (dwMinSize == 0) - hr = -1; + hr = E_FAIL; } if (SUCCEEDED(hr)) { cstrName = new char[dwMinSize]; From c9f3878e9dac73fa61aa0af1176805db9abbd598 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Dec 2022 21:12:58 -0800 Subject: [PATCH 6/6] Core: Correct a use after free. --- Core/Loaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 37722fe0cf..5657bd281c 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -392,8 +392,8 @@ bool UmdReplace(const Path &filepath, std::string &error) { FileLoader *loadedFile = ConstructFileLoader(filepath); if (!loadedFile->Exists()) { - delete loadedFile; error = loadedFile->GetPath().ToVisualString() + " doesn't exist"; + delete loadedFile; return false; } UpdateLoadedFile(loadedFile);