mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
static analysis: more const
This commit is contained in:
parent
d3c5cc7b13
commit
279711a3ab
18 changed files with 64 additions and 66 deletions
|
@ -159,7 +159,7 @@ namespace fmt
|
|||
std::string result;
|
||||
bool first = true;
|
||||
|
||||
for (auto& v : sources)
|
||||
for (const auto& v : sources)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "util/types.hpp"
|
||||
#include <cstring>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -674,7 +674,7 @@ u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file)
|
|||
|
||||
rap_file.read<u128>(rapkey);
|
||||
|
||||
rap_to_rif(reinterpret_cast<uchar*>(&rapkey), reinterpret_cast<uchar*>(&rifkey));
|
||||
rap_to_rif(reinterpret_cast<const uchar*>(&rapkey), reinterpret_cast<uchar*>(&rifkey));
|
||||
|
||||
return rifkey;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
|
||||
if (cfg_pad_btn<T>* item = get_button(id))
|
||||
if (const cfg_pad_btn<T>* item = get_button(id))
|
||||
{
|
||||
return item->get();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
|
||||
if (cfg_pad_btn<T>* item = get_button(id))
|
||||
if (const cfg_pad_btn<T>* item = get_button(id))
|
||||
{
|
||||
return item->get_default();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<nse_t<u64, 1>*>(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<T*>(a.source);
|
||||
auto _b = static_cast<T*>(b.source);
|
||||
const auto _a = static_cast<const T*>(a.source);
|
||||
const auto _b = static_cast<const T*>(b.source);
|
||||
return (_a->last_use_tag < _b->last_use_tag);
|
||||
});
|
||||
|
||||
|
|
|
@ -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<char, char> 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];
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace vk
|
|||
get_graphics_pipeline(vp, fp, props, false, false, std::forward<Args>(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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -115,7 +115,7 @@ void mm_joystick_handler::enumerate_devices()
|
|||
continue;
|
||||
}
|
||||
|
||||
auto& device = it->second;
|
||||
const auto& device = it->second;
|
||||
|
||||
if (!device)
|
||||
continue;
|
||||
|
|
|
@ -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<cfg::node&>(root).get_nodes())
|
||||
for (const auto& node : static_cast<const cfg::node&>(root).get_nodes())
|
||||
{
|
||||
if (node->get_name() == name)
|
||||
{
|
||||
|
|
|
@ -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<vk::physical_device>& gpus = device_enum_context.enumerate_devices();
|
||||
const std::vector<vk::physical_device>& gpus = device_enum_context.enumerate_devices();
|
||||
|
||||
lock.lock();
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue