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))
{
const json addrProps = jprops.at(SCORE_ADDRESSES);
const json& addrProps = jprops.at(SCORE_ADDRESSES);
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 << ".";
else if(hsObject.contains(DATA))
{
const json hsData = hsObject.at(DATA);
const json& hsData = hsObject.at(DATA);
if(!load(hsData, data)
|| !hsObject.contains(MD5) || hsObject.at(MD5) != data.md5

View File

@ -50,7 +50,7 @@ class PhysicalJoystickHandler
struct StickInfo
{
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;
PhysicalJoystickPtr joy;

View File

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

View File

@ -242,7 +242,7 @@ namespace BSPF
// starting from 'startpos' in the first string
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) {
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
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 :
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
inline std::tm localTime()
{
std::time_t currtime;
std::time(&currtime);
const auto currtime = std::time(nullptr);
std::tm tm_snapshot;
#if (defined BSPF_WINDOWS || defined __WIN32__) && (!defined __GNUG__ || defined __MINGW32__)
localtime_s(&tm_snapshot, &currtime);
@ -355,15 +354,9 @@ namespace BSPF
return tm_snapshot;
}
inline bool isWhiteSpace(const char s)
inline bool isWhiteSpace(const char c)
{
const string WHITESPACES = " ,.;:+-*&/\\'";
for(size_t i = 0; i < WHITESPACES.length(); ++i)
if(s == WHITESPACES[i])
return true;
return false;
return string(" ,.;:+-*&/\\'").find(c) != string::npos;
}
} // 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);
}

View File

@ -63,7 +63,7 @@ class CompositeKeyValueRepositoryAtomic : public CompositeKeyValueRepository
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; }
};

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";
for(size_t i = 0; i < WHITESPACES.length(); ++i)
if(s == WHITESPACES[i])
return true;
return false;
return string(" ,.;:+-*/\\'([\n").find(c) != string::npos;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -400,10 +400,10 @@ class FBSurface
/**
Check if the given character is a whitespace.
@param s Character to check
@param c Character to check
@return True if whitespace character
*/
bool isWhiteSpace(const char s) const;
bool isWhiteSpace(const char c) const;
protected:
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 = {
// higher values mean more dejitter strength
0.f, // off
0.50f, 0.59f, 0.67f, 0.74f, 0.80f,
0.85f, 0.89f, 0.92f, 0.94f, 0.95f
0.F, // off
0.50F, 0.59F, 0.67F, 0.74F, 0.80F,
0.85F, 0.89F, 0.92F, 0.94F, 0.95F
};
static constexpr std::array<float, MAX_DEJITTER - MIN_DEJITTER + 1> dFac = {
// lower values mean more dejitter strength
1.f, // off
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.F, // off
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
};
const float baseFactor = bFac[DEJITTER_BASE];
const float diffFactor = dFac[DEJITTER_DIFF];
@ -518,7 +518,7 @@ float Paddles::analogSensitivityValue(int sensitivity)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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)
@ -549,8 +549,8 @@ void Paddles::setDigitalPaddleRange(int range)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Paddles::XCENTER = 0;
int Paddles::YCENTER = 0;
float Paddles::SENSITIVITY = 1.0;
float Paddles::LINEARITY = 1.0;
float Paddles::SENSITIVITY = 1.F;
float Paddles::LINEARITY = 1.F;
int Paddles::DEJITTER_BASE = 0;
int Paddles::DEJITTER_DIFF = 0;
int Paddles::TRIGRANGE = Paddles::TRIGMAX;

View File

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

View File

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

View File

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