Misc: Fix a bunch of code analysis warnings

Some of which were even actual errors.
This commit is contained in:
Stenzek
2024-08-02 23:56:06 +10:00
parent 4eb3b2a9a7
commit 3a83c4265c
30 changed files with 93 additions and 78 deletions

View File

@ -55,6 +55,7 @@ AudioStream::AudioStream(u32 sample_rate, const AudioStreamParameters& parameter
AudioStream::~AudioStream()
{
StretchDestroy();
DestroyBuffer();
}

View File

@ -86,7 +86,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
if (!track)
break;
const std::string track_filename(track->file);
const std::string& track_filename = track->file;
LBA track_start = track->start.ToLBA();
u32 track_file_index = 0;
@ -124,7 +124,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
return false;
}
m_files.push_back(TrackFile{std::move(track_filename), track_fp, 0});
m_files.push_back(TrackFile{track_filename, track_fp, 0});
}
// data type determines the sector size

View File

@ -83,7 +83,7 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd);
CDImage::SubChannelQ subq;
std::copy_n(entry.data, countof(entry.data), subq.data.data());
std::memcpy(subq.data.data(), entry.data, sizeof(entry.data));
// generate an invalid crc by flipping all bits from the valid crc (will never collide)
const u16 crc = subq.ComputeCRC(subq.data) ^ 0xFFFF;
@ -119,7 +119,7 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path)
const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd);
CDImage::SubChannelQ subq;
std::copy_n(entry.data, countof(entry.data), subq.data.data());
std::memcpy(subq.data.data(), entry.data, sizeof(entry.data));
DEBUG_LOG("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
subq.IsCRCValid() ? "VALID" : "INVALID");

View File

@ -365,7 +365,7 @@ bool CueParser::File::HandlePregapCommand(const char* line, u32 line_number, Err
return false;
}
m_current_track->zero_pregap = std::move(msf);
m_current_track->zero_pregap = msf;
return true;
}

View File

@ -11,11 +11,11 @@
Log_SetChannel(D3D11Device);
D3D11StreamBuffer::D3D11StreamBuffer() : m_size(0), m_position(0)
D3D11StreamBuffer::D3D11StreamBuffer()
{
}
D3D11StreamBuffer::D3D11StreamBuffer(ComPtr<ID3D11Buffer> buffer) : m_buffer(std::move(buffer)), m_position(0)
D3D11StreamBuffer::D3D11StreamBuffer(ComPtr<ID3D11Buffer> buffer) : m_buffer(std::move(buffer))
{
D3D11_BUFFER_DESC desc;
m_buffer->GetDesc(&desc);

View File

@ -42,9 +42,9 @@ public:
private:
ComPtr<ID3D11Buffer> m_buffer;
u32 m_size;
u32 m_max_size;
u32 m_position;
u32 m_size = 0;
u32 m_max_size = 0;
u32 m_position = 0;
bool m_use_map_no_overwrite = false;
bool m_mapped = false;
};

View File

@ -753,7 +753,7 @@ std::unique_ptr<GPUSampler> D3D12Device::CreateSampler(const GPUSampler::Config&
if (!handle)
return {};
return std::unique_ptr<GPUSampler>(new D3D12Sampler(std::move(handle)));
return std::unique_ptr<GPUSampler>(new D3D12Sampler(handle));
}
D3D12TextureBuffer::D3D12TextureBuffer(Format format, u32 size_in_elements) : GPUTextureBuffer(format, size_in_elements)

View File

@ -415,7 +415,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
if (m_features.pipeline_cache && !base_path.empty())
{
const std::string basename = GetShaderCacheBaseName("pipelines");
const std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename));
std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename));
if (ReadPipelineCache(filename))
s_pipeline_cache_path = std::move(filename);
else

View File

@ -449,7 +449,7 @@ public:
protected:
Format m_format;
u32 m_size_in_elements;
u32 m_current_position;
u32 m_current_position = 0;
};
class GPUDevice

View File

@ -136,7 +136,7 @@ template<typename FBOType, FBOType (*FactoryFunc)(GPUTexture* const* rts, u32 nu
void (*DestroyFunc)(FBOType fbo)>
void GPUFramebufferManager<FBOType, FactoryFunc, DestroyFunc>::Clear()
{
for (auto it : m_map)
for (const auto& it : m_map)
DestroyFunc(it.second);
m_map.clear();
}

View File

@ -76,7 +76,7 @@ private:
CacheIndex m_index;
std::string m_base_filename;
u32 m_version;
u32 m_version = 0;
std::FILE* m_index_file = nullptr;
std::FILE* m_blob_file = nullptr;

View File

@ -75,7 +75,7 @@ std::optional<InputBindingKey> InputSource::ParseGenericControllerKey(InputSourc
return std::nullopt;
const std::optional<s32> source_index = StringUtil::FromChars<s32>(source.substr(pos));
if (source_index.has_value() || source_index.value() < 0)
if (!source_index.has_value() || source_index.value() < 0)
return std::nullopt;
InputBindingKey key = {};

View File

@ -554,6 +554,7 @@ void OpenGLDevice::CommitRTClearInFB(OpenGLTexture* tex, u32 idx)
glEnable(GL_SCISSOR_TEST);
tex->SetState(GPUTexture::State::Dirty);
}
break;
case GPUTexture::State::Dirty:
break;

View File

@ -23,7 +23,7 @@ ShaderGen::ShaderGen(RenderAPI render_api, GPUShaderLanguage shader_language, bo
m_glsl(shader_language == GPUShaderLanguage::GLSL || shader_language == GPUShaderLanguage::GLSLES ||
shader_language == GPUShaderLanguage::GLSLVK),
m_spirv(shader_language == GPUShaderLanguage::GLSLVK), m_supports_dual_source_blend(supports_dual_source_blend),
m_supports_framebuffer_fetch(supports_framebuffer_fetch), m_use_glsl_interface_blocks(false)
m_supports_framebuffer_fetch(supports_framebuffer_fetch)
{
if (m_glsl)
{

View File

@ -72,8 +72,8 @@ protected:
bool m_spirv;
bool m_supports_dual_source_blend;
bool m_supports_framebuffer_fetch;
bool m_use_glsl_interface_blocks;
bool m_use_glsl_binding_layout;
bool m_use_glsl_interface_blocks = false;
bool m_use_glsl_binding_layout = false;
bool m_has_uniform_buffer = false;
TinyString m_glsl_version_string;