Fix some -Weffc++ warnings (part 2)

This commit is contained in:
Nekotekina 2021-04-03 19:38:02 +03:00
parent c1f1b1174d
commit 963d150e93
28 changed files with 169 additions and 130 deletions

View file

@ -218,6 +218,10 @@ asmjit::Runtime& asmjit::get_global_runtime()
utils::memory_commit(m_pos, size, utils::protection::wx); utils::memory_commit(m_pos, size, utils::protection::wx);
} }
custom_runtime(const custom_runtime&) = delete;
custom_runtime& operator=(const custom_runtime&) = delete;
asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override
{ {
usz codeSize = code->getCodeSize(); usz codeSize = code->getCodeSize();
@ -384,6 +388,10 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager
MemoryManager1() = default; MemoryManager1() = default;
MemoryManager1(const MemoryManager1&) = delete;
MemoryManager1& operator=(const MemoryManager1&) = delete;
~MemoryManager1() override ~MemoryManager1() override
{ {
utils::memory_release(ptr, c_max_size * 2); utils::memory_release(ptr, c_max_size * 2);

View file

@ -16,6 +16,7 @@
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing" #pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wredundant-decls" #pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Weffc++"
#ifndef __clang__ #ifndef __clang__
#pragma GCC diagnostic ignored "-Wduplicated-branches" #pragma GCC diagnostic ignored "-Wduplicated-branches"
@ -205,13 +206,13 @@ inline FT build_function_asm(F&& builder)
class jit_compiler final class jit_compiler final
{ {
// Local LLVM context // Local LLVM context
llvm::LLVMContext m_context; llvm::LLVMContext m_context{};
// Execution instance // Execution instance
std::unique_ptr<llvm::ExecutionEngine> m_engine; std::unique_ptr<llvm::ExecutionEngine> m_engine{};
// Arch // Arch
std::string m_cpu; std::string m_cpu{};
public: public:
jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags = 0); jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags = 0);

View file

@ -47,14 +47,14 @@ namespace LUrlParser
{ {
public: public:
LUrlParserError m_ErrorCode; LUrlParserError m_ErrorCode;
std::string m_Scheme; std::string m_Scheme{};
std::string m_Host; std::string m_Host{};
std::string m_Port; std::string m_Port{};
std::string m_Path; std::string m_Path{};
std::string m_Query; std::string m_Query{};
std::string m_Fragment; std::string m_Fragment{};
std::string m_UserName; std::string m_UserName{};
std::string m_Password; std::string m_Password{};
clParseURL() clParseURL()
: m_ErrorCode( LUrlParserError_Uninitialized ) : m_ErrorCode( LUrlParserError_Uninitialized )

View file

@ -21,11 +21,11 @@ constexpr u8 cheat_type_max = static_cast<u8>(cheat_type::max);
struct cheat_info struct cheat_info
{ {
std::string game; std::string game{};
std::string description; std::string description{};
cheat_type type = cheat_type::max; cheat_type type = cheat_type::max;
u32 offset{}; u32 offset{};
std::string red_script; std::string red_script{};
bool from_str(const std::string& cheat_line); bool from_str(const std::string& cheat_line);
std::string to_str() const; std::string to_str() const;

View file

@ -1,6 +1,19 @@
#pragma once #pragma once
#ifdef _MSC_VER
#pragma warning(push, 0)
#include <pugixml.hpp> #include <pugixml.hpp>
#pragma warning(pop)
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Weffc++"
#include <pugixml.hpp>
#pragma GCC diagnostic pop
#endif
#include <memory> #include <memory>
struct rXmlNode struct rXmlNode
@ -13,7 +26,7 @@ struct rXmlNode
std::string GetAttribute( const std::string &name); std::string GetAttribute( const std::string &name);
std::string GetNodeContent(); std::string GetNodeContent();
pugi::xml_node handle; pugi::xml_node handle{};
}; };
struct rXmlDocument struct rXmlDocument
@ -24,5 +37,5 @@ struct rXmlDocument
void Read(const std::string& data); void Read(const std::string& data);
std::shared_ptr<rXmlNode> GetRoot(); std::shared_ptr<rXmlNode> GetRoot();
pugi::xml_document handle; pugi::xml_document handle{};
}; };

View file

@ -20,15 +20,15 @@ enum SELF_KEY_TYPE
struct SELF_KEY struct SELF_KEY
{ {
u64 version_start; u64 version_start{};
u64 version_end; u64 version_end{};
u16 revision; u16 revision{};
u32 self_type; u32 self_type{};
u8 erk[0x20]; u8 erk[0x20]{};
u8 riv[0x10]; u8 riv[0x10]{};
u8 pub[0x28]; u8 pub[0x28]{};
u8 priv[0x15]; u8 priv[0x15]{};
u32 curve_type; u32 curve_type{};
SELF_KEY(u64 ver_start, u64 ver_end, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct); SELF_KEY(u64 ver_start, u64 ver_end, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct);
}; };
@ -182,15 +182,15 @@ constexpr u8 PUP_KEY[0x40] = {
class KeyVault class KeyVault
{ {
std::vector<SELF_KEY> sk_LV0_arr; std::vector<SELF_KEY> sk_LV0_arr{};
std::vector<SELF_KEY> sk_LV1_arr; std::vector<SELF_KEY> sk_LV1_arr{};
std::vector<SELF_KEY> sk_LV2_arr; std::vector<SELF_KEY> sk_LV2_arr{};
std::vector<SELF_KEY> sk_APP_arr; std::vector<SELF_KEY> sk_APP_arr{};
std::vector<SELF_KEY> sk_ISO_arr; std::vector<SELF_KEY> sk_ISO_arr{};
std::vector<SELF_KEY> sk_LDR_arr; std::vector<SELF_KEY> sk_LDR_arr{};
std::vector<SELF_KEY> sk_UNK7_arr; std::vector<SELF_KEY> sk_UNK7_arr{};
std::vector<SELF_KEY> sk_NPDRM_arr; std::vector<SELF_KEY> sk_NPDRM_arr{};
std::unique_ptr<u8[]> klicensee_key; std::unique_ptr<u8[]> klicensee_key{};
public: public:
KeyVault(); KeyVault();

View file

@ -57,11 +57,11 @@ struct EDATADecrypter final : fs::file_base
u32 total_blocks{0}; u32 total_blocks{0};
u64 pos{0}; u64 pos{0};
NPD_HEADER npdHeader; NPD_HEADER npdHeader{};
EDAT_HEADER edatHeader; EDAT_HEADER edatHeader{};
// Internal data buffers. // Internal data buffers.
std::unique_ptr<u8[]> data_buf; std::unique_ptr<u8[]> data_buf{};
u64 data_buf_size{0}; u64 data_buf_size{0};
u128 dec_key{}; u128 dec_key{};

View file

@ -323,16 +323,16 @@ private:
bool m_is_valid = false; bool m_is_valid = false;
std::string m_path; std::string m_path{};
std::string m_install_dir; std::string m_install_dir{};
std::vector<fs::file> m_filelist; std::vector<fs::file> m_filelist{};
usz m_cur_file = 0; usz m_cur_file = 0;
u64 m_cur_offset = 0; u64 m_cur_offset = 0;
u64 m_cur_file_offset = 0; u64 m_cur_file_offset = 0;
std::unique_ptr<u128[]> m_buf; std::unique_ptr<u128[]> m_buf{};
std::array<uchar, 16> m_dec_key{}; std::array<uchar, 16> m_dec_key{};
PKGHeader m_header{}; PKGHeader m_header{};
PKGMetaData m_metadata{}; PKGMetaData m_metadata{};
psf::registry m_psf; psf::registry m_psf{};
}; };

View file

@ -359,18 +359,18 @@ protected:
const fs::file& sce_f; const fs::file& sce_f;
// SCE headers. // SCE headers.
SceHeader sce_hdr; SceHeader sce_hdr{};
// Metadata structs. // Metadata structs.
MetadataInfo meta_info; MetadataInfo meta_info{};
MetadataHeader meta_hdr; MetadataHeader meta_hdr{};
std::vector<MetadataSectionHeader> meta_shdr; std::vector<MetadataSectionHeader> meta_shdr{};
// Internal data buffers. // Internal data buffers.
std::unique_ptr<u8[]> data_keys; std::unique_ptr<u8[]> data_keys{};
u32 data_keys_length; u32 data_keys_length{};
std::unique_ptr<u8[]> data_buf; std::unique_ptr<u8[]> data_buf{};
u32 data_buf_length; u32 data_buf_length{};
public: public:
SCEDecrypter(const fs::file& s); SCEDecrypter(const fs::file& s);
@ -386,38 +386,38 @@ class SELFDecrypter
const fs::file& self_f; const fs::file& self_f;
// SCE, SELF and APP headers. // SCE, SELF and APP headers.
SceHeader sce_hdr; SceHeader sce_hdr{};
SelfHeader self_hdr; SelfHeader self_hdr{};
AppInfo app_info; AppInfo app_info{};
// ELF64 header and program header/section header arrays. // ELF64 header and program header/section header arrays.
Elf64_Ehdr elf64_hdr; Elf64_Ehdr elf64_hdr{};
std::vector<Elf64_Shdr> shdr64_arr; std::vector<Elf64_Shdr> shdr64_arr{};
std::vector<Elf64_Phdr> phdr64_arr; std::vector<Elf64_Phdr> phdr64_arr{};
// ELF32 header and program header/section header arrays. // ELF32 header and program header/section header arrays.
Elf32_Ehdr elf32_hdr; Elf32_Ehdr elf32_hdr{};
std::vector<Elf32_Shdr> shdr32_arr; std::vector<Elf32_Shdr> shdr32_arr{};
std::vector<Elf32_Phdr> phdr32_arr; std::vector<Elf32_Phdr> phdr32_arr{};
// Decryption info structs. // Decryption info structs.
std::vector<SectionInfo> secinfo_arr; std::vector<SectionInfo> secinfo_arr{};
SCEVersionInfo scev_info; SCEVersionInfo scev_info{};
std::vector<ControlInfo> ctrlinfo_arr; std::vector<ControlInfo> ctrlinfo_arr{};
// Metadata structs. // Metadata structs.
MetadataInfo meta_info; MetadataInfo meta_info{};
MetadataHeader meta_hdr; MetadataHeader meta_hdr{};
std::vector<MetadataSectionHeader> meta_shdr; std::vector<MetadataSectionHeader> meta_shdr{};
// Internal data buffers. // Internal data buffers.
std::unique_ptr<u8[]> data_keys; std::unique_ptr<u8[]> data_keys{};
u32 data_keys_length; u32 data_keys_length{};
std::unique_ptr<u8[]> data_buf; std::unique_ptr<u8[]> data_buf{};
u32 data_buf_length = 0; u32 data_buf_length{};
// Main key vault instance. // Main key vault instance.
KeyVault key_v; KeyVault key_v{};
public: public:
SELFDecrypter(const fs::file& s); SELFDecrypter(const fs::file& s);

View file

@ -7,10 +7,10 @@
class OpenALBackend : public AudioBackend class OpenALBackend : public AudioBackend
{ {
private: private:
ALint m_format; ALint m_format{};
ALuint m_source; ALuint m_source{};
ALuint m_buffers[MAX_AUDIO_BUFFERS]; ALuint m_buffers[MAX_AUDIO_BUFFERS]{};
ALsizei m_num_buffers; ALsizei m_num_buffers{};
u32 m_next_buffer = 0; u32 m_next_buffer = 0;
u32 m_num_unqueued = 0; u32 m_num_unqueued = 0;

View file

@ -10,14 +10,17 @@
class ALSABackend : public AudioBackend class ALSABackend : public AudioBackend
{ {
snd_pcm_t* tls_handle{nullptr}; snd_pcm_t* tls_handle{};
snd_pcm_hw_params_t* tls_hw_params{nullptr}; snd_pcm_hw_params_t* tls_hw_params{};
snd_pcm_sw_params_t* tls_sw_params{nullptr}; snd_pcm_sw_params_t* tls_sw_params{};
public: public:
ALSABackend(); ALSABackend();
virtual ~ALSABackend() override; virtual ~ALSABackend() override;
ALSABackend(const ALSABackend&) = delete;
ALSABackend& operator=(const ALSABackend&) = delete;
virtual const char* GetName() const override { return "ALSA"; } virtual const char* GetName() const override { return "ALSA"; }
static const u32 capabilities = 0; static const u32 capabilities = 0;

View file

@ -63,8 +63,8 @@ struct WAVHeader
class AudioDumper class AudioDumper
{ {
WAVHeader m_header; WAVHeader m_header{};
fs::file m_output; fs::file m_output{};
public: public:
AudioDumper(u16 ch); AudioDumper(u16 ch);

View file

@ -10,14 +10,17 @@
class FAudioBackend : public AudioBackend class FAudioBackend : public AudioBackend
{ {
private: private:
FAudio* m_instance; FAudio* m_instance{};
FAudioMasteringVoice* m_master_voice; FAudioMasteringVoice* m_master_voice{};
FAudioSourceVoice* m_source_voice = nullptr; FAudioSourceVoice* m_source_voice{};
public: public:
FAudioBackend(); FAudioBackend();
virtual ~FAudioBackend() override; virtual ~FAudioBackend() override;
FAudioBackend(const FAudioBackend&) = delete;
FAudioBackend& operator=(const FAudioBackend&) = delete;
virtual const char* GetName() const override virtual const char* GetName() const override
{ {
return "FAudio"; return "FAudio";

View file

@ -13,6 +13,9 @@ public:
PulseBackend(); PulseBackend();
virtual ~PulseBackend() override; virtual ~PulseBackend() override;
PulseBackend(const PulseBackend&) = delete;
PulseBackend& operator=(const PulseBackend&) = delete;
virtual const char* GetName() const override { return "Pulse"; } virtual const char* GetName() const override { return "Pulse"; }
static const u32 capabilities = 0; static const u32 capabilities = 0;
@ -24,5 +27,5 @@ public:
virtual bool AddData(const void* src, u32 num_samples) override; virtual bool AddData(const void* src, u32 num_samples) override;
private: private:
pa_simple *connection = nullptr; pa_simple* connection{};
}; };

View file

@ -13,7 +13,7 @@
class XAudio2Backend final : public AudioBackend class XAudio2Backend final : public AudioBackend
{ {
private: private:
Microsoft::WRL::ComPtr<IXAudio2> m_xaudio2_instance; Microsoft::WRL::ComPtr<IXAudio2> m_xaudio2_instance{};
IXAudio2MasteringVoice* m_master_voice{}; IXAudio2MasteringVoice* m_master_voice{};
IXAudio2SourceVoice* m_source_voice{}; IXAudio2SourceVoice* m_source_voice{};
@ -21,6 +21,9 @@ public:
XAudio2Backend(); XAudio2Backend();
virtual ~XAudio2Backend() override; virtual ~XAudio2Backend() override;
XAudio2Backend(const XAudio2Backend&) = delete;
XAudio2Backend& operator=(const XAudio2Backend&) = delete;
virtual const char* GetName() const override { return "XAudio2"; }; virtual const char* GetName() const override { return "XAudio2"; };
static const u32 capabilities = PLAY_PAUSE_FLUSH | IS_PLAYING | GET_NUM_ENQUEUED_SAMPLES | SET_FREQUENCY_RATIO; static const u32 capabilities = PLAY_PAUSE_FLUSH | IS_PLAYING | GET_NUM_ENQUEUED_SAMPLES | SET_FREQUENCY_RATIO;

View file

@ -31,10 +31,10 @@ struct ppu_function
u32 stack_frame = 0; u32 stack_frame = 0;
u32 trampoline = 0; u32 trampoline = 0;
std::map<u32, u32> blocks; // Basic blocks: addr -> size std::map<u32, u32> blocks{}; // Basic blocks: addr -> size
std::set<u32> calls; // Set of called functions std::set<u32> calls{}; // Set of called functions
std::set<u32> callers; std::set<u32> callers{};
std::string name; // Function name std::string name{}; // Function name
}; };
// PPU Relocation Information // PPU Relocation Information

View file

@ -399,7 +399,7 @@ extern void ppu_trap(ppu_thread& ppu, u64 addr);
class ppu_scale_table_t class ppu_scale_table_t
{ {
std::array<v128, 32 + 31> m_data; std::array<v128, 32 + 31> m_data{};
public: public:
ppu_scale_table_t() ppu_scale_table_t()

View file

@ -172,6 +172,10 @@ struct lv2_fs_object
{ {
} }
lv2_fs_object(const lv2_fs_object&) = delete;
lv2_fs_object& operator=(const lv2_fs_object&) = delete;
virtual ~lv2_fs_object() = default; virtual ~lv2_fs_object() = default;
static lv2_fs_mount_point* get_mp(std::string_view filename); static lv2_fs_mount_point* get_mp(std::string_view filename);

View file

@ -20,13 +20,13 @@ namespace rsx
struct transport_packet struct transport_packet
{ {
op type; op type{};
std::vector<u8> opt_storage; std::vector<u8> opt_storage{};
void *src; void* src{};
void *dst; void* dst{};
u32 length; u32 length{};
u32 aux_param0; u32 aux_param0{};
u32 aux_param1; u32 aux_param1{};
transport_packet(void *_dst, void *_src, u32 len) transport_packet(void *_dst, void *_src, u32 len)
: type(op::raw_copy), src(_src), dst(_dst), length(len) : type(op::raw_copy), src(_src), dst(_dst), length(len)

View file

@ -4,7 +4,7 @@
#include "util/sysinfo.hpp" #include "util/sysinfo.hpp"
cfg_root g_cfg; cfg_root g_cfg{};
bool cfg_root::node_core::has_rtm() const bool cfg_root::node_core::has_rtm() const
{ {

View file

@ -295,7 +295,7 @@ struct cfg_root : cfg::node
cfg::log_entry log{ this, "Log" }; cfg::log_entry log{ this, "Log" };
std::string name; std::string name{};
}; };
extern cfg_root g_cfg; extern cfg_root g_cfg;

View file

@ -21,10 +21,10 @@ namespace psf
class entry final class entry final
{ {
format m_type; format m_type{};
u32 m_max_size; // Entry max size (supplementary info, stored in PSF format) u32 m_max_size{}; // Entry max size (supplementary info, stored in PSF format)
u32 m_value_integer; // TODO: is it really unsigned? u32 m_value_integer{}; // TODO: is it really unsigned?
std::string m_value_string; std::string m_value_string{};
public: public:
// Construct string entry, assign the value // Construct string entry, assign the value

View file

@ -46,13 +46,13 @@ enum class pup_error : u32
class pup_object class pup_object
{ {
fs::file m_file; fs::file m_file{};
pup_error m_error{}; pup_error m_error{};
std::string m_formatted_error; std::string m_formatted_error{};
std::vector<PUPFileEntry> m_file_tbl; std::vector<PUPFileEntry> m_file_tbl{};
std::vector<PUPHashEntry> m_hash_tbl; std::vector<PUPHashEntry> m_hash_tbl{};
pup_error validate_hashes(); pup_error validate_hashes();

View file

@ -24,8 +24,8 @@ struct TRPEntry
class TRPLoader final class TRPLoader final
{ {
const fs::file& trp_f; const fs::file& trp_f;
TRPHeader m_header; TRPHeader m_header{};
std::vector<TRPEntry> m_entries; std::vector<TRPEntry> m_entries{};
public: public:
TRPLoader(const fs::file& f); TRPLoader(const fs::file& f);

View file

@ -6,7 +6,7 @@ namespace utils
{ {
class cpu_stats class cpu_stats
{ {
u64 m_last_cpu, m_sys_cpu, m_usr_cpu; u64 m_last_cpu = 0, m_sys_cpu = 0, m_usr_cpu = 0;
public: public:
cpu_stats(); cpu_stats();

View file

@ -70,19 +70,19 @@ namespace logs
class file_writer class file_writer
{ {
std::thread m_writer; std::thread m_writer{};
fs::file m_fout; fs::file m_fout{};
fs::file m_fout2; fs::file m_fout2{};
u64 m_max_size; u64 m_max_size{};
std::unique_ptr<uchar[]> m_fptr; std::unique_ptr<uchar[]> m_fptr{};
z_stream m_zs{}; z_stream m_zs{};
shared_mutex m_m; shared_mutex m_m{};
alignas(128) atomic_t<u64> m_buf{0}; // MSB (40 bit): push begin, LSB (24 bis): push size alignas(128) atomic_t<u64> m_buf{0}; // MSB (40 bit): push begin, LSB (24 bis): push size
alignas(128) atomic_t<u64> m_out{0}; // Amount of bytes written to file alignas(128) atomic_t<u64> m_out{0}; // Amount of bytes written to file
uchar m_zout[65536]; uchar m_zout[65536]{};
// Write buffered logs immediately // Write buffered logs immediately
bool flush(u64 bufv); bool flush(u64 bufv);
@ -118,10 +118,10 @@ namespace logs
} }
// Channel registry // Channel registry
std::unordered_multimap<std::string, channel*> channels; std::unordered_multimap<std::string, channel*> channels{};
// Messages for delayed listener initialization // Messages for delayed listener initialization
std::vector<stored_message> messages; std::vector<stored_message> messages{};
}; };
static root_listener* get_logger() static root_listener* get_logger()

View file

@ -47,13 +47,13 @@ namespace utils
class shm class shm
{ {
#ifdef _WIN32 #ifdef _WIN32
void* m_handle; void* m_handle{};
#else #else
int m_file; int m_file{};
#endif #endif
u32 m_size; u32 m_size{};
u32 m_flags; u32 m_flags{};
atomic_t<void*> m_ptr; atomic_t<void*> m_ptr{nullptr};
public: public:
explicit shm(u32 size, u32 flags = 0); explicit shm(u32 size, u32 flags = 0);

View file

@ -14,6 +14,7 @@
#pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wattributes" #pragma GCC diagnostic ignored "-Wattributes"
#pragma GCC diagnostic ignored "-Wstrict-aliasing" #pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Weffc++"
#include "yaml-cpp/yaml.h" #include "yaml-cpp/yaml.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif