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
This commit is contained in:
Tillmann Karras
2014-02-23 23:03:39 +01:00
parent 5f0a8008f4
commit 315a8ba1c0
63 changed files with 494 additions and 420 deletions

View File

@ -735,8 +735,8 @@ public:
{
#ifndef __SYMBIAN32__
FreeMemoryPages(region, region_size);
#endif
region = NULL;
#endif
region_size = 0;
}

View File

@ -196,7 +196,7 @@ std::vector<std::string> cdio_get_devices ()
for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j)
{
std::string drive = StringFromFormat(checklist[i].format, j);
if ( (is_cdrom(drive, NULL)) > 0 )
if (is_cdrom(drive, NULL))
{
drives.push_back(std::move(drive));
}

View File

@ -25,6 +25,14 @@ extern const char *netplay_dolphin_ver;
#define LOGGING 1
#endif
#if defined(__GNUC__) || __clang__
// Disable "unused function" warnings for the ones manually marked as such.
#define UNUSED __attribute__((unused))
#else
// Not sure MSVC even checks this...
#define UNUSED
#endif
#define STACKALIGN
#if __cplusplus >= 201103 || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__)

View File

@ -362,8 +362,6 @@ void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip,
{
STACKFRAME callStack;
BOOL bResult;
TCHAR symInfo[BUFFERSIZE] = _T("?");
TCHAR srcInfo[BUFFERSIZE] = _T("?");
HANDLE hProcess = GetCurrentProcess();
// If it's not this thread, let's suspend it, and resume it at the end

View File

@ -20,11 +20,11 @@ namespace FPURoundMode
PREC_53 = 1,
PREC_64 = 2
};
void SetRoundMode(enum RoundModes mode);
void SetRoundMode(RoundModes mode);
void SetPrecisionMode(enum PrecisionModes mode);
void SetPrecisionMode(PrecisionModes mode);
void SetSIMDMode(enum RoundModes rounding_mode, bool non_ieee_mode);
void SetSIMDMode(RoundModes rounding_mode, bool non_ieee_mode);
/*
* There are two different flavors of float to int conversion:

View File

@ -21,13 +21,13 @@
// Generic, do nothing
namespace FPURoundMode
{
void SetRoundMode(enum RoundModes mode)
void SetRoundMode(RoundModes mode)
{
}
void SetPrecisionMode(enum PrecisionModes mode)
void SetPrecisionMode(PrecisionModes mode)
{
}
void SetSIMDMode(enum RoundModes rounding_mode, bool non_ieee_mode)
void SetSIMDMode(RoundModes rounding_mode, bool non_ieee_mode)
{
}
void SaveSIMDState()

View File

@ -124,13 +124,12 @@ bool IniFile::Section::Get(const std::string& key, std::vector<std::string>& out
}
// ignore starting , if any
size_t subStart = temp.find_first_not_of(",");
size_t subEnd;
// split by ,
while (subStart != std::string::npos)
{
// Find next ,
subEnd = temp.find_first_of(",", subStart);
size_t subEnd = temp.find_first_of(",", subStart);
if (subStart != subEnd)
// take from first char until next ,
out.push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));

View File

@ -36,7 +36,7 @@ int AshmemCreateFileMapping(const char *name, size_t size)
return fd;
// We don't really care if we can't set the name, it is optional
ret = ioctl(fd, ASHMEM_SET_NAME, name);
ioctl(fd, ASHMEM_SET_NAME, name);
ret = ioctl(fd, ASHMEM_SET_SIZE, size);
if (ret < 0)

View File

@ -129,11 +129,10 @@ void FreeMemoryPages(void* ptr, size_t size)
if (ptr)
{
#ifdef _WIN32
if (!VirtualFree(ptr, 0, MEM_RELEASE))
{
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
ptr = NULL; // Is this our responsibility?
}
#else
munmap(ptr, size);
#endif
@ -145,9 +144,9 @@ void FreeAlignedMemory(void* ptr)
if (ptr)
{
#ifdef _WIN32
_aligned_free(ptr);
_aligned_free(ptr);
#else
free(ptr);
free(ptr);
#endif
}
}

View File

@ -18,7 +18,7 @@ namespace FPURoundMode
static u32 saved_sse_state = _mm_getcsr();
static const u32 default_sse_state = _mm_getcsr();
void SetRoundMode(enum RoundModes mode)
void SetRoundMode(RoundModes mode)
{
// Set FPU rounding mode to mimic the PowerPC's
#ifdef _M_IX86
@ -49,7 +49,7 @@ namespace FPURoundMode
#endif
}
void SetPrecisionMode(enum PrecisionModes mode)
void SetPrecisionMode(PrecisionModes mode)
{
#ifdef _M_IX86
// sets the floating-point lib to 53-bit
@ -75,7 +75,7 @@ namespace FPURoundMode
#endif
}
void SetSIMDMode(enum RoundModes rounding_mode, bool non_ieee_mode)
void SetSIMDMode(RoundModes rounding_mode, bool non_ieee_mode)
{
// OR-mask for disabling FPU exceptions (bits 7-12 in the MXCSR register)
const u32 EXCEPTION_MASK = 0x1F80;