Merge pull request #2058 from Stevoisiak/Codemaid-Cleanup-Take2

Basic Formatting/Whitespace Cleanup
This commit is contained in:
Lioncash
2015-02-25 18:07:56 -05:00
97 changed files with 673 additions and 657 deletions

View File

@ -130,7 +130,7 @@ public:
BitField() = default;
#ifndef _WIN32
// We explicitly delete the copy assigment operator here, because the
// We explicitly delete the copy assignment operator here, because the
// default copy assignment would copy the full storage value, rather than
// just the bits relevant to this particular bit field.
// Ideally, we would just implement the copy assignment to copy only the
@ -183,7 +183,7 @@ private:
__forceinline StorageType GetMask() const
{
return ((~(StorageTypeU)0) >> (8*sizeof(T) - bits)) << position;
return ((~(StorageTypeU)0) >> (8 * sizeof(T) - bits)) << position;
}
StorageType storage;

View File

@ -68,7 +68,7 @@ public:
bool IsTempBreakPoint(u32 _iAddress);
// Add BreakPoint
void Add(u32 em_address, bool temp=false);
void Add(u32 em_address, bool temp = false);
void Add(const TBreakPoint& bp);
// Remove Breakpoint

View File

@ -72,23 +72,23 @@ std::vector<std::string> cdio_get_devices()
CFMutableDictionaryRef classes_to_match;
std::vector<std::string> drives;
kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
kern_result = IOMasterPort(MACH_PORT_NULL, &master_port);
if (kern_result != KERN_SUCCESS)
return( drives );
return drives;
classes_to_match = IOServiceMatching( kIOCDMediaClass );
classes_to_match = IOServiceMatching(kIOCDMediaClass);
if (classes_to_match == nullptr)
return( drives );
return drives;
CFDictionarySetValue( classes_to_match,
CFSTR(kIOMediaEjectableKey), kCFBooleanTrue );
CFDictionarySetValue(classes_to_match,
CFSTR(kIOMediaEjectableKey), kCFBooleanTrue);
kern_result = IOServiceGetMatchingServices( master_port,
classes_to_match, &media_iterator );
kern_result = IOServiceGetMatchingServices(master_port,
classes_to_match, &media_iterator);
if (kern_result != KERN_SUCCESS)
return( drives );
return drives;
next_media = IOIteratorNext( media_iterator );
next_media = IOIteratorNext(media_iterator);
if (next_media != 0)
{
CFTypeRef str_bsd_path;
@ -96,12 +96,12 @@ std::vector<std::string> cdio_get_devices()
do
{
str_bsd_path =
IORegistryEntryCreateCFProperty( next_media,
CFSTR( kIOBSDNameKey ), kCFAllocatorDefault,
0 );
IORegistryEntryCreateCFProperty(next_media,
CFSTR(kIOBSDNameKey), kCFAllocatorDefault,
0);
if (str_bsd_path == nullptr)
{
IOObjectRelease( next_media );
IOObjectRelease(next_media);
continue;
}
@ -120,12 +120,11 @@ std::vector<std::string> cdio_get_devices()
delete[] buf;
}
CFRelease( str_bsd_path );
IOObjectRelease( next_media );
} while (( next_media = IOIteratorNext( media_iterator ) ) != 0);
CFRelease(str_bsd_path);
IOObjectRelease(next_media);
} while ((next_media = IOIteratorNext(media_iterator)) != 0);
}
IOObjectRelease( media_iterator );
IOObjectRelease(media_iterator);
return drives;
}
#else
@ -166,11 +165,11 @@ static bool is_cdrom(const std::string& drive, char *mnttype)
{
// Check if the device exists
if (!is_device(drive))
return(false);
return false;
bool is_cd=false;
bool is_cd = false;
// If it does exist, verify that it is a cdrom/dvd drive
int cdfd = open(drive.c_str(), (O_RDONLY|O_NONBLOCK), 0);
int cdfd = open(drive.c_str(), (O_RDONLY | O_NONBLOCK), 0);
if (cdfd >= 0)
{
#ifdef __linux__
@ -179,11 +178,11 @@ static bool is_cdrom(const std::string& drive, char *mnttype)
is_cd = true;
close(cdfd);
}
return(is_cd);
return is_cd;
}
// Returns a pointer to an array of strings with the device names
std::vector<std::string> cdio_get_devices ()
std::vector<std::string> cdio_get_devices()
{
std::vector<std::string> drives;
// Scan the system for DVD/CD-ROM drives.

View File

@ -161,7 +161,7 @@ public:
}
template <typename T, std::size_t N>
void DoArray(std::array<T,N>& x)
void DoArray(std::array<T, N>& x)
{
DoArray(x.data(), (u32)x.size());
}
@ -260,8 +260,7 @@ public:
LinkedListItem<T>* next = list_cur->next;
TFree(list_cur);
list_cur = next;
}
while (list_cur);
} while (list_cur);
}
}
break;
@ -332,7 +331,7 @@ public:
template<class T>
static bool Load(const std::string& _rFilename, u32 _Revision, T& _class)
{
INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
INFO_LOG(COMMON, "ChunkReader: Loading %s", _rFilename.c_str());
if (!File::Exists(_rFilename))
return false;
@ -342,14 +341,14 @@ public:
static const u64 headerSize = sizeof(SChunkHeader);
if (fileSize < headerSize)
{
ERROR_LOG(COMMON,"ChunkReader: File too small");
ERROR_LOG(COMMON, "ChunkReader: File too small");
return false;
}
File::IOFile pFile(_rFilename, "rb");
if (!pFile)
{
ERROR_LOG(COMMON,"ChunkReader: Can't open file for reading");
ERROR_LOG(COMMON, "ChunkReader: Can't open file for reading");
return false;
}
@ -357,14 +356,14 @@ public:
SChunkHeader header;
if (!pFile.ReadArray(&header, 1))
{
ERROR_LOG(COMMON,"ChunkReader: Bad header size");
ERROR_LOG(COMMON, "ChunkReader: Bad header size");
return false;
}
// Check revision
if (header.Revision != _Revision)
{
ERROR_LOG(COMMON,"ChunkReader: Wrong file revision, got %d expected %d",
ERROR_LOG(COMMON, "ChunkReader: Wrong file revision, got %d expected %d",
header.Revision, _Revision);
return false;
}
@ -373,7 +372,7 @@ public:
const u32 sz = (u32)(fileSize - headerSize);
if (header.ExpectedSize != sz)
{
ERROR_LOG(COMMON,"ChunkReader: Bad file size, got %d expected %d",
ERROR_LOG(COMMON, "ChunkReader: Bad file size, got %d expected %d",
sz, header.ExpectedSize);
return false;
}
@ -382,7 +381,7 @@ public:
std::vector<u8> buffer(sz);
if (!pFile.ReadArray(&buffer[0], sz))
{
ERROR_LOG(COMMON,"ChunkReader: Error reading file");
ERROR_LOG(COMMON, "ChunkReader: Error reading file");
return false;
}
@ -390,7 +389,7 @@ public:
PointerWrap p(&ptr, PointerWrap::MODE_READ);
_class.DoState(p);
INFO_LOG(COMMON, "ChunkReader: Done loading %s" , _rFilename.c_str());
INFO_LOG(COMMON, "ChunkReader: Done loading %s", _rFilename.c_str());
return true;
}
@ -398,11 +397,11 @@ public:
template<class T>
static bool Save(const std::string& _rFilename, u32 _Revision, T& _class)
{
INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());
INFO_LOG(COMMON, "ChunkReader: Writing %s", _rFilename.c_str());
File::IOFile pFile(_rFilename, "wb");
if (!pFile)
{
ERROR_LOG(COMMON,"ChunkReader: Error opening file for write");
ERROR_LOG(COMMON, "ChunkReader: Error opening file for write");
return false;
}
@ -424,17 +423,17 @@ public:
// Write to file
if (!pFile.WriteArray(&header, 1))
{
ERROR_LOG(COMMON,"ChunkReader: Failed writing header");
ERROR_LOG(COMMON, "ChunkReader: Failed writing header");
return false;
}
if (!pFile.WriteArray(&buffer[0], sz))
{
ERROR_LOG(COMMON,"ChunkReader: Failed writing data");
ERROR_LOG(COMMON, "ChunkReader: Failed writing data");
return false;
}
INFO_LOG(COMMON,"ChunkReader: Done writing %s", _rFilename.c_str());
INFO_LOG(COMMON, "ChunkReader: Done writing %s", _rFilename.c_str());
return true;
}

View File

@ -83,7 +83,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
std::equal(end_match.rbegin(), end_match.rend(), found.rbegin()))
{
std::string full_name;
if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR)
if (_strPath.c_str()[_strPath.size() - 1] == DIR_SEP_CHR)
full_name = _strPath + found;
else
full_name = _strPath + DIR_SEP + found;

View File

@ -33,7 +33,7 @@ public:
~FixedSizeQueue()
{
delete [] storage;
delete[] storage;
}
void clear()

View File

@ -24,11 +24,11 @@ u32 HashFletcher(const u8* data_u8, size_t length)
size_t tlen = len > 360 ? 360 : len;
len -= tlen;
do {
do
{
sum1 += *data++;
sum2 += sum1;
}
while (--tlen);
} while (--tlen);
sum1 = (sum1 & 0xffff) + (sum1 >> 16);
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
@ -58,8 +58,7 @@ u32 HashAdler32(const u8* data, size_t len)
{
a += *data++;
b += a;
}
while (--tlen);
} while (--tlen);
a = (a & 0xffff) + (a >> 16) * (65536 - MOD_ADLER);
b = (b & 0xffff) + (b >> 16) * (65536 - MOD_ADLER);
@ -115,24 +114,24 @@ inline u64 getblock(const u64 * p, int i)
inline void bmix64(u64 & h1, u64 & h2, u64 & k1, u64 & k2, u64 & c1, u64 & c2)
{
k1 *= c1;
k1 = _rotl64(k1,23);
k1 = _rotl64(k1, 23);
k1 *= c2;
h1 ^= k1;
h1 += h2;
h2 = _rotl64(h2,41);
h2 = _rotl64(h2, 41);
k2 *= c2;
k2 = _rotl64(k2,23);
k2 = _rotl64(k2, 23);
k2 *= c1;
h2 ^= k2;
h2 += h1;
h1 = h1*3+0x52dce729;
h2 = h2*3+0x38495ab5;
h1 = h1 * 3 + 0x52dce729;
h2 = h2 * 3 + 0x38495ab5;
c1 = c1*5+0x7b7d159c;
c2 = c2*5+0x6bce6396;
c1 = c1 * 5 + 0x7b7d159c;
c2 = c2 * 5 + 0x6bce6396;
}
//----------
@ -154,9 +153,11 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
const u8 * data = (const u8*)src;
const int nblocks = len / 16;
u32 Step = (len / 8);
if (samples == 0) samples = std::max(Step, 1u);
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
if (Step < 1)
Step = 1;
u64 h1 = 0x9368e53c2f6af274;
u64 h2 = 0x586dcd208f7cd3fd;
@ -172,8 +173,8 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
for (int i = 0; i < nblocks; i+=Step)
{
u64 k1 = getblock(blocks,i*2+0);
u64 k2 = getblock(blocks,i*2+1);
u64 k1 = getblock(blocks, i*2+0);
u64 k2 = getblock(blocks, i*2+1);
bmix64(h1,h2,k1,k2,c1,c2);
}
@ -232,9 +233,11 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
if (samples == 0) samples = std::max(Step, 1u);
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
if (Step < 1)
Step = 1;
while (data < end - Step * 3)
{
h[0] = _mm_crc32_u64(h[0], data[Step * 0]);
@ -280,9 +283,11 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
if (samples == 0) samples = std::max(Step, 1u);
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
if (Step < 1)
Step = 1;
while (data < end)
{
u64 k = data[0];
@ -323,9 +328,11 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
u32 Step = (len/4);
const u32 *data = (const u32 *)src;
const u32 *end = data + Step;
if (samples == 0) samples = std::max(Step, 1u);
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
if (Step < 1)
Step = 1;
while (data < end)
{
h = _mm_crc32_u32(h, data[0]);
@ -367,24 +374,24 @@ inline u32 fmix32(u32 h)
inline void bmix32(u32 & h1, u32 & h2, u32 & k1, u32 & k2, u32 & c1, u32 & c2)
{
k1 *= c1;
k1 = _rotl(k1,11);
k1 = _rotl(k1, 11);
k1 *= c2;
h1 ^= k1;
h1 += h2;
h2 = _rotl(h2,17);
h2 = _rotl(h2, 17);
k2 *= c2;
k2 = _rotl(k2,11);
k2 = _rotl(k2, 11);
k2 *= c1;
h2 ^= k2;
h2 += h1;
h1 = h1*3+0x52dce729;
h2 = h2*3+0x38495ab5;
h1 = h1*3+0x52dce729;
h2 = h2*3+0x38495ab5;
c1 = c1*5+0x7b7d159c;
c2 = c2*5+0x6bce6396;
c1 = c1*5+0x7b7d159c;
c2 = c2*5+0x6bce6396;
}
//----------
@ -395,9 +402,11 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
u32 out[2];
const int nblocks = len / 8;
u32 Step = (len / 4);
if (samples == 0) samples = std::max(Step, 1u);
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
if (Step < 1)
Step = 1;
u32 h1 = 0x8de1c3ac;
u32 h2 = 0xbab98226;
@ -446,8 +455,8 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
h1 += h2;
h2 += h1;
h1 = fmix32(h1);
h2 = fmix32(h2);
h1 = fmix32(h1);
h2 = fmix32(h2);
h1 += h2;
h2 += h1;
@ -471,9 +480,11 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
if (samples == 0) samples = std::max(Step, 1u);
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
if (Step < 1)
Step = 1;
while (data < end)
{
u64 k = data[0];

View File

@ -63,7 +63,6 @@ public:
void Set(const std::string& key, bool newValue)
{
Set(key, StringFromBool(newValue));
}
template<typename T>

View File

@ -41,7 +41,8 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title
// Open the console window and create the window handle for GetStdHandle()
AllocConsole();
// Hide
if (Hidden) ShowWindow(GetConsoleWindow(), SW_HIDE);
if (Hidden)
ShowWindow(GetConsoleWindow(), SW_HIDE);
// Save the window handle that AllocConsole() created
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// Set the console window title
@ -133,9 +134,9 @@ void ConsoleListener::LetterSpace(int Width, int Height)
int NewScreenHeight = OldScreenHeight;
// Width
BufferWidthHeight(NewBufferWidth, OldBufferHeight, NewScreenWidth, OldScreenHeight, (NewBufferWidth > OldScreenWidth-1));
BufferWidthHeight(NewBufferWidth, OldBufferHeight, NewScreenWidth, OldScreenHeight, (NewBufferWidth > OldScreenWidth - 1));
// Height
BufferWidthHeight(NewBufferWidth, NewBufferHeight, NewScreenWidth, NewScreenHeight, (NewBufferHeight > OldScreenHeight-1));
BufferWidthHeight(NewBufferWidth, NewBufferHeight, NewScreenWidth, NewScreenHeight, (NewBufferHeight > OldScreenHeight - 1));
// Resize the window too
//MoveWindow(GetConsoleWindow(), 200,200, (Width*8 + 50),(NewScreenHeight*12 + 200), true);
@ -157,7 +158,8 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
{
#ifdef _WIN32
// Check size
if (Width < 8 || Height < 12) return;
if (Width < 8 || Height < 12)
return;
bool DBef = true;
bool DAft = true;
@ -233,10 +235,12 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
COORD Coo = GetCoordinates(OldCursor, LBufWidth);
SetConsoleCursorPosition(hConsole, Coo);
if (SLog.length() > 0) Log(LogTypes::LNOTICE, SLog.c_str());
if (SLog.length() > 0)
Log(LogTypes::LNOTICE, SLog.c_str());
// Resize the window too
if (Resize) MoveWindow(GetConsoleWindow(), Left,Top, (Width + 100),Height, true);
if (Resize)
MoveWindow(GetConsoleWindow(), Left, Top, (Width + 100), Height, true);
#endif
}
@ -328,7 +332,8 @@ void ConsoleListener::ClearScreen(bool Cursor)
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
// Reset cursor
if (Cursor) SetConsoleCursorPosition(hConsole, coordScreen);
if (Cursor)
SetConsoleCursorPosition(hConsole, coordScreen);
#endif
}

View File

@ -130,7 +130,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
char temp[MAX_MSGLEN];
LogContainer *log = m_Log[type];
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
if (!log->IsEnabled() || level > log->GetLevel() || !log->HasListeners())
return;
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);

View File

@ -109,10 +109,10 @@ void* AllocateMemoryPages(size_t size)
return ptr;
}
void* AllocateAlignedMemory(size_t size,size_t alignment)
void* AllocateAlignedMemory(size_t size, size_t alignment)
{
#ifdef _WIN32
void* ptr = _aligned_malloc(size,alignment);
void* ptr = _aligned_malloc(size, alignment);
#else
void* ptr = nullptr;
if (posix_memalign(&ptr, alignment, size) != 0)

View File

@ -74,7 +74,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
va_list args;
va_start(args, format);
CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args);
CharArrayFromFormatV(buffer, sizeof(buffer) - 1, str_translator(format).c_str(), args);
va_end(args);
ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer);

