diff --git a/Utilities/StrUtil.h b/Utilities/StrUtil.h index 4fe6fc90cc..4614f6f623 100644 --- a/Utilities/StrUtil.h +++ b/Utilities/StrUtil.h @@ -159,7 +159,7 @@ namespace fmt std::string result; bool first = true; - for (auto& v : sources) + for (const auto& v : sources) { if (first) { diff --git a/rpcs3/Crypto/aes.cpp b/rpcs3/Crypto/aes.cpp index 61ae4ae85c..1cfc72aaab 100644 --- a/rpcs3/Crypto/aes.cpp +++ b/rpcs3/Crypto/aes.cpp @@ -897,7 +897,7 @@ unsigned char const_Zero[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -void leftshift_onebit(unsigned char *input, unsigned char *output) +void leftshift_onebit(const unsigned char *input, unsigned char *output) { int i; unsigned char overflow = 0; @@ -910,7 +910,7 @@ void leftshift_onebit(unsigned char *input, unsigned char *output) } } -void xor_128(unsigned char *a, unsigned char *b, unsigned char *out) +void xor_128(const unsigned char *a, const unsigned char *b, unsigned char *out) { int i; for (i = 0; i < 16; i++) @@ -945,7 +945,7 @@ void generate_subkey(aes_context *ctx, unsigned char *K1, unsigned char *K2) } } -void padding(unsigned char *lastb, unsigned char *pad, size_t length) +void padding(const unsigned char *lastb, unsigned char *pad, size_t length) { for (unsigned int i = 0; i < 16; i++) { diff --git a/rpcs3/Crypto/ec.cpp b/rpcs3/Crypto/ec.cpp index efef91228c..3789928492 100644 --- a/rpcs3/Crypto/ec.cpp +++ b/rpcs3/Crypto/ec.cpp @@ -5,7 +5,7 @@ #include "util/types.hpp" #include -static inline int bn_compare(u8* a, u8* b, u32 n) +static inline int bn_compare(const u8* a, const u8* b, u32 n) { for (u32 i = 0; i < n; i++) { @@ -18,7 +18,7 @@ static inline int bn_compare(u8* a, u8* b, u32 n) return 0; } -static u8 bn_add_1(u8* d, u8* a, u8* b, u32 n) +static u8 bn_add_1(u8* d, const u8* a, const u8* b, u32 n) { u8 c = 0; for (u32 i = n - 1; i != umax; i--) @@ -31,7 +31,7 @@ static u8 bn_add_1(u8* d, u8* a, u8* b, u32 n) return c; } -static u8 bn_sub_1(u8* d, u8* a, u8* b, u32 n) +static u8 bn_sub_1(u8* d, const u8* a, const u8* b, u32 n) { u8 c = 1; for (u32 i = n - 1; i != umax; i--) @@ -44,13 +44,13 @@ static u8 bn_sub_1(u8* d, u8* a, u8* b, u32 n) return 1 - c; } -static void bn_reduce(u8* d, u8* N, u32 n) +static void bn_reduce(u8* d, const u8* N, u32 n) { if (bn_compare(d, N, n) >= 0) bn_sub_1(d, d, N, n); } -static void bn_add(u8* d, u8* a, u8* b, u8* N, u32 n) +static void bn_add(u8* d, const u8* a, const u8* b, const u8* N, u32 n) { if (bn_add_1(d, a, b, n)) bn_sub_1(d, d, N, n); @@ -58,7 +58,7 @@ static void bn_add(u8* d, u8* a, u8* b, u8* N, u32 n) bn_reduce(d, N, n); } -static void bn_sub(u8* d, u8* a, u8* b, u8* N, u32 n) +static void bn_sub(u8* d, const u8* a, const u8* b, const u8* N, u32 n) { if (bn_sub_1(d, a, b, n)) bn_add_1(d, d, N, n); @@ -83,7 +83,7 @@ static constexpr u8 inv256[0x80] = { 0x11, 0x3b, 0x5d, 0xc7, 0x49, 0x33, 0x55, 0xff, }; -static void bn_mon_muladd_dig(u8* d, u8* a, u8 b, u8* N, u32 n) +static void bn_mon_muladd_dig(u8* d, const u8* a, u8 b, const u8* N, u32 n) { const u8 z = -(d[n - 1] + a[n - 1] * b) * inv256[N[n - 1] / 2]; @@ -106,7 +106,7 @@ static void bn_mon_muladd_dig(u8* d, u8* a, u8 b, u8* N, u32 n) bn_reduce(d, N, n); } -static void bn_mon_mul(u8* d, u8* a, u8* b, u8* N, u32 n) +static void bn_mon_mul(u8* d, const u8* a, const u8* b, const u8* N, u32 n) { u8 t[512]; memset(t, 0, n); @@ -117,13 +117,13 @@ static void bn_mon_mul(u8* d, u8* a, u8* b, u8* N, u32 n) memcpy(d, t, n); } -static void bn_to_mon(u8* d, u8* N, u32 n) +static void bn_to_mon(u8* d, const u8* N, u32 n) { for (u32 i = 0; i < 8 * n; i++) bn_add(d, d, d, N, n); } -static void bn_from_mon(u8* d, u8* N, u32 n) +static void bn_from_mon(u8* d, const u8* N, u32 n) { u8 t[512]; @@ -132,7 +132,7 @@ static void bn_from_mon(u8* d, u8* N, u32 n) bn_mon_mul(d, d, t, N, n); } -static void bn_mon_exp(u8* d, u8* a, u8* N, u32 n, u8* e, u32 en) +static void bn_mon_exp(u8* d, const u8* a, const u8* N, u32 n, const u8* e, u32 en) { u8 t[512]; @@ -153,7 +153,7 @@ static void bn_mon_exp(u8* d, u8* a, u8* N, u32 n, u8* e, u32 en) } } -static void bn_mon_inv(u8* d, u8* a, u8* N, u32 n) +static void bn_mon_inv(u8* d, const u8* a, const u8* N, u32 n) { u8 t[512], s[512]; @@ -179,7 +179,7 @@ static thread_local u8 ec_k[21]{}; static thread_local bool ec_curve_initialized{}; static thread_local bool ec_pub_initialized{}; -static inline bool elt_is_zero(u8* d) +static inline bool elt_is_zero(const u8* d) { for (u32 i = 0; i < 20; i++) if (d[i] != 0) @@ -188,27 +188,27 @@ static inline bool elt_is_zero(u8* d) return true; } -static void elt_add(u8* d, u8* a, u8* b) +static void elt_add(u8* d, const u8* a, const u8* b) { bn_add(d, a, b, ec_p, 20); } -static void elt_sub(u8* d, u8* a, u8* b) +static void elt_sub(u8* d, const u8* a, const u8* b) { bn_sub(d, a, b, ec_p, 20); } -static void elt_mul(u8* d, u8* a, u8* b) +static void elt_mul(u8* d, const u8* a, const u8* b) { bn_mon_mul(d, a, b, ec_p, 20); } -static void elt_square(u8* d, u8* a) +static void elt_square(u8* d, const u8* a) { elt_mul(d, a, a); } -static void elt_inv(u8* d, u8* a) +static void elt_inv(u8* d, const u8* a) { u8 s[20]; memcpy(s, a, 20); @@ -233,19 +233,19 @@ static inline void point_zero(point* p) memset(p->y, 0, 20); } -static inline bool point_is_zero(point* p) +static inline bool point_is_zero(const point* p) { return elt_is_zero(p->x) && elt_is_zero(p->y); } -static void point_double(point* r, point* p) +static void point_double(point* r, const point* p) { u8 s[20], t[20]; point pp = *p; - u8* px = pp.x; - u8* py = pp.y; + const u8* px = pp.x; + const u8* py = pp.y; u8* rx = r->x; u8* ry = r->y; @@ -272,17 +272,17 @@ static void point_double(point* r, point* p) elt_sub(ry, ry, py); // ry = -s*(rx-px) - py } -static void point_add(point* r, point* p, point* q) +static void point_add(point* r, const point* p, const point* q) { u8 s[20], t[20], u[20]; point pp = *p; point qq = *q; - u8* px = pp.x; - u8* py = pp.y; - u8* qx = qq.x; - u8* qy = qq.y; + const u8* px = pp.x; + const u8* py = pp.y; + const u8* qx = qq.x; + const u8* qy = qq.y; u8* rx = r->x; u8* ry = r->y; @@ -326,7 +326,7 @@ static void point_add(point* r, point* p, point* q) elt_sub(ry, ry, py); // ry = -s*(rx-px) - py } -static void point_mul(point* d, u8* a, point* b) // a is bignum +static void point_mul(point* d, const u8* a, const point* b) // a is bignum { point_zero(d); @@ -341,7 +341,7 @@ static void point_mul(point* d, u8* a, point* b) // a is bignum } } -static bool check_ecdsa(struct point* Q, u8* R, u8* S, u8* hash) +static bool check_ecdsa(const struct point* Q, u8* R, u8* S, const u8* hash) { u8 Sinv[21]; u8 e[21]; @@ -417,7 +417,7 @@ void ecdsa_set_priv(const u8* k) memcpy(ec_k, k, sizeof ec_k); } -bool ecdsa_verify(u8* hash, u8* R, u8* S) +bool ecdsa_verify(const u8* hash, u8* R, u8* S) { return check_ecdsa(&ec_Q, R, S, hash); } diff --git a/rpcs3/Crypto/ec.h b/rpcs3/Crypto/ec.h index 9efa5f17ff..f5ee60ba52 100644 --- a/rpcs3/Crypto/ec.h +++ b/rpcs3/Crypto/ec.h @@ -9,4 +9,4 @@ void ecdsa_set_curve(const u8* p, const u8* a, const u8* b, const u8* N, const u8* Gx, const u8* Gy); void ecdsa_set_pub(const u8* Q); void ecdsa_set_priv(const u8* k); -bool ecdsa_verify(u8* hash, u8* R, u8* S); +bool ecdsa_verify(const u8* hash, u8* R, u8* S); diff --git a/rpcs3/Crypto/key_vault.cpp b/rpcs3/Crypto/key_vault.cpp index b9222cd63e..2533b4d7fc 100644 --- a/rpcs3/Crypto/key_vault.cpp +++ b/rpcs3/Crypto/key_vault.cpp @@ -762,7 +762,7 @@ const u8* KeyVault::GetKlicenseeKey() const return klicensee_key; } -void rap_to_rif(unsigned char* rap, unsigned char* rif) +void rap_to_rif(const unsigned char* rap, unsigned char* rif) { int i; int round; diff --git a/rpcs3/Crypto/key_vault.h b/rpcs3/Crypto/key_vault.h index ac5ba084b9..4dff84992b 100644 --- a/rpcs3/Crypto/key_vault.h +++ b/rpcs3/Crypto/key_vault.h @@ -347,4 +347,4 @@ private: }; // RAP to RIF function. -void rap_to_rif(unsigned char* rap, unsigned char* rif); +void rap_to_rif(const unsigned char* rap, unsigned char* rif); diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index d7eacd5ca1..985b2fc74c 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -674,7 +674,7 @@ u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file) rap_file.read(rapkey); - rap_to_rif(reinterpret_cast(&rapkey), reinterpret_cast(&rifkey)); + rap_to_rif(reinterpret_cast(&rapkey), reinterpret_cast(&rifkey)); return rifkey; } diff --git a/rpcs3/Emu/Io/emulated_pad_config.h b/rpcs3/Emu/Io/emulated_pad_config.h index ad74e0dfc2..e2b46d3daa 100644 --- a/rpcs3/Emu/Io/emulated_pad_config.h +++ b/rpcs3/Emu/Io/emulated_pad_config.h @@ -40,7 +40,7 @@ public: { std::lock_guard lock(m_mutex); - if (cfg_pad_btn* item = get_button(id)) + if (const cfg_pad_btn* item = get_button(id)) { return item->get(); } @@ -52,7 +52,7 @@ public: { std::lock_guard lock(m_mutex); - if (cfg_pad_btn* item = get_button(id)) + if (const cfg_pad_btn* item = get_button(id)) { return item->get_default(); } diff --git a/rpcs3/Emu/Io/usb_device.h b/rpcs3/Emu/Io/usb_device.h index e0fad67966..3d60bd36b0 100644 --- a/rpcs3/Emu/Io/usb_device.h +++ b/rpcs3/Emu/Io/usb_device.h @@ -134,7 +134,7 @@ struct UsbDescriptorNode { memcpy(data, &_data, sizeof(T)); } - UsbDescriptorNode(u8 _bLength, u8 _bDescriptorType, u8* _data) + UsbDescriptorNode(u8 _bLength, u8 _bDescriptorType, const u8* _data) : bLength(_bLength), bDescriptorType(_bDescriptorType) { memcpy(data, _data, _bLength - 2); diff --git a/rpcs3/Emu/RSX/Common/surface_utils.h b/rpcs3/Emu/RSX/Common/surface_utils.h index 2fb55810e4..05e1993780 100644 --- a/rpcs3/Emu/RSX/Common/surface_utils.h +++ b/rpcs3/Emu/RSX/Common/surface_utils.h @@ -437,7 +437,7 @@ namespace rsx bool test() { - for (auto &e : memory_tag_samples) + for (const auto& e : memory_tag_samples) { if (e.second != *reinterpret_cast*>(vm::g_sudo_addr + e.first)) return false; @@ -471,10 +471,10 @@ namespace rsx return 0; // Sort here before doing transfers since surfaces may have been updated in the meantime - std::sort(old_contents.begin(), old_contents.end(), [](auto& a, auto &b) + std::sort(old_contents.begin(), old_contents.end(), [](const auto& a, const auto &b) { - auto _a = static_cast(a.source); - auto _b = static_cast(b.source); + const auto _a = static_cast(a.source); + const auto _b = static_cast(b.source); return (_a->last_use_tag < _b->last_use_tag); }); diff --git a/rpcs3/Emu/RSX/Program/ShaderParam.h b/rpcs3/Emu/RSX/Program/ShaderParam.h index 01e4931869..266ab51cbd 100644 --- a/rpcs3/Emu/RSX/Program/ShaderParam.h +++ b/rpcs3/Emu/RSX/Program/ShaderParam.h @@ -190,7 +190,7 @@ struct ParamArray bool HasParam(const ParamFlag flag, const std::string& type, const std::string& name) { - ParamType* t = SearchParam(flag, type); + const ParamType* t = SearchParam(flag, type); return t && t->HasItem(name); } @@ -300,7 +300,7 @@ public: { 3, 'w' } }; - for (auto& p : pos_to_swizzle) + for (const auto& p : pos_to_swizzle) { swizzle[p.second] = swizzles[0].length() > p.first ? swizzles[0][p.first] : 0; } @@ -309,7 +309,7 @@ public: { std::unordered_map new_swizzle; - for (auto& p : pos_to_swizzle) + for (const auto& p : pos_to_swizzle) { new_swizzle[p.second] = swizzle[swizzles[i].length() <= p.first ? '\0' : swizzles[i][p.first]]; } @@ -320,7 +320,7 @@ public: swizzles.clear(); std::string new_swizzle; - for (auto& p : pos_to_swizzle) + for (const auto& p : pos_to_swizzle) { if (swizzle[p.second] != '\0') new_swizzle += swizzle[p.second]; diff --git a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h index 63db151ab3..34cb08bae4 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h +++ b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h @@ -91,7 +91,7 @@ namespace vk get_graphics_pipeline(vp, fp, props, false, false, std::forward(args)...); } - void preload_programs(RSXVertexProgram& vp, RSXFragmentProgram& fp) + void preload_programs(const RSXVertexProgram& vp, const RSXFragmentProgram& fp) { search_vertex_program(vp); search_fragment_program(fp); diff --git a/rpcs3/Emu/RSX/VK/VKResourceManager.h b/rpcs3/Emu/RSX/VK/VKResourceManager.h index 11e6558018..30d838d065 100644 --- a/rpcs3/Emu/RSX/VK/VKResourceManager.h +++ b/rpcs3/Emu/RSX/VK/VKResourceManager.h @@ -161,19 +161,17 @@ namespace vk { while (!m_eid_map.empty()) { - auto& scope = m_eid_map.front(); + const auto& scope = m_eid_map.front(); if (scope.eid > eid) { break; } - else + + eid_scope_t tmp(0); { - eid_scope_t tmp(0); - { - std::lock_guard lock(m_eid_map_lock); - m_eid_map.front().swap(tmp); - m_eid_map.pop_front(); - } + std::lock_guard lock(m_eid_map_lock); + m_eid_map.front().swap(tmp); + m_eid_map.pop_front(); } } } diff --git a/rpcs3/Emu/RSX/VK/vkutils/device.cpp b/rpcs3/Emu/RSX/VK/vkutils/device.cpp index 5391e1308e..35c94e35cd 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/device.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/device.cpp @@ -1072,7 +1072,7 @@ namespace vk ensure(!host_coherent_types.empty()); // BAR heap, currently parked for future use, I have some plans for it (kd-11) - for (auto& type : bar_memory_types) + for (const auto& type : bar_memory_types) { result.device_bar.push(type.type_index, type.size); result.device_bar_total_bytes += type.size; @@ -1094,7 +1094,7 @@ namespace vk }); } - for (auto& type : device_local_types) + for (const auto& type : device_local_types) { result.device_local.push(type.type_index, type.size); result.device_local_total_bytes += type.size; @@ -1106,7 +1106,7 @@ namespace vk std::sort(host_coherent_types.begin(), host_coherent_types.end(), FN(x.size > y.size)); } - for (auto& type : host_coherent_types) + for (const auto& type : host_coherent_types) { result.host_visible_coherent.push(type.type_index, type.size); result.host_visible_total_bytes += type.size; diff --git a/rpcs3/Input/mm_joystick_handler.cpp b/rpcs3/Input/mm_joystick_handler.cpp index 3d48efccf9..112620bf37 100644 --- a/rpcs3/Input/mm_joystick_handler.cpp +++ b/rpcs3/Input/mm_joystick_handler.cpp @@ -115,7 +115,7 @@ void mm_joystick_handler::enumerate_devices() continue; } - auto& device = it->second; + const auto& device = it->second; if (!device) continue; diff --git a/rpcs3/rpcs3qt/config_adapter.cpp b/rpcs3/rpcs3qt/config_adapter.cpp index bc6effef3d..ddc0cc839c 100644 --- a/rpcs3/rpcs3qt/config_adapter.cpp +++ b/rpcs3/rpcs3qt/config_adapter.cpp @@ -6,11 +6,11 @@ LOG_CHANNEL(cfg_log, "CFG"); // Helper methods to interact with YAML and the config settings. namespace cfg_adapter { - static cfg::_base& get_cfg(cfg::_base& root, const std::string& name) + static cfg::_base& get_cfg(const cfg::_base& root, const std::string& name) { if (root.get_type() == cfg::type::node) { - for (const auto& node : static_cast(root).get_nodes()) + for (const auto& node : static_cast(root).get_nodes()) { if (node->get_name() == name) { diff --git a/rpcs3/rpcs3qt/render_creator.cpp b/rpcs3/rpcs3qt/render_creator.cpp index ef425366b3..57cd71ecbf 100644 --- a/rpcs3/rpcs3qt/render_creator.cpp +++ b/rpcs3/rpcs3qt/render_creator.cpp @@ -41,7 +41,7 @@ render_creator::render_creator(QObject *parent) : QObject(parent) if (device_enum_context.create("RPCS3", true)) { device_enum_context.bind(); - std::vector& gpus = device_enum_context.enumerate_devices(); + const std::vector& gpus = device_enum_context.enumerate_devices(); lock.lock(); diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 65d161c333..bcb5f36baa 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -272,7 +272,7 @@ namespace stx order[pos++] = {type.init_pos(), std::addressof(type)}; } - std::stable_sort(order.get(), order.get() + type_count, [](auto& a, auto& b) + std::stable_sort(order.get(), order.get() + type_count, [](const auto& a, const auto& b) { if (a.second->is_trivial_and_nonsavable && !b.second->is_trivial_and_nonsavable) {