summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
author Oliver Stöneberg <firewave@users.noreply.github.com>2020-01-23 04:03:35 +0100
committer R. Belmont <rb6502@users.noreply.github.com>2020-01-22 22:03:35 -0500
commit7c3aea8928f90955b7b67e40c705c16d8543384f (patch)
tree4818711117f20ef52fbbcec6543aa970c3c4d519 /src/frontend
parentd4bed5fce44ecf903e5170a8d4624a9edf7c14f3 (diff)
fixed some clang-tidy warnings (nw) (#6197)
* fixed some bugprone-throw-keyword-missing clang-tidy warnings (nw) * fixed some modernize-use-nullptr clang-tidy warnings (nw) * fixed some readability-delete-null-pointer clang-tidy warnings (nw) * fixed some performance-faster-string-find clang-tidy warnings (nw) * fixed some performance-for-range-copy clang-tidy warnings (nw) * fixed some readability-redundant-string-cstr clang-tidy warnings (nw)
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/audit.cpp10
-rw-r--r--src/frontend/mame/language.cpp2
-rw-r--r--src/frontend/mame/luaengine.cpp8
-rw-r--r--src/frontend/mame/ui/custui.cpp6
-rw-r--r--src/frontend/mame/ui/dirmenu.cpp18
-rw-r--r--src/frontend/mame/ui/filecreate.cpp2
-rw-r--r--src/frontend/mame/ui/imgcntrl.cpp4
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp14
-rw-r--r--src/frontend/mame/ui/selgame.cpp10
-rw-r--r--src/frontend/mame/ui/selmenu.cpp10
-rw-r--r--src/frontend/mame/ui/selsoft.cpp4
-rw-r--r--src/frontend/mame/ui/sliders.cpp4
-rw-r--r--src/frontend/mame/ui/tapectrl.cpp2
13 files changed, 47 insertions, 47 deletions
diff --git a/src/frontend/mame/audit.cpp b/src/frontend/mame/audit.cpp
index a33dd4bb52a..dbba78e20ec 100644
--- a/src/frontend/mame/audit.cpp
+++ b/src/frontend/mame/audit.cpp
@@ -220,14 +220,14 @@ media_auditor::summary media_auditor::audit_samples()
// look for the files
emu_file file(m_enumerator.options().sample_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
- path_iterator path(searchpath.c_str());
+ path_iterator path(searchpath);
std::string curpath;
while (path.next(curpath, samplename))
{
// attempt to access the file (.flac) or (.wav)
- osd_file::error filerr = file.open(curpath.c_str(), ".flac");
+ osd_file::error filerr = file.open(curpath, ".flac");
if (filerr != osd_file::error::NONE)
- filerr = file.open(curpath.c_str(), ".wav");
+ filerr = file.open(curpath, ".wav");
if (filerr == osd_file::error::NONE)
{
@@ -397,9 +397,9 @@ media_auditor::audit_record &media_auditor::audit_one_rom(const rom_entry *rom)
// open the file if we can
osd_file::error filerr;
if (has_crc)
- filerr = file.open(curpath.c_str(), crc);
+ filerr = file.open(curpath, crc);
else
- filerr = file.open(curpath.c_str());
+ filerr = file.open(curpath);
// if it worked, get the actual length and hashes, then stop
if (filerr == osd_file::error::NONE)
diff --git a/src/frontend/mame/language.cpp b/src/frontend/mame/language.cpp
index a5f2e9ce3a9..2740aed973f 100644
--- a/src/frontend/mame/language.cpp
+++ b/src/frontend/mame/language.cpp
@@ -68,7 +68,7 @@ void load_translation(emu_options &m_options)
strreplace(name, "(", "");
strreplace(name, ")", "");
emu_file file(m_options.language_path(), OPEN_FLAG_READ);
- if (file.open(name.c_str(), PATH_SEPARATOR "strings.mo") != osd_file::error::NONE)
+ if (file.open(name, PATH_SEPARATOR "strings.mo") != osd_file::error::NONE)
{
osd_printf_error("Error opening translation file %s\n", name);
return;
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index cc9c597b037..411004676a9 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -1227,13 +1227,13 @@ void lua_engine::initialize()
if(e.type() != OPTION_FLOAT)
luaL_error(m_lua_state, "Cannot set option to wrong type");
else
- e.set_value(string_format("%f", val).c_str(), OPTION_PRIORITY_CMDLINE);
+ e.set_value(string_format("%f", val), OPTION_PRIORITY_CMDLINE);
},
[this](core_options::entry &e, int val) {
if(e.type() != OPTION_INTEGER)
luaL_error(m_lua_state, "Cannot set option to wrong type");
else
- e.set_value(string_format("%d", val).c_str(), OPTION_PRIORITY_CMDLINE);
+ e.set_value(string_format("%d", val), OPTION_PRIORITY_CMDLINE);
},
[this](core_options::entry &e, const char *val) {
if(e.type() != OPTION_STRING)
@@ -1647,9 +1647,9 @@ void lua_engine::initialize()
if(!item)
break;
name = &(strchr(item, '/')[1]);
- if(name.substr(0, name.find("/")) == tag)
+ if(name.substr(0, name.find('/')) == tag)
{
- name = name.substr(name.find("/") + 1, std::string::npos);
+ name = name.substr(name.find('/') + 1, std::string::npos);
table[name] = i;
}
}
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp
index 48fd67a2a67..dfd206706b8 100644
--- a/src/frontend/mame/ui/custui.cpp
+++ b/src/frontend/mame/ui/custui.cpp
@@ -76,7 +76,7 @@ menu_custom_ui::~menu_custom_ui()
ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE);
if (!m_lang.empty())
{
- machine().options().set_value(OPTION_LANGUAGE, m_lang[m_currlang].c_str(), OPTION_PRIORITY_CMDLINE);
+ machine().options().set_value(OPTION_LANGUAGE, m_lang[m_currlang], OPTION_PRIORITY_CMDLINE);
load_translation(machine().options());
}
ui_globals::reset = true;
@@ -172,7 +172,7 @@ void menu_custom_ui::populate(float &customtop, float &custombottom)
if (!m_lang.empty())
{
arrow_flags = get_arrow_flags<std::uint16_t>(0, m_lang.size() - 1, m_currlang);
- item_append(_("Language"), m_lang[m_currlang].c_str(), arrow_flags, (void *)(uintptr_t)LANGUAGE_MENU);
+ item_append(_("Language"), m_lang[m_currlang], arrow_flags, (void *)(uintptr_t)LANGUAGE_MENU);
}
arrow_flags = get_arrow_flags<uint16_t>(0, HIDE_BOTH, ui_globals::panels_status);
@@ -445,7 +445,7 @@ menu_colors_ui::~menu_colors_ui()
for (int index = 1; index < MUI_RESTORE; index++)
{
dec_color = string_format("%x", (uint32_t)m_color_table[index].color);
- ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE);
+ ui().options().set_value(m_color_table[index].option, dec_color, OPTION_PRIORITY_CMDLINE);
}
// refresh our cached colors
diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp
index 1d8166718f0..50afe928561 100644
--- a/src/frontend/mame/ui/dirmenu.cpp
+++ b/src/frontend/mame/ui/dirmenu.cpp
@@ -170,7 +170,7 @@ void menu_display_actual::populate(float &customtop, float &custombottom)
else
m_searchpath.assign(machine().options().value(s_folders[m_ref].option));
- path_iterator path(m_searchpath.c_str());
+ path_iterator path(m_searchpath);
std::string curpath;
m_folders.clear();
while (path.next(curpath, nullptr))
@@ -226,7 +226,7 @@ menu_add_change_folder::menu_add_change_folder(mame_ui_manager &mui, render_cont
else
searchpath = mui.machine().options().value(s_folders[m_ref].option);
- path_iterator path(searchpath.c_str());
+ path_iterator path(searchpath);
std::string curpath;
while (path.next(curpath, nullptr))
m_folders.push_back(curpath);
@@ -289,10 +289,10 @@ void menu_add_change_folder::handle()
if (m_change)
{
if (ui().options().exists(s_folders[m_ref].option))
- ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE);
+ ui().options().set_value(s_folders[m_ref].option, m_current_path, OPTION_PRIORITY_CMDLINE);
else if (strcmp(machine().options().value(s_folders[m_ref].option), m_current_path.c_str()) != 0)
{
- machine().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE);
+ machine().options().set_value(s_folders[m_ref].option, m_current_path, OPTION_PRIORITY_CMDLINE);
}
}
else
@@ -307,10 +307,10 @@ void menu_add_change_folder::handle()
}
if (ui().options().exists(s_folders[m_ref].option))
- ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE);
+ ui().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
else if (strcmp(machine().options().value(s_folders[m_ref].option), tmppath.c_str()) != 0)
{
- machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE);
+ machine().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
}
}
@@ -449,7 +449,7 @@ menu_remove_folder::menu_remove_folder(mame_ui_manager &mui, render_container &c
else
m_searchpath.assign(mui.machine().options().value(s_folders[m_ref].option));
- path_iterator path(m_searchpath.c_str());
+ path_iterator path(m_searchpath);
std::string curpath;
while (path.next(curpath, nullptr))
m_folders.push_back(curpath);
@@ -479,10 +479,10 @@ void menu_remove_folder::handle()
}
if (ui().options().exists(s_folders[m_ref].option))
- ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE);
+ ui().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
else if (strcmp(machine().options().value(s_folders[m_ref].option),tmppath.c_str())!=0)
{
- machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE);
+ machine().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
}
reset_parent(reset_options::REMEMBER_REF);
diff --git a/src/frontend/mame/ui/filecreate.cpp b/src/frontend/mame/ui/filecreate.cpp
index 9928829ecf5..157b19bec9a 100644
--- a/src/frontend/mame/ui/filecreate.cpp
+++ b/src/frontend/mame/ui/filecreate.cpp
@@ -205,7 +205,7 @@ void menu_file_create::handle()
if ((event->itemref == ITEMREF_CREATE) || (event->itemref == ITEMREF_NEW_IMAGE_NAME))
{
std::string tmp_file(m_filename);
- if (tmp_file.find(".") != -1 && tmp_file.find(".") < tmp_file.length() - 1)
+ if (tmp_file.find('.') != -1 && tmp_file.find('.') < tmp_file.length() - 1)
{
m_current_file = m_filename;
stack_pop();
diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp
index 3312e5d54e7..8d3ef0974c1 100644
--- a/src/frontend/mame/ui/imgcntrl.cpp
+++ b/src/frontend/mame/ui/imgcntrl.cpp
@@ -95,7 +95,7 @@ void menu_control_device_image::test_create(bool &can_create, bool &need_confirm
auto path = util::zippath_combine(m_current_directory, m_current_file);
// does a file or a directory exist at the path
- auto entry = osd_stat(path.c_str());
+ auto entry = osd_stat(path);
auto file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE;
switch(file_type)
@@ -211,7 +211,7 @@ void menu_control_device_image::handle()
break;
case SELECT_PARTLIST:
- m_swi = m_sld->find(m_software_info_name.c_str());
+ m_swi = m_sld->find(m_software_info_name);
if (!m_swi)
m_state = START_SOFTLIST;
else if (m_swi->has_multiple_parts(m_image.image_interface()))
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 4278e0efad9..55147b020ec 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -609,11 +609,11 @@ void menu_export::handle()
{
std::string filename("exported");
emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ);
- if (infile.open(filename.c_str(), ".xml") == osd_file::error::NONE)
+ if (infile.open(filename, ".xml") == osd_file::error::NONE)
for (int seq = 0; ; ++seq)
{
std::string seqtext = string_format("%s_%04d", filename, seq);
- if (infile.open(seqtext.c_str(), ".xml") != osd_file::error::NONE)
+ if (infile.open(seqtext, ".xml") != osd_file::error::NONE)
{
filename = seqtext;
break;
@@ -622,7 +622,7 @@ void menu_export::handle()
// attempt to open the output file
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(filename.c_str(), ".xml") == osd_file::error::NONE)
+ if (file.open(filename, ".xml") == osd_file::error::NONE)
{
std::string fullpath(file.fullpath());
file.close();
@@ -654,11 +654,11 @@ void menu_export::handle()
{
std::string filename("exported");
emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ);
- if (infile.open(filename.c_str(), ".txt") == osd_file::error::NONE)
+ if (infile.open(filename, ".txt") == osd_file::error::NONE)
for (int seq = 0; ; ++seq)
{
std::string seqtext = string_format("%s_%04d", filename, seq);
- if (infile.open(seqtext.c_str(), ".txt") != osd_file::error::NONE)
+ if (infile.open(seqtext, ".txt") != osd_file::error::NONE)
{
filename = seqtext;
break;
@@ -667,7 +667,7 @@ void menu_export::handle()
// attempt to open the output file
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(filename.c_str(), ".txt") == osd_file::error::NONE)
+ if (file.open(filename, ".txt") == osd_file::error::NONE)
{
// print the header
std::ostringstream buffer;
@@ -764,7 +764,7 @@ void menu_machine_configure::handle()
{
std::string filename(m_drv.name);
emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
- osd_file::error filerr = file.open(filename.c_str(), ".ini");
+ osd_file::error filerr = file.open(filename, ".ini");
if (filerr == osd_file::error::NONE)
{
std::string inistring = m_opts.output_ini();
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index b7e621997ad..00113d8aeda 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -251,7 +251,7 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container &conta
ui_globals::rpanel = std::min<int>(std::max<int>(moptions.last_right_panel(), RP_FIRST), RP_LAST);
std::string tmp(moptions.last_used_filter());
- std::size_t const found = tmp.find_first_of(",");
+ std::size_t const found = tmp.find_first_of(',');
std::string fake_ini;
if (found == std::string::npos)
{
@@ -306,8 +306,8 @@ menu_select_game::~menu_select_game()
ui_options &mopt = ui().options();
mopt.set_value(OPTION_LAST_RIGHT_PANEL, ui_globals::rpanel, OPTION_PRIORITY_CMDLINE);
- mopt.set_value(OPTION_LAST_USED_FILTER, filter.c_str(), OPTION_PRIORITY_CMDLINE);
- mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver.c_str(), OPTION_PRIORITY_CMDLINE);
+ mopt.set_value(OPTION_LAST_USED_FILTER, filter, OPTION_PRIORITY_CMDLINE);
+ mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver, OPTION_PRIORITY_CMDLINE);
mopt.set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE);
ui().save_ui_options();
}
@@ -894,8 +894,8 @@ void menu_select_game::inkey_select_favorite(const event *menu_event)
driver_enumerator drv(machine().options(), *ui_swinfo->driver);
media_auditor auditor(drv);
drv.next();
- software_list_device *swlist = software_list_device::find_by_name(*drv.config(), ui_swinfo->listname.c_str());
- const software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
+ software_list_device *swlist = software_list_device::find_by_name(*drv.config(), ui_swinfo->listname);
+ const software_info *swinfo = swlist->find(ui_swinfo->shortname);
media_auditor::summary const summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST);
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index bb3e5dc8c00..4fd71e2798e 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -346,8 +346,8 @@ void menu_select_launch::bios_selection::handle()
machine().options().set_value(OPTION_BIOS, elem.second, OPTION_PRIORITY_CMDLINE); // oh dear, relying on this persisting through the part selection menu
driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
drivlist.next();
- software_list_device *swlist = software_list_device::find_by_name(*drivlist.config(), ui_swinfo->listname.c_str());
- const software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
+ software_list_device *swlist = software_list_device::find_by_name(*drivlist.config(), ui_swinfo->listname);
+ const software_info *swinfo = swlist->find(ui_swinfo->shortname);
if (!select_part(ui(), container(), *swinfo, *ui_swinfo))
{
reselect_last::reselect(true);
@@ -693,7 +693,7 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto
else
{
std::string copyright(emulator_info::get_copyright());
- size_t found = copyright.find("\n");
+ size_t found = copyright.find('\n');
tempbuf[0].clear();
tempbuf[1] = string_format(_("%1$s %2$s"), emulator_info::get_appname(), build_version);
@@ -1305,8 +1305,8 @@ void menu_select_launch::get_title_search(std::string &snaptext, std::string &se
}
std::string tmp(searchstr);
- path_iterator path(tmp.c_str());
- path_iterator path_iter(addpath.c_str());
+ path_iterator path(tmp);
+ path_iterator path_iter(addpath);
std::string c_path, curpath;
// iterate over path and add path for zipped formats
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 4133f238e08..3c689d19239 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -483,8 +483,8 @@ void menu_select_software::inkey_select(const event *menu_event)
driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
media_auditor auditor(drivlist);
drivlist.next();
- software_list_device *swlist = software_list_device::find_by_name(*drivlist.config(), ui_swinfo->listname.c_str());
- const software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
+ software_list_device *swlist = software_list_device::find_by_name(*drivlist.config(), ui_swinfo->listname);
+ const software_info *swinfo = swlist->find(ui_swinfo->shortname);
media_auditor::summary const summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST);
diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp
index 77df1a003cf..aa3ebac7976 100644
--- a/src/frontend/mame/ui/sliders.cpp
+++ b/src/frontend/mame/ui/sliders.cpp
@@ -151,7 +151,7 @@ void menu_sliders::populate(float &customtop, float &custombottom)
// add UI sliders
std::vector<menu_item> ui_sliders = ui().get_slider_list();
- for (menu_item item : ui_sliders)
+ for (const menu_item &item : ui_sliders)
{
if (item.type == menu_item_type::SLIDER)
{
@@ -180,7 +180,7 @@ void menu_sliders::populate(float &customtop, float &custombottom)
// add OSD options
std::vector<menu_item> osd_sliders = machine().osd().get_slider_list();
- for (menu_item item : osd_sliders)
+ for (const menu_item &item : osd_sliders)
{
if (item.type == menu_item_type::SLIDER)
{
diff --git a/src/frontend/mame/ui/tapectrl.cpp b/src/frontend/mame/ui/tapectrl.cpp
index 0784ed72d26..1517554efd9 100644
--- a/src/frontend/mame/ui/tapectrl.cpp
+++ b/src/frontend/mame/ui/tapectrl.cpp
@@ -87,7 +87,7 @@ void menu_tape_control::populate(float &customtop, float &custombottom)
? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? _("playing") : _("(playing)"))
: ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? _("recording") : _("(recording)"))
),
- timepos.c_str(),
+ timepos,
tapeflags,
TAPECMD_SLIDER);