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);
}
custom_runtime(const custom_runtime&) = delete;
custom_runtime& operator=(const custom_runtime&) = delete;
asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override
{
usz codeSize = code->getCodeSize();
@ -384,6 +388,10 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager
MemoryManager1() = default;
MemoryManager1(const MemoryManager1&) = delete;
MemoryManager1& operator=(const MemoryManager1&) = delete;
~MemoryManager1() override
{
utils::memory_release(ptr, c_max_size * 2);

View file

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

View file

@ -1,21 +1,21 @@
/*
* Lightweight URL & URI parser (RFC 1738, RFC 3986)
* https://github.com/corporateshark/LUrlParser
*
*
* The MIT License (MIT)
*
*
* Copyright (C) 2015 Sergey Kosarevsky (sk@linderdaum.com)
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -47,14 +47,14 @@ namespace LUrlParser
{
public:
LUrlParserError m_ErrorCode;
std::string m_Scheme;
std::string m_Host;
std::string m_Port;
std::string m_Path;
std::string m_Query;
std::string m_Fragment;
std::string m_UserName;
std::string m_Password;
std::string m_Scheme{};
std::string m_Host{};
std::string m_Port{};
std::string m_Path{};
std::string m_Query{};
std::string m_Fragment{};
std::string m_UserName{};
std::string m_Password{};
clParseURL()
: m_ErrorCode( LUrlParserError_Uninitialized )

View file

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

View file

@ -1,6 +1,19 @@
#pragma once
#ifdef _MSC_VER
#pragma warning(push, 0)
#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>
struct rXmlNode
@ -13,7 +26,7 @@ struct rXmlNode
std::string GetAttribute( const std::string &name);
std::string GetNodeContent();
pugi::xml_node handle;
pugi::xml_node handle{};
};
struct rXmlDocument
@ -24,5 +37,5 @@ struct rXmlDocument
void Read(const std::string& data);
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
{
u64 version_start;
u64 version_end;
u16 revision;
u32 self_type;
u8 erk[0x20];
u8 riv[0x10];
u8 pub[0x28];
u8 priv[0x15];
u32 curve_type;
u64 version_start{};
u64 version_end{};
u16 revision{};
u32 self_type{};
u8 erk[0x20]{};
u8 riv[0x10]{};
u8 pub[0x28]{};
u8 priv[0x15]{};
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);
};
@ -182,15 +182,15 @@ constexpr u8 PUP_KEY[0x40] = {
class KeyVault
{
std::vector<SELF_KEY> sk_LV0_arr;
std::vector<SELF_KEY> sk_LV1_arr;
std::vector<SELF_KEY> sk_LV2_arr;
std::vector<SELF_KEY> sk_APP_arr;
std::vector<SELF_KEY> sk_ISO_arr;
std::vector<SELF_KEY> sk_LDR_arr;
std::vector<SELF_KEY> sk_UNK7_arr;
std::vector<SELF_KEY> sk_NPDRM_arr;
std::unique_ptr<u8[]> klicensee_key;
std::vector<SELF_KEY> sk_LV0_arr{};
std::vector<SELF_KEY> sk_LV1_arr{};
std::vector<SELF_KEY> sk_LV2_arr{};
std::vector<SELF_KEY> sk_APP_arr{};
std::vector<SELF_KEY> sk_ISO_arr{};
std::vector<SELF_KEY> sk_LDR_arr{};
std::vector<SELF_KEY> sk_UNK7_arr{};
std::vector<SELF_KEY> sk_NPDRM_arr{};
std::unique_ptr<u8[]> klicensee_key{};
public:
KeyVault();

View file

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

View file

@ -323,16 +323,16 @@ private:
bool m_is_valid = false;
std::string m_path;
std::string m_install_dir;
std::vector<fs::file> m_filelist;
std::string m_path{};
std::string m_install_dir{};
std::vector<fs::file> m_filelist{};
usz m_cur_file = 0;
u64 m_cur_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{};
PKGHeader m_header{};
PKGMetaData m_metadata{};
psf::registry m_psf;
psf::registry m_psf{};
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@
class XAudio2Backend final : public AudioBackend
{
private:
Microsoft::WRL::ComPtr<IXAudio2> m_xaudio2_instance;
Microsoft::WRL::ComPtr<IXAudio2> m_xaudio2_instance{};
IXAudio2MasteringVoice* m_master_voice{};
IXAudio2SourceVoice* m_source_voice{};
@ -21,6 +21,9 @@ public:
XAudio2Backend();
virtual ~XAudio2Backend() override;
XAudio2Backend(const XAudio2Backend&) = delete;
XAudio2Backend& operator=(const XAudio2Backend&) = delete;
virtual const char* GetName() const override { return "XAudio2"; };
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 trampoline = 0;
std::map<u32, u32> blocks; // Basic blocks: addr -> size
std::set<u32> calls; // Set of called functions
std::set<u32> callers;
std::string name; // Function name
std::map<u32, u32> blocks{}; // Basic blocks: addr -> size
std::set<u32> calls{}; // Set of called functions
std::set<u32> callers{};
std::string name{}; // Function name
};
// PPU Relocation Information

View file

@ -399,7 +399,7 @@ extern void ppu_trap(ppu_thread& ppu, u64 addr);
class ppu_scale_table_t
{
std::array<v128, 32 + 31> m_data;
std::array<v128, 32 + 31> m_data{};
public:
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;
static lv2_fs_mount_point* get_mp(std::string_view filename);

View file

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

View file

@ -4,7 +4,7 @@
#include "util/sysinfo.hpp"
cfg_root g_cfg;
cfg_root g_cfg{};
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" };
std::string name;
std::string name{};
};
extern cfg_root g_cfg;

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ namespace utils
{
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:
cpu_stats();

View file

@ -70,19 +70,19 @@ namespace logs
class file_writer
{
std::thread m_writer;
fs::file m_fout;
fs::file m_fout2;
u64 m_max_size;
std::thread m_writer{};
fs::file m_fout{};
fs::file m_fout2{};
u64 m_max_size{};
std::unique_ptr<uchar[]> m_fptr;
std::unique_ptr<uchar[]> m_fptr{};
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_out{0}; // Amount of bytes written to file
uchar m_zout[65536];
uchar m_zout[65536]{};
// Write buffered logs immediately
bool flush(u64 bufv);
@ -118,10 +118,10 @@ namespace logs
}
// Channel registry
std::unordered_multimap<std::string, channel*> channels;
std::unordered_multimap<std::string, channel*> channels{};
// Messages for delayed listener initialization
std::vector<stored_message> messages;
std::vector<stored_message> messages{};
};
static root_listener* get_logger()

View file

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

View file

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