1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Fix various explicitness, laziness, hard codes

This commit is contained in:
sampletext32 2020-04-10 21:48:32 +03:00 committed by Ivan
parent 5524cd1e75
commit c69691f19b
6 changed files with 26 additions and 24 deletions

View File

@ -1603,15 +1603,14 @@ bool fs::remove_all(const std::string& path, bool remove_root)
continue;
}
if (entry.is_directory == false)
if (!entry.is_directory)
{
if (!remove_file(path_append(path, entry.name)))
{
return false;
}
}
if (entry.is_directory == true)
else
{
if (!remove_all(path_append(path, entry.name)))
{
@ -1651,12 +1650,11 @@ u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment)
continue;
}
if (entry.is_directory == false)
if (!entry.is_directory)
{
result += ::align(entry.size, rounding_alignment);
}
if (entry.is_directory == true)
else
{
const u64 size = get_dir_size(path_append(path, entry.name), rounding_alignment);

View File

@ -81,7 +81,7 @@ namespace fmt
template <typename T>
std::string merge(const T& source, const std::string& separator)
{
if (!source.size())
if (source.empty())
{
return {};
}

View File

@ -154,7 +154,7 @@ namespace utils
#else
while ((m_file = ::shm_open("/rpcs3-mem1", O_RDWR | O_CREAT | O_EXCL, S_IWUSR | S_IRUSR)) == -1)
{
if (m_file == -1 && errno == EMFILE)
if (errno == EMFILE)
{
fmt::throw_exception("Too many open files. Raise the limit and try again.");
}

View File

@ -359,14 +359,18 @@ void cpu_thread::operator()()
std::this_thread::sleep_for(1ms);
}
if (id_type() == 1 && false)
switch (id_type())
{
g_fxo->get<cpu_profiler>()->registered.push(id);
}
if (id_type() == 2 && g_cfg.core.spu_prof)
{
g_fxo->get<cpu_profiler>()->registered.push(id);
case 1:
//g_fxo->get<cpu_profiler>()->registered.push(id);
break;
case 2:
if (g_cfg.core.spu_prof)
{
g_fxo->get<cpu_profiler>()->registered.push(id);
}
break;
default: ;
}
// Register thread in g_cpu_array

View File

@ -543,7 +543,7 @@ bool gdb_thread::cmd_thread_info(gdb_cmd& cmd)
std::string result;
const auto on_select = [&](u32, cpu_thread& cpu)
{
if (result.length()) {
if (!result.empty()) {
result += ",";
}
result += u64_to_padded_hex(static_cast<u64>(cpu.id));
@ -572,7 +572,7 @@ bool gdb_thread::cmd_read_register(gdb_cmd& cmd)
auto ppu = static_cast<named_thread<ppu_thread>*>(th.get());
u32 rid = hex_to_u32(cmd.data);
std::string result = get_reg(ppu, rid);
if (!result.length()) {
if (result.empty()) {
GDB.warning("Wrong register id %d.", rid);
return send_cmd_ack("E01");
}
@ -622,7 +622,7 @@ bool gdb_thread::cmd_read_memory(gdb_cmd& cmd)
//result += "xx";
}
}
if (len && !result.length()) {
if (len && result.empty()) {
//nothing read
return send_cmd_ack("E01");
}

View File

@ -245,12 +245,12 @@ bool cheat_engine::resolve_script(u32& final_offset, const u32 offset, const std
while (index < red_script.size())
{
if (red_script[index] >= '0' && red_script[index] <= '9')
if (std::isdigit(static_cast<u8>(red_script[index])))
{
std::string num_string;
for (; index < red_script.size(); index++)
{
if (red_script[index] < '0' || red_script[index] > '9')
if (!std::isdigit(static_cast<u8>(red_script[index])))
break;
num_string += red_script[index];
@ -348,15 +348,15 @@ std::vector<u32> cheat_engine::search(const T value, const std::vector<u32>& to_
else
{
// Looks through mapped memory
for (u32 page_ind = (0x10000 / 4096); page_ind < (0xF0000000 / 4096); page_ind++)
for (u32 page_start = 0x10000; page_start < 0xF0000000; page_start += 4096)
{
if (vm::check_addr(page_ind * 4096))
if (vm::check_addr(page_start))
{
// Assumes the values are aligned
for (u32 index = 0; index < 4096; index += sizeof(T))
{
if (*vm::get_super_ptr<T>((page_ind * 4096) + index) == value_swapped)
results.push_back((page_ind * 4096) + index);
if (*vm::get_super_ptr<T>(page_start + index) == value_swapped)
results.push_back(page_start + index);
}
}
}