Apply some Clang-Tidy fixes

This commit is contained in:
gamerforEA 2020-02-27 00:13:54 +04:00 committed by Ivan
parent c0fbf3091e
commit 93552a5958
34 changed files with 59 additions and 59 deletions

View File

@ -433,7 +433,7 @@ public:
void reset()
{
if (!m_segs.size())
if (m_segs.empty())
{
if (m_curr.addr != nullptr)
{

View File

@ -186,7 +186,7 @@ std::string utils::get_firmware_version()
std::string utils::get_OS_version()
{
std::string output = "";
std::string output;
#ifdef _WIN32
// GetVersionEx is deprecated, RtlGetVersion is kernel-mode only and AnalyticsInfo is UWP only.
// So we're forced to read PEB instead to get Windows version info. It's ugly but works.

View File

@ -861,7 +861,7 @@ fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name,
}
// Read the RAP file, if provided.
if (rap_file_name.size())
if (!rap_file_name.empty())
{
fs::file rap(rap_file_name);

View File

@ -46,7 +46,7 @@ avconf_manager::avconf_manager()
u32 curindex = 0;
auto mic_list = fmt::split(g_cfg.audio.microphone_devices, {"@@@"});
if (mic_list.size())
if (!mic_list.empty())
{
switch (g_cfg.audio.microphone_type)
{

View File

@ -627,7 +627,7 @@ public:
lv2_obj::sleep(*this);
}
if (es.raw_data.size())
if (!es.raw_data.empty())
{
cellDmux.error("dmuxFlushEs: 0x%x bytes lost (es_id=%d)", ::size32(es.raw_data), es.id);
}

View File

@ -52,7 +52,7 @@ s32 cellHttpUtilParseUri(vm::ptr<CellHttpUri> uri, vm::cptr<char> str, vm::ptr<v
uri->username.set(pool.addr() + usernameOffset);
uri->password.set(pool.addr() + passwordOffset);
if (URL.m_Port != "")
if (!URL.m_Port.empty())
{
int port = stoi(URL.m_Port);
uri->port = port;

View File

@ -140,7 +140,7 @@ error_code cellImeJpOpen(sys_memory_container_t container_id, vm::ptr<CellImeJpH
{
cellImeJp.warning("cellImeJpOpen dictionary path = %s", addDicPath->path);
manager->dictionary_paths.push_back(std::string(addDicPath->path));
manager->dictionary_paths.emplace_back(addDicPath->path);
}
*hImeJpHandle = vm::cast(ime_jp_address);
@ -170,7 +170,7 @@ error_code cellImeJpOpen2(sys_memory_container_t container_id, vm::ptr<CellImeJp
{
cellImeJp.warning("cellImeJpOpen2 dictionary path = %s", addDicPath->path);
manager->dictionary_paths.push_back(std::string(addDicPath->path));
manager->dictionary_paths.emplace_back(addDicPath->path);
}
*hImeJpHandle = vm::cast(ime_jp_address);
@ -205,7 +205,7 @@ error_code cellImeJpOpen3(sys_memory_container_t container_id, vm::ptr<CellImeJp
{
cellImeJp.warning("cellImeJpOpen3 dictionary %d path = %s", i, addDicPath[i]->path);
manager->dictionary_paths.push_back(std::string(addDicPath[i]->path));
manager->dictionary_paths.emplace_back(addDicPath[i]->path);
}
}
}

View File

@ -86,7 +86,7 @@ void mic_context::load_config_and_init()
{
auto device_list = fmt::split(g_cfg.audio.microphone_devices, {"@@@"});
if (device_list.size() && mic_list.empty())
if (!device_list.empty() && mic_list.empty())
{
switch (g_cfg.audio.microphone_type)
{

View File

@ -1306,7 +1306,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
// Create save directory if necessary
if (psf.size() && save_entry.isNew && !fs::create_dir(dir_path))
if (!psf.empty() && save_entry.isNew && !fs::create_dir(dir_path))
{
cellSaveData.warning("savedata_op(): failed to create %s (%s)", dir_path, fs::g_tls_error);
return CELL_SAVEDATA_ERROR_ACCESS_ERROR;

View File

@ -402,7 +402,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
auto found = content_map->find(hash);
if (found == content_map->end()) // content isn't yet being tracked
{
auto ext_offset = item.name.find_last_of("."); // used later if no "Title" found
auto ext_offset = item.name.find_last_of('.'); // used later if no "Title" found
std::shared_ptr<search_content_t> curr_find = std::make_shared<search_content_t>();
if( item_path.length() > CELL_SEARCH_PATH_LEN_MAX )
@ -455,7 +455,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
info.orientation = 0; // CellSearchOrientation
info.codec = 0; // CellSearchCodec
info.status = 0; // CellSearchContentStatus
strcpy_trunc(info.title, item.name.substr(0, ext_offset).c_str());
strcpy_trunc(info.title, item.name.substr(0, ext_offset));
strcpy_trunc(info.albumTitle, "ALBUM TITLE");
}
else if (type == CELL_SEARCH_CONTENTSEARCHTYPE_VIDEO_ALL)
@ -474,7 +474,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
info.videoCodec = 0; // CellSearchCodec
info.audioCodec = 0; // CellSearchCodec
info.status = 0; // CellSearchContentStatus
strcpy_trunc(info.title, item.name.substr(0, ext_offset).c_str()); // it'll do for the moment...
strcpy_trunc(info.title, item.name.substr(0, ext_offset)); // it'll do for the moment...
strcpy_trunc(info.albumTitle, "ALBUM TITLE");
}

View File

@ -39,7 +39,7 @@ struct syscache_info
syscache_info() noexcept
{
// Check if dev_hdd1 is mounted by parent process
if (Emu.hdd1.size())
if (!Emu.hdd1.empty())
{
const auto lock = init.init();

View File

@ -642,7 +642,7 @@ extern std::string ppu_get_syscall_name(u64 code)
// Get function name by FNID
extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
{
if (module == "") switch (fnid)
if (module.empty()) switch (fnid)
{
case 0x0d10fd3f: return "module_prologue";
case 0x330f7005: return "module_epilogue";
@ -2438,7 +2438,7 @@ extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
// Get variable name by VNID
extern std::string ppu_get_variable_name(const std::string& module, u32 vnid)
{
if (module == "") switch (vnid)
if (module.empty()) switch (vnid)
{
// these arent the actual hash, but its close enough
case 0xd7f43016: return "module_info";

View File

@ -1528,7 +1528,7 @@ void ppu_load_exec(const ppu_exec_object& elf)
auto ppu = idm::make_ptr<named_thread<ppu_thread>>("PPU[0x1000000] Thread (main_thread)", p, "main_thread", primary_prio, 1);
// Write initial data (exitspawn)
if (Emu.data.size())
if (!Emu.data.empty())
{
std::memcpy(vm::base(ppu->stack_addr + ppu->stack_size - ::size32(Emu.data)), Emu.data.data(), Emu.data.size());
ppu->gpr[1] -= Emu.data.size();

View File

@ -440,7 +440,7 @@ void spu_cache::initialize()
compiler->init();
}
if (compilers.size() && !func_list.empty())
if (!compilers.empty() && !func_list.empty())
{
// Initialize progress dialog (wait for previous progress done)
while (g_progr_ptotal)
@ -518,7 +518,7 @@ void spu_cache::initialize()
return;
}
if (compilers.size() && !func_list.empty())
if (!compilers.empty() && !func_list.empty())
{
spu_log.success("SPU Runtime: Built %u functions.", func_list.size());
}
@ -4491,7 +4491,7 @@ public:
bool need_check = false;
m_block->bb = &bb;
if (bb.preds.size())
if (!bb.preds.empty())
{
// Initialize registers and build PHI nodes if necessary
for (u32 i = 0; i < s_reg_max; i++)

View File

@ -53,7 +53,7 @@ void fmt_class_string<sys_config_service_listener_type>::format(std::string& out
// Utilities
void dump_buffer(std::string& out, const std::vector<u8>& buffer)
{
if (buffer.size() > 0)
if (!buffer.empty())
{
out.reserve(out.size() + buffer.size() * 2 + 1);
fmt::append(out, "0x");
@ -130,7 +130,7 @@ bool lv2_config_service_listener::check_service(const lv2_config_service& servic
// realhw only seems to send the pad connected events to the listeners that provided 0x01 as the first byte of their data buffer
// TODO: Figure out how this filter works more properly
if (service_id == SYS_CONFIG_SERVICE_PADMANAGER && (data.size() == 0 || data[0] != 0x01))
if (service_id == SYS_CONFIG_SERVICE_PADMANAGER && (data.empty() || data[0] != 0x01))
{
return false;
}

View File

@ -130,7 +130,7 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
return {};
}
if (flag.type == SYS_SYNC_WAITER_SINGLE && flag.sq.size())
if (flag.type == SYS_SYNC_WAITER_SINGLE && !flag.sq.empty())
{
return CELL_EPERM;
}

View File

@ -336,7 +336,7 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar
if (Emu.GetCat() == "DG" || Emu.GetCat() == "GD")
disc = vfs::get("/dev_bdvd/");
if (disc.empty() && Emu.GetTitleID().size())
if (disc.empty() && !Emu.GetTitleID().empty())
disc = vfs::get(Emu.GetDir());
vm::temporary_unlock(ppu);

View File

@ -261,7 +261,7 @@ void usb_handler_thread::operator()()
}
// If there is no handled devices usb thread is not actively needed
if (!handled_devices.size())
if (handled_devices.empty())
std::this_thread::sleep_for(500ms);
else
std::this_thread::sleep_for(200us);
@ -389,7 +389,7 @@ void usb_handler_thread::check_devices_vs_ldds()
bool usb_handler_thread::get_event(vm::ptr<u64>& arg1, vm::ptr<u64>& arg2, vm::ptr<u64>& arg3)
{
if (usbd_events.size())
if (!usbd_events.empty())
{
const auto& usb_event = usbd_events.front();
*arg1 = std::get<0>(usb_event);

View File

@ -239,7 +239,7 @@ char gdb_thread::read_char()
u8 gdb_thread::read_hexbyte()
{
std::string s = "";
std::string s;
s += read_char();
s += read_char();
return hex_to_u8(s);
@ -548,7 +548,7 @@ bool gdb_thread::cmd_supported(gdb_cmd& cmd)
bool gdb_thread::cmd_thread_info(gdb_cmd& cmd)
{
std::string result = "";
std::string result;
const auto on_select = [&](u32, cpu_thread& cpu)
{
if (result.length()) {

View File

@ -19,7 +19,7 @@ public:
std::vector<std::string> ListDevices() override
{
std::vector<std::string> nulllist;
nulllist.push_back("Default Null Device");
nulllist.emplace_back("Default Null Device");
return nulllist;
}

View File

@ -150,7 +150,7 @@ void usb_device_skylander::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoin
// Interrupt transfers are slow(6ms, TODO accurate measurement)
transfer->expected_time = get_timestamp() + 6000;
if (q_queries.size())
if (!q_queries.empty())
{
memcpy(buf, q_queries.front().data(), 0x20);
q_queries.pop();

View File

@ -205,5 +205,5 @@ void usb_device_emulated::isochronous_transfer(UsbTransfer* transfer)
void usb_device_emulated::add_string(char* str)
{
strings.push_back(str);
strings.emplace_back(str);
}

View File

@ -93,7 +93,7 @@ namespace rsx
result.font_names.push_back(font_name);
#ifdef _WIN32
result.lookup_font_dirs.push_back("C:/Windows/Fonts/");
result.lookup_font_dirs.emplace_back("C:/Windows/Fonts/");
#else
char* home = getenv("HOME");
if (home == nullptr)
@ -113,13 +113,13 @@ namespace rsx
{
case language_class::default_:
{
result.font_names.push_back("Arial.ttf");
result.font_names.emplace_back("Arial.ttf");
#ifndef _WIN32
result.font_names.emplace_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"); // ubuntu
result.font_names.emplace_back("/usr/share/fonts/TTF/DejaVuSans.ttf"); // arch
#endif
// Attempt to load a font from dev_flash as a last resort
result.font_names.push_back("SCE-PS3-VR-R-LATIN.TTF");
result.font_names.emplace_back("SCE-PS3-VR-R-LATIN.TTF");
break;
}
case language_class::cjk_base:
@ -128,10 +128,10 @@ namespace rsx
result.font_names.clear();
// Attempt to load a font from dev_flash before any other source
result.font_names.push_back("SCE-PS3-SR-R-JPN.TTF");
result.font_names.emplace_back("SCE-PS3-SR-R-JPN.TTF");
// Known system font as last fallback
result.font_names.push_back("Yu Gothic.ttf");
result.font_names.emplace_back("Yu Gothic.ttf");
break;
}
case language_class::hangul:
@ -140,10 +140,10 @@ namespace rsx
result.font_names.clear();
// Attempt to load a font from dev_flash before any other source
result.font_names.push_back("SCE-PS3-YG-R-KOR.TTF");
result.font_names.emplace_back("SCE-PS3-YG-R-KOR.TTF");
// Known system font as last fallback
result.font_names.push_back("Malgun Gothic.ttf");
result.font_names.emplace_back("Malgun Gothic.ttf");
break;
}
}
@ -172,7 +172,7 @@ namespace rsx
break;
}
std::string extension = "";
std::string extension;
if (const auto extension_start = font_file.find_last_of('.');
extension_start != std::string::npos)
{

View File

@ -76,10 +76,10 @@ namespace rsx
_cell.enabled = !(flags & CELL_OSKDIALOG_NO_RETURN);
break;
case button_flags::_shift:
_cell.enabled |= _cell.outputs.size() > 0;
_cell.enabled |= !_cell.outputs.empty();
break;
case button_flags::_mode:
_cell.enabled |= num_layers.size() > 0;
_cell.enabled |= !num_layers.empty();
break;
}

View File

@ -654,7 +654,7 @@ namespace vk
continue;
}
packets.push_back({base, lods });
packets.emplace_back(base, lods);
next_layer = layer;
next_level = 1;
base = i;
@ -664,7 +664,7 @@ namespace vk
if (packets.empty() ||
(packets.back().first + packets.back().second) < sections.size())
{
packets.push_back({base, lods});
packets.emplace_back(base, lods);
}
for (const auto &packet : packets)

View File

@ -772,7 +772,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
// Special case (directory scan)
m_sfo_dir = GetSfoDirFromGamePath(m_path, GetUsr(), m_title_id);
}
else if (disc.size())
else if (!disc.empty())
{
// Check previously used category before it's overwritten
if (m_cat == "DG")

View File

@ -487,7 +487,7 @@ bool ds4_pad_handler::GetCalibrationData(const std::shared_ptr<DS4Device>& ds4De
void ds4_pad_handler::CheckAddDevice(hid_device* hidDevice, hid_device_info* hidDevInfo)
{
std::string serial = "";
std::string serial;
std::shared_ptr<DS4Device> ds4Dev = std::make_shared<DS4Device>();
ds4Dev->hidDevice = hidDevice;
// There isnt a nice 'portable' way with hidapi to detect bt vs wired as the pid/vid's are the same

View File

@ -445,7 +445,7 @@ void keyboard_pad_handler::mouseWheelEvent(QWheelEvent* event)
std::vector<std::string> keyboard_pad_handler::ListDevices()
{
std::vector<std::string> list_devices;
list_devices.push_back("Keyboard");
list_devices.emplace_back("Keyboard");
return list_devices;
}

View File

@ -72,7 +72,7 @@ fs::file tar_object::get_file(std::string path)
m_map[header.name] = largest_offset;
int size = octalToDecimal(atoi(header.size));
if (path.compare(header.name) == 0) { //path is equal, read file and advance offset to start of next block
if (path == header.name) { //path is equal, read file and advance offset to start of next block
std::vector<u8> buf(size);
m_file.read(buf, size);
int offset = ((m_file.pos() - initial_offset + 512 - 1) & ~(512 - 1)) + initial_offset;

View File

@ -330,7 +330,7 @@ std::vector<u32> cheat_engine::search(const T value, const std::vector<u32>& to_
cpu_thread::suspend_all cpu_lock(nullptr);
if (to_filter.size())
if (!to_filter.empty())
{
for (const auto& off : to_filter)
{
@ -460,11 +460,11 @@ bool cheat_engine::is_addr_safe(const u32 offset)
{
if ((seg.flags & 3))
{
segs.push_back({seg.addr, seg.size});
segs.emplace_back(seg.addr, seg.size);
}
}
if (!segs.size())
if (segs.empty())
{
log_cheat.fatal("Couldn't find a +rw-x section");
return false;
@ -496,7 +496,7 @@ u32 cheat_engine::reverse_lookup(const u32 addr, const u32 max_offset, const u32
}
// If depth has not been reached dig deeper
if (ptrs.size() && cur_depth < max_depth)
if (!ptrs.empty() && cur_depth < max_depth)
{
for (const auto& ptr : ptrs)
{
@ -586,7 +586,7 @@ cheat_manager_dialog::cheat_manager_dialog(QWidget* parent)
bool success;
u32 final_offset;
if (cheat->red_script.size())
if (!cheat->red_script.empty())
{
final_offset = 0;
if (!cheat_engine::resolve_script(final_offset, cheat->offset, cheat->red_script))
@ -758,7 +758,7 @@ cheat_manager_dialog::cheat_manager_dialog(QWidget* parent)
std::pair<bool, bool> results;
u32 final_offset;
if (cheat->red_script.size())
if (!cheat->red_script.empty())
{
final_offset = 0;
if (!g_cheat.resolve_script(final_offset, cheat->offset, cheat->red_script))
@ -964,7 +964,7 @@ void cheat_manager_dialog::do_the_search()
{
lst_search->insertItem(row, tr("0x%1").arg(offsets_found[row], 1, 16).toUpper());
}
btn_filter_results->setEnabled(offsets_found.size());
btn_filter_results->setEnabled(!offsets_found.empty());
}
void cheat_manager_dialog::update_cheat_list()

View File

@ -589,7 +589,7 @@ void emu_settings::SetSetting(SettingsType type, const std::string& val)
void emu_settings::OpenCorrectionDialog(QWidget* parent)
{
if (m_broken_types.size() && QMessageBox::question(parent, tr("Fix invalid settings?"),
if (!m_broken_types.empty() && QMessageBox::question(parent, tr("Fix invalid settings?"),
tr(
"Your config file contained one or more unrecognized values for settings.\n"
"Their default value will be used until they are corrected.\n"

View File

@ -2191,7 +2191,7 @@ bool game_list_frame::SearchMatchesApp(const QString& name, const QString& seria
std::string game_list_frame::CurrentSelectionIconPath()
{
std::string selection = "";
std::string selection;
if (m_gameList->selectedItems().count())
{

View File

@ -448,7 +448,7 @@ void log_frame::UpdateUI()
break;
}
if (buf.size() && m_TTYAct->isChecked())
if (!buf.empty() && m_TTYAct->isChecked())
{
std::stringstream buf_stream;
buf_stream.str(buf);

View File

@ -749,7 +749,7 @@ void main_window::DecryptSPRXLibraries()
if (elf_file)
{
const std::string bin_ext = module.toLower().endsWith(".sprx") ? ".prx" : ".elf";
const std::string new_path = old_path.substr(0, old_path.find_last_of(".")) + bin_ext;
const std::string new_path = old_path.substr(0, old_path.find_last_of('.')) + bin_ext;
if (fs::file new_file{new_path, fs::rewrite})
{