diff options
| author | Tillmann Karras <tilkax@gmail.com> | 2014-02-23 23:03:39 +0100 |
|---|---|---|
| committer | Tillmann Karras <tilkax@gmail.com> | 2014-02-28 12:43:20 +0100 |
| commit | 315a8ba1c04bf8cffd9b04096be898ac462fa89e (patch) | |
| tree | 5655bdf4d940b3fdd372cb76181d70137982aefc /Source/Core/VideoCommon | |
| parent | 5f0a8008f45f2c30a1aed044a428c5b4ce09ce88 (diff) | |
Various changes suggested by cppcheck
- remove unused variables
- reduce the scope where it makes sense
- correct limits (did you know that strcat()'s last parameter does not
include the \0 that is always added?)
- set some free()'d pointers to NULL
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/FPSCounter.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Fifo.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/ImageWrite.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/ImageWrite.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureConversionShader.cpp | 34 |
7 files changed, 27 insertions, 29 deletions
diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index cdf7c1d85f..59a67e002a 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -32,7 +32,7 @@ static void LogFPSToFile(unsigned long val) s_bench_file.Open(File::GetUserPath(D_LOGS_IDX) + "fps.txt", "w"); char buffer[256]; - snprintf(buffer, 256, "%ld\n", val); + snprintf(buffer, 256, "%lu\n", val); s_bench_file.WriteArray(buffer, strlen(buffer)); } diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 9e3f615291..233f1e8109 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -70,6 +70,7 @@ void Fifo_Shutdown() { if (GpuRunningState) PanicAlert("Fifo shutting down while active"); FreeMemoryPages(videoBuffer, FIFO_SIZE); + videoBuffer = NULL; } u8* GetVideoBufferStartPtr() diff --git a/Source/Core/VideoCommon/ImageWrite.cpp b/Source/Core/VideoCommon/ImageWrite.cpp index ad0449dd2f..a3c9dec86a 100644 --- a/Source/Core/VideoCommon/ImageWrite.cpp +++ b/Source/Core/VideoCommon/ImageWrite.cpp @@ -26,7 +26,7 @@ Inputs: data : This is an array of RGBA with 8 bits per channel. 4 bytes for each pixel. row_stride: Determines the amount of bytes per row of pixels. */ -bool TextureToPng(u8* data, int row_stride, const std::string filename, int width, int height, bool saveAlpha) +bool TextureToPng(u8* data, int row_stride, const std::string& filename, int width, int height, bool saveAlpha) { bool success = false; diff --git a/Source/Core/VideoCommon/ImageWrite.h b/Source/Core/VideoCommon/ImageWrite.h index 5df630651a..b46dc1376f 100644 --- a/Source/Core/VideoCommon/ImageWrite.h +++ b/Source/Core/VideoCommon/ImageWrite.h @@ -7,4 +7,4 @@ #include "Common/Common.h" bool SaveData(const char* filename, const char* pdata); -bool TextureToPng(u8* data, int row_stride, const std::string filename, int width, int height, bool saveAlpha = true); +bool TextureToPng(u8* data, int row_stride, const std::string& filename, int width, int height, bool saveAlpha = true); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 5abce6fdee..9ea6fae5ad 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -73,11 +73,8 @@ void TextureCache::Invalidate() TextureCache::~TextureCache() { Invalidate(); - if (temp) - { - FreeAlignedMemory(temp); - temp = NULL; - } + FreeAlignedMemory(temp); + temp = NULL; } void TextureCache::OnConfigChanged(VideoConfig& config) @@ -238,11 +235,11 @@ bool TextureCache::CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsign for (unsigned int level = 1; level < levels; ++level) { - sprintf(texPathTemp, "%s_mip%i", texBasePathTemp, level); + sprintf(texPathTemp, "%s_mip%u", texBasePathTemp, level); if (!HiresTextures::HiresTexExists(texPathTemp)) { if (level > 1) - WARN_LOG(VIDEO, "Couldn't find custom texture LOD with index %i (filename: %s), disabling custom LODs for this texture", level, texPathTemp); + WARN_LOG(VIDEO, "Couldn't find custom texture LOD with index %u (filename: %s), disabling custom LODs for this texture", level, texPathTemp); return false; } @@ -260,7 +257,7 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign if (level == 0) sprintf(texPathTemp, "%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat); else - sprintf(texPathTemp, "%s_%08x_%i_mip%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat, level); + sprintf(texPathTemp, "%s_%08x_%i_mip%u", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat, level); unsigned int required_size = 0; PC_TexFormat ret = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, &required_size, texformat, temp_size, temp); diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 517f45433d..f66726f478 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -72,7 +72,7 @@ public: virtual ~TCacheEntryBase(); virtual void Bind(unsigned int stage) = 0; - virtual bool Save(const std::string filename, unsigned int level) = 0; + virtual bool Save(const std::string& filename, unsigned int level) = 0; virtual void Load(unsigned int width, unsigned int height, unsigned int expanded_width, unsigned int level) = 0; diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 47f9df21ba..1564afa338 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -141,13 +141,13 @@ void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* dest) WRITE(p, " %s = floor(%s * 255.0 / exp2(8.0 - %d.0));\n", dest, src, depth); } -void WriteEncoderEnd(char* p, API_TYPE ApiType) +void WriteEncoderEnd(char*& p, API_TYPE ApiType) { WRITE(p, "}\n"); IntensityConstantAdded = false; } -void WriteI8Encoder(char* p, API_TYPE ApiType) +void WriteI8Encoder(char*& p, API_TYPE ApiType) { WriteSwizzler(p, GX_TF_I8, ApiType); WRITE(p, " float3 texSample;\n"); @@ -169,7 +169,7 @@ void WriteI8Encoder(char* p, API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteI4Encoder(char* p, API_TYPE ApiType) +void WriteI4Encoder(char*& p, API_TYPE ApiType) { WriteSwizzler(p, GX_TF_I4, ApiType); WRITE(p, " float3 texSample;\n"); @@ -210,7 +210,7 @@ void WriteI4Encoder(char* p, API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteIA8Encoder(char* p,API_TYPE ApiType) +void WriteIA8Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_IA8, ApiType); WRITE(p, " float4 texSample;\n"); @@ -228,7 +228,7 @@ void WriteIA8Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteIA4Encoder(char* p,API_TYPE ApiType) +void WriteIA4Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_IA4, ApiType); WRITE(p, " float4 texSample;\n"); @@ -260,7 +260,7 @@ void WriteIA4Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteRGB565Encoder(char* p,API_TYPE ApiType) +void WriteRGB565Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB565, ApiType); @@ -283,7 +283,7 @@ void WriteRGB565Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteRGB5A3Encoder(char* p,API_TYPE ApiType) +void WriteRGB5A3Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB5A3, ApiType); @@ -349,7 +349,7 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteRGBA4443Encoder(char* p,API_TYPE ApiType) +void WriteRGBA4443Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB5A3, ApiType); @@ -373,7 +373,7 @@ void WriteRGBA4443Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteRGBA8Encoder(char* p,API_TYPE ApiType) +void WriteRGBA8Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGBA8, ApiType); @@ -398,7 +398,7 @@ void WriteRGBA8Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteC4Encoder(char* p, const char* comp,API_TYPE ApiType) +void WriteC4Encoder(char*& p, const char* comp,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_R4, ApiType); WRITE(p, " float4 color0;\n"); @@ -420,7 +420,7 @@ void WriteC4Encoder(char* p, const char* comp,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteC8Encoder(char* p, const char* comp,API_TYPE ApiType) +void WriteC8Encoder(char*& p, const char* comp,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_R8, ApiType); @@ -432,7 +432,7 @@ void WriteC8Encoder(char* p, const char* comp,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteCC4Encoder(char* p, const char* comp,API_TYPE ApiType) +void WriteCC4Encoder(char*& p, const char* comp,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_RA4, ApiType); WRITE(p, " float2 texSample;\n"); @@ -462,7 +462,7 @@ void WriteCC4Encoder(char* p, const char* comp,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteCC8Encoder(char* p, const char* comp, API_TYPE ApiType) +void WriteCC8Encoder(char*& p, const char* comp, API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_RA8, ApiType); @@ -472,7 +472,7 @@ void WriteCC8Encoder(char* p, const char* comp, API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteZ8Encoder(char* p, const char* multiplier,API_TYPE ApiType) +void WriteZ8Encoder(char*& p, const char* multiplier,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_Z8M, ApiType); @@ -493,7 +493,7 @@ void WriteZ8Encoder(char* p, const char* multiplier,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteZ16Encoder(char* p,API_TYPE ApiType) +void WriteZ16Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_Z16, ApiType); @@ -525,7 +525,7 @@ void WriteZ16Encoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteZ16LEncoder(char* p,API_TYPE ApiType) +void WriteZ16LEncoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_Z16L, ApiType); @@ -561,7 +561,7 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType) WriteEncoderEnd(p, ApiType); } -void WriteZ24Encoder(char* p, API_TYPE ApiType) +void WriteZ24Encoder(char*& p, API_TYPE ApiType) { WriteSwizzler(p, GX_TF_Z24X8, ApiType); |
