Skip to content

Commit

Permalink
xrCore: Fix extra warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Jan 15, 2016
1 parent d9f3f3e commit bece46e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/xrCore/Crypto/xr_dsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ void xr_dsa::generate_params()
string256 random_string;
xr_sprintf (random_string, "%I64d_%s", CPU::QPC(), rnd_seed);
//sprintf_s (random_string, "%s", rnd_seed);
unsigned char* rnd_seed = static_cast<unsigned char*>((void*)random_string);
unsigned char* seed = static_cast<unsigned char*>((void*)random_string);
unsigned int rnd_ssize = xr_strlen(random_string);
DSA* tmp_dsa_params = DSA_generate_parameters(
key_bit_length,
rnd_seed,
seed,
rnd_ssize,
&counter,
&long_ret,
Expand Down
3 changes: 3 additions & 0 deletions src/xrCore/Debug/MiniDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ Copyright (c) 1997-2001 John Robbins -- All rights reserved.
----------------------------------------------------------------------*/

#include "stdafx.h"
#pragma warning(push)
#pragma warning(disable:4091) // 'typedef ': ignored on left of '' when no variable is declared
#include "MiniDump.h"
#include "StackTrace.h"
#pragma warning(pop)
#include <process.h>

// The structure I can package the data necessary to the dump writer thread.
Expand Down
3 changes: 3 additions & 0 deletions src/xrCore/Debug/StackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ Copyright (c) 1997-2000 John Robbins -- All rights reserved.
----------------------------------------------------------------------*/

#include "stdafx.h"
#pragma warning(push)
#pragma warning(disable:4091) // 'typedef ': ignored on left of '' when no variable is declared
#include "StackTrace.h"
#include "SymbolEngine.h"
#include "MiniDump.h"
#pragma warning(pop)
#include <psapi.h>
#pragma comment(lib, "psapi.lib")

Expand Down
15 changes: 6 additions & 9 deletions src/xrCore/LzHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ char wterr[] = "Can't write.";
u8 text_buf[N + F];
int match_position, match_length, lson[N + 1], rson[N + 257], dad[N + 1];

unsigned code, len;
unsigned tim_size = 0;

unsigned freq[T + 1]; /* frequency table */

int prnt[T + N_CHAR + 1]; /* pointers to parent nodes, except for the */
Expand Down Expand Up @@ -531,8 +528,6 @@ void EncodeChar(unsigned c)
k = prnt[k];
} while (k != R);
fs.PutCode(j, i);
code = i;
len = j;
update(c);
}

Expand Down Expand Up @@ -588,7 +583,7 @@ int DecodePosition(void)
/* compression */
void Encode(void) /* compression */
{
int i, c, len, r, s, last_match_length;
int i, c, r, s, last_match_length;

textsize = fs.InputSize();
fs.Init_Output(textsize);
Expand All @@ -605,8 +600,12 @@ void Encode(void) /* compression */
r = N - F;
for (i = s; i < r; i++)
text_buf[i] = 0x20;
for (len = 0; len < F && (c = fs._getb()) != EOF; len++)
int len = 0;
while (len < F && (c = fs._getb()) != EOF)
{
text_buf[r + len] = (unsigned char)c;
len++;
}
textsize = len;
for (i = 1; i <= F; i++)
InsertNode(r - i);
Expand Down Expand Up @@ -648,7 +647,6 @@ void Encode(void) /* compression */
}
} while (len > 0);
fs.PutFlush();
tim_size = textsize;
}

void Decode(void) /* recover */
Expand Down Expand Up @@ -692,7 +690,6 @@ void Decode(void) /* recover */
}
}
}
tim_size = count;
}

unsigned _writeLZ(int hf, void* d, unsigned size)
Expand Down
10 changes: 5 additions & 5 deletions src/xrCore/Threading/ttapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ int ttapi_Init(const _processor_info &pi)
// System Info
ttapi_worker_count = pi.n_cores;
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
DWORD i, dwNumIter;
DWORD dwNumIter;
volatile DWORD dwDummy = 1;
LARGE_INTEGER liFrequency, liStart, liEnd;
QueryPerformanceFrequency(&liFrequency);
// Get fast spin-loop timings
dwNumIter = 100000000;
QueryPerformanceCounter(&liStart);
for (i = 0; i < dwNumIter; ++i)
for (DWORD i = 0; i < dwNumIter; ++i)
{
if (!dwDummy)
goto process1;
Expand All @@ -128,11 +128,11 @@ int ttapi_Init(const _processor_info &pi)
process1:
QueryPerformanceCounter(&liEnd);
// We want 1/25 (40ms) fast spin-loop
ttapi_dwFastIter = (dwNumIter * liFrequency.QuadPart) / ((liEnd.QuadPart - liStart.QuadPart) * 25);
ttapi_dwFastIter = DWORD((dwNumIter * liFrequency.QuadPart) / ((liEnd.QuadPart - liStart.QuadPart) * 25));
// Get slow spin-loop timings
dwNumIter = 10000000;
QueryPerformanceCounter(&liStart);
for (i = 0; i < dwNumIter; ++i)
for (DWORD i = 0; i < dwNumIter; ++i)
{
if (!dwDummy)
goto process2;
Expand All @@ -141,7 +141,7 @@ int ttapi_Init(const _processor_info &pi)
process2:
QueryPerformanceCounter(&liEnd);
// We want 1/2 (500ms) slow spin-loop
ttapi_dwSlowIter = (dwNumIter * liFrequency.QuadPart) / ((liEnd.QuadPart - liStart.QuadPart) * 2);
ttapi_dwSlowIter = DWORD((dwNumIter * liFrequency.QuadPart) / ((liEnd.QuadPart - liStart.QuadPart) * 2));
SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
// Check for override from command line
char szSearchFor[] = "-max-threads";
Expand Down
4 changes: 2 additions & 2 deletions src/xrCore/memory_allocation_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ __declspec(noinline) void save_stack_trace()
size_t frameCount = StackTrace.Count-skipFrames;
size_t totalSize = 0;
auto lengths = (size_t *)_alloca(frameCount*sizeof(size_t));
for (int i = 0; i<frameCount; i++)
for (size_t i = 0; i<frameCount; i++)
{
lengths[i] = strlen(StackTrace[i+skipFrames]);
totalSize += lengths[i]+1;
}
char *stackTrace = (char *)malloc(totalSize);
{
char *ptr = stackTrace;
for (int i = 0; i<frameCount; i++)
for (size_t i = 0; i<frameCount; i++)
{
memcpy(ptr, StackTrace[i], lengths[i]);
ptr += lengths[i];
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/xrDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void xrDebug::FormatLastError(char *buffer, const size_t &bufferSize)
0,
nullptr);
// XXX nitrocaster: check buffer overflow
sprintf(buffer, "[error][%8d]: %s", lastErr, msg);
sprintf(buffer, "[error][%8d]: %s", lastErr, (char *)msg);
LocalFree(msg);
}

Expand Down
4 changes: 2 additions & 2 deletions src/xrCore/xrMemory_subst_msvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ void* xrMemory::mem_realloc(void* P, size_t size)
debug_cs.Enter();
#endif
u32 p_current = get_header(P);
u32 p_new = get_pool(1 + size + (debug_mode ? 4 : 0));
u32 newPool = get_pool(1 + size + (debug_mode ? 4 : 0));
u32 p_mode;
if (mem_generic==p_current)
{
if (p_new < p_current)
if (newPool < p_current)
p_mode = 2;
else
p_mode = 0;
Expand Down

0 comments on commit bece46e

Please sign in to comment.