Fix various Cppcheck warnings (#15081)

This commit is contained in:
Hielke Morsink 2021-07-24 23:41:50 +02:00 committed by GitHub
parent cd98ca0d8e
commit c887a049d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 29 additions and 33 deletions

View File

@ -232,7 +232,7 @@ namespace OpenRCT2::Ui
return result;
}
static std::wstring GetFilterString(const std::vector<FileDialogDesc::Filter> filters)
static std::wstring GetFilterString(const std::vector<FileDialogDesc::Filter>& filters)
{
std::wstringstream filtersb;
for (const auto& filter : filters)

View File

@ -123,7 +123,7 @@ public:
~UiContext() override
{
CloseWindow();
UiContext::CloseWindow();
delete _windowManager;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
delete _platformUiContext;
@ -179,11 +179,8 @@ public:
if (mode == FULLSCREEN_MODE::FULLSCREEN)
{
SDL_SetWindowFullscreen(_window, 0);
}
// Set window size
if (mode == FULLSCREEN_MODE::FULLSCREEN)
{
// Set window size
UpdateFullscreenResolutions();
Resolution resolution = GetClosestResolution(gConfigGeneral.fullscreen_width, gConfigGeneral.fullscreen_height);
SDL_SetWindowSize(_window, resolution.Width, resolution.Height);
@ -598,7 +595,7 @@ public:
{
scaleQuality = ScaleQuality::Linear;
}
snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%u", static_cast<int32_t>(scaleQuality));
snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%d", static_cast<int32_t>(scaleQuality));
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQualityBuffer);
int32_t width, height;

View File

@ -47,9 +47,9 @@ namespace OpenRCT2::Audio
public:
AudioChannelImpl()
{
SetRate(1);
SetVolume(MIXER_VOLUME_MAX);
SetPan(0.5f);
AudioChannelImpl::SetRate(1);
AudioChannelImpl::SetVolume(MIXER_VOLUME_MAX);
AudioChannelImpl::SetPan(0.5f);
}
~AudioChannelImpl() override

View File

@ -56,7 +56,7 @@ namespace OpenRCT2::Audio
~AudioMixerImpl() override
{
Close();
AudioMixerImpl::Close();
delete _nullSource;
}

View File

@ -134,7 +134,7 @@ public:
}
char scaleQualityBuffer[4];
snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%u", static_cast<int32_t>(scaleQuality));
snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%d", static_cast<int32_t>(scaleQuality));
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
_screenTexture = SDL_CreateTexture(_sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_STREAMING, width, height);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQualityBuffer);

View File

@ -21,9 +21,8 @@
using namespace OpenRCT2;
OpenGLShader::OpenGLShader(const char* name, GLenum type)
: _type(type)
{
_type = type;
auto path = GetPath(name);
auto sourceCode = ReadSourceCode(path);
auto sourceCodeStr = sourceCode.c_str();

View File

@ -91,9 +91,9 @@ private:
public:
Atlas(GLuint index, int32_t imageSize)
: _index(index)
, _imageSize(imageSize)
{
_index = index;
_imageSize = imageSize;
}
void Initialise(int32_t atlasWidth, int32_t atlasHeight)

View File

@ -117,13 +117,13 @@ enum
struct LoadSaveListItem
{
std::string name;
std::string path;
time_t date_modified;
std::string date_formatted;
std::string time_formatted;
uint8_t type;
bool loaded;
std::string name{};
std::string path{};
time_t date_modified{ 0 };
std::string date_formatted{};
std::string time_formatted{};
uint8_t type{ 0 };
bool loaded{ false };
};
static std::function<void(int32_t result, std::string_view)> _loadSaveCallback;

View File

@ -150,7 +150,7 @@ private:
_nextDownloadQueued = true;
}
void DownloadObject(const rct_object_entry& entry, const std::string name, const std::string url)
void DownloadObject(const rct_object_entry& entry, const std::string& name, const std::string& url)
{
try
{

View File

@ -631,11 +631,11 @@ public:
private:
explicit TcpSocket(SOCKET socket, const std::string& hostName, const std::string& ipAddress)
: _status(SocketStatus::Connected)
, _socket(socket)
, _ipAddress(ipAddress)
, _hostName(hostName)
{
_socket = socket;
_hostName = hostName;
_ipAddress = ipAddress;
_status = SocketStatus::Connected;
}
void CloseSocket()
@ -833,10 +833,10 @@ public:
private:
explicit UdpSocket(SOCKET socket, const std::string& hostName)
: _status(SocketStatus::Connected)
, _socket(socket)
, _hostName(hostName)
{
_socket = socket;
_hostName = hostName;
_status = SocketStatus::Connected;
}
SOCKET CreateSocket()

View File

@ -13,7 +13,7 @@
#include <initializer_list>
#include <vector>
template<typename T, typename TExpected> static void AssertVector(std::vector<T> actual, TExpected expected)
template<typename T, typename TExpected> static void AssertVector(const std::vector<T>& actual, TExpected expected)
{
ASSERT_EQ(actual.size(), expected.size()) << "Expected vector of size " << expected.size() << ", but was " << actual.size();
size_t i = 0;
@ -24,7 +24,7 @@ template<typename T, typename TExpected> static void AssertVector(std::vector<T>
}
}
template<typename T> static void AssertVector(std::vector<T> actual, std::initializer_list<T> expected)
template<typename T> static void AssertVector(const std::vector<T>& actual, std::initializer_list<T> expected)
{
AssertVector<T, std::initializer_list<T>>(actual, expected);
}