View File

@ -45,14 +45,14 @@ size_t XEmitter::ABI_PushRegistersAndAdjustStack(BitSet32 mask, size_t rsp_align
ABI_CalculateFrameSize(mask, rsp_alignment, needed_frame_size, &shadow, &subtraction, &xmm_offset);
for (int r : mask & ABI_ALL_GPRS)
PUSH((X64Reg) r);
PUSH((X64Reg)r);
if (subtraction)
SUB(64, R(RSP), subtraction >= 0x80 ? Imm32((u32)subtraction) : Imm8((u8)subtraction));
for (int x : mask & ABI_ALL_FPRS)
{
MOVAPD(MDisp(RSP, (int)xmm_offset), (X64Reg) (x - 16));
MOVAPD(MDisp(RSP, (int)xmm_offset), (X64Reg)(x - 16));
xmm_offset += 16;
}
@ -76,7 +76,7 @@ void XEmitter::ABI_PopRegistersAndAdjustStack(BitSet32 mask, size_t rsp_alignmen
for (int r = 15; r >= 0; r--)
{
if (mask[r])
POP((X64Reg) r);
POP((X64Reg)r);
}
}

View File

@ -30,7 +30,7 @@ struct ModRM
ModRM(u8 modRM, u8 rex)
{
mod = modRM >> 6;
reg = ((modRM >> 3) & 7) | ((rex & 4)?8:0);
reg = ((modRM >> 3) & 7) | ((rex & 4) ? 8 : 0);
rm = modRM & 7;
}
};

View File

@ -21,7 +21,7 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
#if defined _LP64
// Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to
// restored at the end of the asm block.
__asm__ (
__asm__(
"cpuid;"
"movl %%ebx,%1;"
: "=a" (*eax),
@ -32,7 +32,7 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
: "rbx"
);
#else
__asm__ (
__asm__(
"cpuid;"
"movl %%ebx,%1;"
: "=a" (*eax),
@ -219,7 +219,8 @@ void CPUInfo::Detect()
logical_cpu_count /= cores_x_package;
}
}
} else
}
else
{
// Use AMD's new method.
num_cores = (cpu_id[2] & 0xFF) + 1;