Some fixes for suggestions from clang-tidy.

This commit is contained in:
Stephen Anthony 2020-12-16 16:24:46 -03:30
parent 162b13f3d1
commit 00d241c67b
22 changed files with 41 additions and 55 deletions

View File

@ -22,7 +22,7 @@ namespace Common {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Base::toString(int value, Common::Base::Fmt outputBase)
{
static char vToS_buf[32]; // NOLINT - One place where C-style is acceptable
static char vToS_buf[32]; // NOLINT : One place where C-style is acceptable
if(outputBase == Base::Fmt::_DEFAULT)
outputBase = myDefaultBase;

View File

@ -69,7 +69,7 @@ Int16 HighScoresManager::peek(uInt16 addr) const
{
if (myOSystem.hasConsole())
{
if(addr < 0x100u || myOSystem.console().cartridge().internalRamSize() == 0)
if(addr < 0x100U || myOSystem.console().cartridge().internalRamSize() == 0)
return myOSystem.console().system().peek(addr);
else
return myOSystem.console().cartridge().internalRamGetValue(addr);

View File

@ -56,7 +56,7 @@ namespace {
return serializedMask.size() == 1 ? serializedMask.at(0) : serializedMask;
}
int deserializeModkeyMask(json serializedMask)
int deserializeModkeyMask(const json& serializedMask)
{
if(serializedMask.is_null()) return StellaMod::KBDM_NONE;
if(!serializedMask.is_array()) return serializedMask.get<StellaMod>();

View File

@ -43,7 +43,7 @@ std::map<string, Variant> KeyValueRepositorySqlite::load()
myStmtSelect->reset();
}
catch (const SqliteError& err) {
Logger::info(err.message);
Logger::info(err.what());
}
return values;
@ -69,7 +69,7 @@ void KeyValueRepositorySqlite::save(const std::map<string, Variant>& values)
tx.commit();
}
catch (const SqliteError& err) {
Logger::info(err.message);
Logger::info(err.what());
}
}
@ -87,7 +87,7 @@ void KeyValueRepositorySqlite::save(const string& key, const Variant& value)
myStmtInsert->reset();
}
catch (const SqliteError& err) {
Logger::info(err.message);
Logger::info(err.what());
}
}

View File

@ -39,7 +39,7 @@ bool SettingsDb::initialize()
mySettingsRepository->initialize();
}
catch (const SqliteError& err) {
Logger::info("sqlite DB " + databaseFileName() + " failed to initialize: " + err.message);
Logger::info("sqlite DB " + databaseFileName() + " failed to initialize: " + err.what());
myDb.reset();
mySettingsRepository.reset();

View File

@ -66,7 +66,7 @@ void SqliteDatabase::initialize()
}
throw SqliteError("unable to initialize sqlite DB for unknown reason");
};
}
exec("PRAGMA journal_mode=WAL");

View File

