Minor fixes for warnings from some lint tools.

This commit is contained in:
Stephen Anthony 2022-05-08 13:55:17 -02:30
parent e13233e5b7
commit 928de47898
12 changed files with 37 additions and 50 deletions

View File

@ -522,7 +522,7 @@ const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops
if(jprops.contains(SCORE_ADDRESSES)) if(jprops.contains(SCORE_ADDRESSES))
{ {
const json addrProps = jprops.at(SCORE_ADDRESSES); const json& addrProps = jprops.at(SCORE_ADDRESSES);
if(!addrProps.empty() && addrProps.is_array()) if(!addrProps.empty() && addrProps.is_array())
{ {
@ -642,7 +642,7 @@ void HighScoresManager::loadHighScores(ScoresData& data)
buf << "Error: Incompatible high scores data for variation " << data.variation << "."; buf << "Error: Incompatible high scores data for variation " << data.variation << ".";
else if(hsObject.contains(DATA)) else if(hsObject.contains(DATA))
{ {
const json hsData = hsObject.at(DATA); const json& hsData = hsObject.at(DATA);
if(!load(hsData, data) if(!load(hsData, data)
|| !hsObject.contains(MD5) || hsObject.at(MD5) != data.md5 || !hsObject.contains(MD5) || hsObject.at(MD5) != data.md5

View File

@ -50,7 +50,7 @@ class PhysicalJoystickHandler
struct StickInfo struct StickInfo
{ {
explicit StickInfo(nlohmann::json map, PhysicalJoystickPtr stick = nullptr) explicit StickInfo(nlohmann::json map, PhysicalJoystickPtr stick = nullptr)
: mapping(map), joy{std::move(stick)} {} : mapping{std::move(map)}, joy{std::move(stick)} {}
nlohmann::json mapping; nlohmann::json mapping;
PhysicalJoystickPtr joy; PhysicalJoystickPtr joy;

View File

@ -75,14 +75,14 @@ class RewindManager
static constexpr int NUM_HORIZONS = 8; static constexpr int NUM_HORIZONS = 8;
// cycle values for the horzions // cycle values for the horzions
const std::array<uInt64, NUM_HORIZONS> HORIZON_CYCLES = { const std::array<uInt64, NUM_HORIZONS> HORIZON_CYCLES = {
76 * 262 * 60 * 3, uInt64{76} * 262 * 60 * 3,
76 * 262 * 60 * 10, uInt64{76} * 262 * 60 * 10,
76 * 262 * 60 * 30, uInt64{76} * 262 * 60 * 30,
76 * 262 * 60 * 60, uInt64{76} * 262 * 60 * 60,
76 * 262 * 60 * 60 * 3, uInt64{76} * 262 * 60 * 60 * 3,
76 * 262 * 60 * 60 * 10, uInt64{76} * 262 * 60 * 60 * 10,
uInt64{76} *262 * 60 * 60 * 30, uInt64{76} * 262 * 60 * 60 * 30,
uInt64{76} *262 * 60 * 60 * 60 uInt64{76} * 262 * 60 * 60 * 60
}; };
// settings values for the horzions // settings values for the horzions
const std::array<string, NUM_HORIZONS> HOR_SETTINGS = { const std::array<string, NUM_HORIZONS> HOR_SETTINGS = {

View File

@ -242,7 +242,7 @@ namespace BSPF
// starting from 'startpos' in the first string // starting from 'startpos' in the first string
static size_t findIgnoreCase(string_view s1, string_view s2, size_t startpos = 0) static size_t findIgnoreCase(string_view s1, string_view s2, size_t startpos = 0)
{ {
auto pos = std::search(s1.cbegin()+startpos, s1.cend(), const auto pos = std::search(s1.cbegin()+startpos, s1.cend(),
s2.cbegin(), s2.cend(), [](char ch1, char ch2) { s2.cbegin(), s2.cend(), [](char ch1, char ch2) {
return toupper(static_cast<uInt8>(ch1)) == toupper(static_cast<uInt8>(ch2)); return toupper(static_cast<uInt8>(ch1)) == toupper(static_cast<uInt8>(ch2));
}); });
@ -335,7 +335,7 @@ namespace BSPF
// Trim leading and trailing whitespace from a string // Trim leading and trailing whitespace from a string
inline string trim(const string& str) inline string trim(const string& str)
{ {
const string::size_type first = str.find_first_not_of(' '); const auto first = str.find_first_not_of(' ');
return (first == string::npos) ? EmptyString : return (first == string::npos) ? EmptyString :
str.substr(first, str.find_last_not_of(' ')-first+1); str.substr(first, str.find_last_not_of(' ')-first+1);
} }
@ -344,8 +344,7 @@ namespace BSPF
// Equivalent to the C-style localtime() function, but is thread-safe // Equivalent to the C-style localtime() function, but is thread-safe
inline std::tm localTime() inline std::tm localTime()
{ {
std::time_t currtime; const auto currtime = std::time(nullptr);
std::time(&currtime);
std::tm tm_snapshot; std::tm tm_snapshot;
#if (defined BSPF_WINDOWS || defined __WIN32__) && (!defined __GNUG__ || defined __MINGW32__) #if (defined BSPF_WINDOWS || defined __WIN32__) && (!defined __GNUG__ || defined __MINGW32__)
localtime_s(&tm_snapshot, &currtime); localtime_s(&tm_snapshot, &currtime);
@ -355,15 +354,9 @@ namespace BSPF
return tm_snapshot; return tm_snapshot;
} }
inline bool isWhiteSpace(const char s) inline bool isWhiteSpace(const char c)
{ {
const string WHITESPACES = " ,.;:+-*&/\\'"; return string(" ,.;:+-*&/\\'").find(c) != string::npos;
for(size_t i = 0; i < WHITESPACES.length(); ++i)
if(s == WHITESPACES[i])
return true;
return false;
} }
} // namespace BSPF } // namespace BSPF

View File

@ -45,7 +45,7 @@ bool CompositeKeyValueRepositoryAtomic::has(const string& key1, const string& ke
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CompositeKeyValueRepositoryAtomic::remove(const string& key1, const string key2) void CompositeKeyValueRepositoryAtomic::remove(const string& key1, const string& key2)
{ {
getAtomic(key1)->remove(key2); getAtomic(key1)->remove(key2);
} }

View File

@ -63,7 +63,7 @@ class CompositeKeyValueRepositoryAtomic : public CompositeKeyValueRepository
virtual bool has(const string& key1, const string& key2); virtual bool has(const string& key1, const string& key2);
virtual void remove(const string& key1, const string key2); virtual void remove(const string& key1, const string& key2);
CompositeKeyValueRepositoryAtomic* atomic() override { return this; } CompositeKeyValueRepositoryAtomic* atomic() override { return this; }
}; };

View File

@ -334,15 +334,9 @@ void FBSurface::splitString(const GUI::Font& font, const string& s, int w,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FBSurface::isWhiteSpace(const char s) const bool FBSurface::isWhiteSpace(const char c) const
{ {
const string WHITESPACES = " ,.;:+-*/\\'([\n"; return string(" ,.;:+-*/\\'([\n").find(c) != string::npos;
for(size_t i = 0; i < WHITESPACES.length(); ++i)
if(s == WHITESPACES[i])
return true;
return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -400,10 +400,10 @@ class FBSurface
/** /**
Check if the given character is a whitespace. Check if the given character is a whitespace.
@param s Character to check @param c Character to check
@return True if whitespace character @return True if whitespace character
*/ */
bool isWhiteSpace(const char s) const; bool isWhiteSpace(const char c) const;
protected: protected:
uInt32* myPixels{nullptr}; // NOTE: MUST be set in child classes uInt32* myPixels{nullptr}; // NOTE: MUST be set in child classes

View File

@ -209,15 +209,15 @@ AnalogReadout::Connection Paddles::getReadOut(int lastAxis, int& newAxis, int ce
static constexpr std::array<float, MAX_DEJITTER - MIN_DEJITTER + 1> bFac = { static constexpr std::array<float, MAX_DEJITTER - MIN_DEJITTER + 1> bFac = {
// higher values mean more dejitter strength // higher values mean more dejitter strength
0.f, // off 0.F, // off
0.50f, 0.59f, 0.67f, 0.74f, 0.80f, 0.50F, 0.59F, 0.67F, 0.74F, 0.80F,
0.85f, 0.89f, 0.92f, 0.94f, 0.95f 0.85F, 0.89F, 0.92F, 0.94F, 0.95F
}; };
static constexpr std::array<float, MAX_DEJITTER - MIN_DEJITTER + 1> dFac = { static constexpr std::array<float, MAX_DEJITTER - MIN_DEJITTER + 1> dFac = {
// lower values mean more dejitter strength // lower values mean more dejitter strength
1.f, // off 1.F, // off
1.0f / 181, 1.0f / 256, 1.0f / 362, 1.0f / 512, 1.0f / 724, 1.0F / 181, 1.0F / 256, 1.0F / 362, 1.0F / 512, 1.0F / 724,
1.0f / 1024, 1.0f / 1448, 1.0f / 2048, 1.0f / 2896, 1.0f / 4096 1.0F / 1024, 1.0F / 1448, 1.0F / 2048, 1.0F / 2896, 1.0F / 4096
}; };
const float baseFactor = bFac[DEJITTER_BASE]; const float baseFactor = bFac[DEJITTER_BASE];
const float diffFactor = dFac[DEJITTER_DIFF]; const float diffFactor = dFac[DEJITTER_DIFF];
@ -518,7 +518,7 @@ float Paddles::analogSensitivityValue(int sensitivity)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setAnalogLinearity(int linearity) void Paddles::setAnalogLinearity(int linearity)
{ {
LINEARITY = 100.f / BSPF::clamp(linearity, MIN_ANALOG_LINEARITY, MAX_ANALOG_LINEARITY); LINEARITY = 100.F / BSPF::clamp(linearity, MIN_ANALOG_LINEARITY, MAX_ANALOG_LINEARITY);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setDejitterBase(int strength) void Paddles::setDejitterBase(int strength)
@ -549,8 +549,8 @@ void Paddles::setDigitalPaddleRange(int range)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Paddles::XCENTER = 0; int Paddles::XCENTER = 0;
int Paddles::YCENTER = 0; int Paddles::YCENTER = 0;
float Paddles::SENSITIVITY = 1.0; float Paddles::SENSITIVITY = 1.F;
float Paddles::LINEARITY = 1.0; float Paddles::LINEARITY = 1.F;
int Paddles::DEJITTER_BASE = 0; int Paddles::DEJITTER_BASE = 0;
int Paddles::DEJITTER_DIFF = 0; int Paddles::DEJITTER_DIFF = 0;
int Paddles::TRIGRANGE = Paddles::TRIGMAX; int Paddles::TRIGRANGE = Paddles::TRIGMAX;

View File

@ -58,7 +58,7 @@ void FileListWidget::setDirectory(const FilesystemNode& node,
_history.clear(); _history.clear();
while(tmp.hasParent()) while(tmp.hasParent())
{ {
_history.push_back(HistoryType(tmp, fixPath(name))); _history.emplace_back(tmp, fixPath(name));
name = tmp.getName(); name = tmp.getName();
tmp = tmp.getParent(); tmp = tmp.getParent();
@ -262,7 +262,7 @@ void FileListWidget::addHistory(const FilesystemNode& node)
string select = selected().getName(); string select = selected().getName();
_currentHistory->selected = fixPath(select); _currentHistory->selected = fixPath(select);
_history.push_back(HistoryType(node, "..")); _history.emplace_back(node, "..");
_currentHistory = std::prev(_history.end(), 1); _currentHistory = std::prev(_history.end(), 1);
//_historyIndex++; //_historyIndex++;
} }

View File

@ -117,9 +117,7 @@ class FileListWidget : public StringListWidget
FilesystemNode node; FilesystemNode node;
string selected; string selected;
HistoryType() explicit HistoryType(const FilesystemNode& _hnode, const string& _hselected)
: node{}, selected{} {}
explicit HistoryType(const FilesystemNode _hnode, const string _hselected)
: node{_hnode}, selected{_hselected} {} : node{_hnode}, selected{_hselected} {}
}; };
enum class IconType { enum class IconType {

View File

@ -20,7 +20,9 @@
class EditTextWidget; class EditTextWidget;
class FileListWidget; class FileListWidget;
class Font; namespace GUI {
class Font;
}
#include "Widget.hxx" #include "Widget.hxx"