@ -21,12 +21,16 @@
#include <sqlite3.h>
#include "bspf.hxx"
struct SqliteError {
explicit SqliteError(const string& _message) : message(_message) {}
class SqliteError : public std::exception
{
public:
explicit SqliteError(const string& message) : myMessage(message) { }
explicit SqliteError(sqlite3* handle) : myMessage(sqlite3_errmsg(handle)) { }
explicit SqliteError(sqlite3* handle) : message(sqlite3_errmsg(handle)) {}
const char* what() const noexcept override { return myMessage.c_str(); }
const string message;
private:
const string myMessage;
};
#endif // SQLITE_ERROR_HXX

View File

@ -18,7 +18,7 @@
#include "SqliteError.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SqliteStatement::SqliteStatement(sqlite3* handle, string sql)
SqliteStatement::SqliteStatement(sqlite3* handle, const string& sql)
: myHandle(handle)
{
if (sqlite3_prepare_v2(handle, sql.c_str(), -1, &myStmt, nullptr) != SQLITE_OK)

View File

@ -25,7 +25,7 @@
class SqliteStatement {
public:
SqliteStatement(sqlite3* handle, string sql);
SqliteStatement(sqlite3* handle, const string& sql);
~SqliteStatement();

View File

@ -117,7 +117,7 @@ void Cartridge3EWidget::loadConfig()
myBankWidgets[1]->setSelectedIndex(bank - myCart.romBankCount(), oldBank != bank);
}
CartDebugWidget::loadConfig(); // Intentionally calling grand-parent method
CartDebugWidget::loadConfig(); // NOLINT : Intentionally calling grand-parent method
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -41,7 +41,7 @@ string DataGridRamWidget::getToolTip(const Common::Point& pos) const
const Int32 addr = _addrList[idx];
const string label = _ram.getLabel(addr);
const string tip = DataGridWidget::getToolTip(pos);
string tip = DataGridWidget::getToolTip(pos);
if(label.empty())
return tip;

View File

@ -89,7 +89,7 @@ string ToggleBitWidget::getToolTip(const Common::Point& pos) const
if(idx.y < 0)
return EmptyString;
const string tip = ToggleWidget::getToolTip(pos);
string tip = ToggleWidget::getToolTip(pos);
if(idx.x < static_cast<int>(_labelList.size()))
{

View File

@ -185,11 +185,6 @@ class Console : public Serializable, public ConsoleIO
*/
EmulationTiming& emulationTiming() { return myEmulationTiming; }
/**
Retrieve the current game's refresh rate, or 0 if no game.
*/
int refreshRate() const;
public:
/**
Toggle between NTSC/PAL/SECAM (and variants) display format.

View File

@ -184,10 +184,10 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
}
else
{
bbw = desc.bbx[chr].w;
bbh = desc.bbx[chr].h;
bbx = desc.bbx[chr].x;
bby = desc.bbx[chr].y;
bbw = desc.bbx[chr].w; // NOLINT
bbh = desc.bbx[chr].h; // NOLINT
bbx = desc.bbx[chr].x; // NOLINT
bby = desc.bbx[chr].y; // NOLINT
}
uInt32 cx = tx + bbx;

View File

@ -1288,6 +1288,8 @@ void FrameBuffer::setCursorState()
showCursor(true); // +UI, +Emulation
myGrabMouse = false; // disable grab while cursor is shown in emulation
break;
default:
break;
}
myBackend->grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);

View File

@ -172,7 +172,7 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
return;
}
while(i < lines)
while(i < lines) // NOLINT : i changes in lambda above
ADD_ALINE();
}

View File

@ -174,7 +174,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
break;
}
while(i < lines)
while(i < lines) // NOLINT : i changes in lambda above
ADD_LINE();
}

View File

@ -45,11 +45,11 @@ using json = nlohmann::json;
class HighScoresDialog : public Dialog
{
public:
static const uInt32 NUM_RANKS = 10;
static constexpr uInt32 NUM_RANKS = 10;
HighScoresDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h, Menu::AppMode mode);
virtual ~HighScoresDialog();
~HighScoresDialog() override;
protected:
void loadConfig() override;

View File

@ -35,7 +35,7 @@ class HighScoresMenu : public DialogContainer
Create a new menu stack
*/
explicit HighScoresMenu(OSystem& osystem);
virtual ~HighScoresMenu();
~HighScoresMenu() override;
private:
Dialog* baseDialog() override;

View File

@ -138,15 +138,8 @@ void ProgressDialog::incProgress()
void ProgressDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch(cmd)
{
case Event::UICancel:
if(cmd == Event::UICancel)
myIsCancelled = true;
break;
default:
else
Dialog::handleCommand(sender, cmd, data, 0);
break;
}
}

View File

@ -167,7 +167,7 @@ void R77HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
return;
}
while (i < lines)
while (i < lines) // NOLINT : i changes in lambda above
ADD_BIND();
}

View File

@ -393,18 +393,10 @@ void TimeMachineDialog::handleKeyUp(StellaKey key, StellaMod mod)
Event::Type event = instance().eventHandler().eventForKey(EventMode::kEmulationMode, key, mod);
switch (event)
{
case Event::TogglePlayBackMode:
handleCommand(nullptr, kPlayBack, 0, 0);
break;
default:
if (key == KBDK_SPACE)
if(event == Event::TogglePlayBackMode || key == KBDK_SPACE)
handleCommand(nullptr, kPlayBack, 0, 0);
else
Dialog::handleKeyUp(key, mod);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -