ICC build fixes

warning fixes
get rid of SAFE_WCSCPY and SAFE_STRCPY

This was SVN commit r7239.
This commit is contained in:
janwas 2010-01-01 15:33:07 +00:00
parent 5a53b3183a
commit 03726c0b54
24 changed files with 135 additions and 126 deletions

View File

@ -127,7 +127,7 @@ public:
copyFile(srcDAE, testDAE); copyFile(srcDAE, testDAE);
//buildArchive(); //buildArchive();
shared_ptr<u8> buf = io_Allocate(100); shared_ptr<u8> buf = io_Allocate(100);
SAFE_STRCPY((char*)buf.get(), "Test"); strcpy_s((char*)buf.get(), 5, "Test");
g_VFS->CreateFile(testDAE, buf, 4); g_VFS->CreateFile(testDAE, buf, 4);
} }
@ -189,7 +189,7 @@ public:
copyFile(srcDAE, testDAE); copyFile(srcDAE, testDAE);
shared_ptr<u8> buf = io_Allocate(100); shared_ptr<u8> buf = io_Allocate(100);
SAFE_STRCPY((char*)buf.get(), "Not valid XML"); strcpy_s((char*)buf.get(), 100, "Not valid XML");
g_VFS->CreateFile(testSkeletonDefs, buf, 13); g_VFS->CreateFile(testSkeletonDefs, buf, 13);
CModelDefPtr modeldef = meshManager->GetMesh(testDAE); CModelDefPtr modeldef = meshManager->GetMesh(testDAE);
@ -203,7 +203,7 @@ public:
copyFile(srcSkeletonDefs, testSkeletonDefs); copyFile(srcSkeletonDefs, testSkeletonDefs);
shared_ptr<u8> buf = io_Allocate(100); shared_ptr<u8> buf = io_Allocate(100);
SAFE_STRCPY((char*)buf.get(), "Not valid XML"); strcpy_s((char*)buf.get(), 100, "Not valid XML");
g_VFS->CreateFile(testDAE, buf, 13); g_VFS->CreateFile(testDAE, buf, 13);
CModelDefPtr modeldef = meshManager->GetMesh(testDAE); CModelDefPtr modeldef = meshManager->GetMesh(testDAE);

View File

@ -269,7 +269,7 @@ void CMiniMap::Draw()
m_Width = (u32)(m_CachedActualSize.right - m_CachedActualSize.left); m_Width = (u32)(m_CachedActualSize.right - m_CachedActualSize.left);
m_Height = (u32)(m_CachedActualSize.bottom - m_CachedActualSize.top); m_Height = (u32)(m_CachedActualSize.bottom - m_CachedActualSize.top);
m_MapSize = m_Terrain->GetVerticesPerSide(); m_MapSize = m_Terrain->GetVerticesPerSide();
m_TextureSize = round_up_to_pow2(m_MapSize); m_TextureSize = (GLsizei)round_up_to_pow2((size_t)m_MapSize);
m_scaleX = float(m_Width) / float(m_MapSize - 1); m_scaleX = float(m_Width) / float(m_MapSize - 1);
m_scaleY = float(m_Height) / float(m_MapSize - 1); m_scaleY = float(m_Height) / float(m_MapSize - 1);

View File

@ -108,17 +108,6 @@ switch(x % 2)
#define NODEFAULT default: UNREACHABLE #define NODEFAULT default: UNREACHABLE
/**
* equivalent to strcpy, but indicates that the programmer checked usage and
* promises it is safe.
*
* (this macro prevents actually-safe instances of the function from
* showing up in searches)
**/
#define SAFE_STRCPY str##cpy
#define SAFE_WCSCPY wcs##cpy
// generate a symbol containing the line number of the macro invocation. // generate a symbol containing the line number of the macro invocation.
// used to give a unique name (per file) to types made by cassert. // used to give a unique name (per file) to types made by cassert.
// we can't prepend __FILE__ to make it globally unique - the filename // we can't prepend __FILE__ to make it globally unique - the filename

View File

@ -75,7 +75,7 @@ void debug_wprintf_mem(const wchar_t* fmt, ...)
// write into buffer (in-place) // write into buffer (in-place)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
int len = vswprintf(debug_log_pos, charsLeft-2, fmt, args); int len = vswprintf_s(debug_log_pos, charsLeft-2, fmt, args);
va_end(args); va_end(args);
debug_log_pos += len+2; debug_log_pos += len+2;

View File

@ -36,13 +36,13 @@ ERROR_ASSOCIATE(ERR::STL_CNT_INVALID, L"Container type is known but contents are
// used in debug_stl_simplify_name. // used in debug_stl_simplify_name.
// note: strcpy is safe because replacement happens in-place and // note: wcscpy_s is safe because replacement happens in-place and
// src is longer than dst (otherwise, we wouldn't be replacing). // <what> is longer than <with> (otherwise, we wouldn't be replacing).
#define REPLACE(what, with)\ #define REPLACE(what, with)\
else if(!wcsncmp(src, (what), ARRAY_SIZE(what)-1))\ else if(!wcsncmp(src, (what), ARRAY_SIZE(what)-1))\
{\ {\
src += ARRAY_SIZE(what)-1-1; /* see preincrement rationale*/\ src += ARRAY_SIZE(what)-1-1; /* see preincrement rationale*/\
SAFE_WCSCPY(dst, (with));\ wcscpy_s(dst, ARRAY_SIZE(what), (with));\
dst += ARRAY_SIZE(with)-1;\ dst += ARRAY_SIZE(with)-1;\
} }
#define STRIP(what)\ #define STRIP(what)\

View File

@ -133,7 +133,7 @@ void NextNumberedFilename(const PIVFS& fs, const VfsPath& pathnameFormat, size_t
for(size_t i = 0; i < files.size(); i++) for(size_t i = 0; i < files.size(); i++)
{ {
int number; int number;
if(swscanf(files[i].Name().c_str(), nameFormat.c_str(), &number) == 1) if(swscanf_s(files[i].Name().c_str(), nameFormat.c_str(), &number) == 1)
maxNumber = std::max(size_t(number), maxNumber); maxNumber = std::max(size_t(number), maxNumber);
} }

View File

@ -34,7 +34,7 @@ void WriteBuffer::Append(const void* data, size_t size)
{ {
if(m_size + size > m_capacity) if(m_size + size > m_capacity)
{ {
m_capacity = round_up_to_pow2((size_t)(m_size + size)); m_capacity = round_up_to_pow2(m_size + size);
shared_ptr<u8> newData = io_Allocate(m_capacity); shared_ptr<u8> newData = io_Allocate(m_capacity);
cpu_memcpy(newData.get(), m_data.get(), m_size); cpu_memcpy(newData.get(), m_data.get(), m_size);
m_data = newData; m_data = newData;

View File

@ -174,7 +174,7 @@ bool ogl_HaveExtension(const char* ext)
bool ogl_HaveVersion(const char* desired_version) bool ogl_HaveVersion(const char* desired_version)
{ {
int desired_major, desired_minor; int desired_major, desired_minor;
if(sscanf(desired_version, "%d.%d", &desired_major, &desired_minor) != 2) if(sscanf_s(desired_version, "%d.%d", &desired_major, &desired_minor) != 2)
{ {
debug_assert(0); // invalid version string debug_assert(0); // invalid version string
return false; return false;
@ -182,7 +182,7 @@ bool ogl_HaveVersion(const char* desired_version)
int major, minor; int major, minor;
const char* version = (const char*)glGetString(GL_VERSION); const char* version = (const char*)glGetString(GL_VERSION);
if(!version || sscanf(version, "%d.%d", &major, &minor) != 2) if(!version || sscanf_s(version, "%d.%d", &major, &minor) != 2)
{ {
debug_assert(0); // GL_VERSION invalid debug_assert(0); // GL_VERSION invalid
return false; return false;

View File

@ -97,7 +97,7 @@ wchar_t* wcsdup(const wchar_t* str)
wchar_t* dst = (wchar_t*)malloc((num_chars+1)*sizeof(wchar_t)); // note: wcsdup is required to use malloc wchar_t* dst = (wchar_t*)malloc((num_chars+1)*sizeof(wchar_t)); // note: wcsdup is required to use malloc
if(!dst) if(!dst)
return 0; return 0;
SAFE_WCSCPY(dst, str); wcscpy_s(dst, num_chars, str);
return dst; return dst;
} }
#endif #endif

View File

@ -88,10 +88,10 @@ need only be renamed (e.g. _open, _stat).
// VC doesn't define str[n]casecmp // VC doesn't define str[n]casecmp
#if MSC_VERSION #if MSC_VERSION
#define strcasecmp stricmp #define strcasecmp _stricmp
#define strncasecmp strnicmp #define strncasecmp _strnicmp
#define wcscasecmp wcsicmp #define wcscasecmp _wcsicmp
#define wcsncasecmp wcsnicmp #define wcsncasecmp _wcsnicmp
#endif #endif
#if OS_MACOSX #if OS_MACOSX

View File

@ -613,7 +613,7 @@ static LibError h_free_idx(ssize_t idx, HDATA* hd)
{ {
wchar_t buf[H_STRING_LEN]; wchar_t buf[H_STRING_LEN];
if(vtbl->to_string(hd->user, buf) < 0) if(vtbl->to_string(hd->user, buf) < 0)
SAFE_WCSCPY(buf, L"(error)"); wcscpy_s(buf, ARRAY_SIZE(buf), L"(error)");
debug_printf(L"H_MGR| free %ls %ls accesses=%lu %ls\n", hd->type->name, hd->pathname.string().c_str(), (unsigned long)hd->num_derefs, buf); debug_printf(L"H_MGR| free %ls %ls accesses=%lu %ls\n", hd->type->name, hd->pathname.string().c_str(), (unsigned long)hd->num_derefs, buf);
} }
#endif #endif

View File

@ -471,81 +471,88 @@ static void ExtractDescriptors(u32 reg, std::vector<u8>& descriptors)
} }
} }
static void DecodeDescriptor(u8 descriptor) // note: the following cannot reside in DecodeDescriptor because
// ARRAY_SIZE's template argument must not reference a local type.
enum Flags
{ {
enum Flags // type (unified := neither bit set)
{ I = 0x01,
// type (unified := neither bit set) D = 0x02,
I = 0x01,
D = 0x02,
// level // level
L2 = 0x04, L2 = 0x04,
// size
S4K = 0x08,
S4M = 0x10,
S2M = 0x20
};
struct Properties
{
int flags; // pageSize, type, level
u8 descriptor;
u8 associativity;
u16 entries;
};
static const u8 F = x86_x64_fullyAssociative;
// size
S4K = 0x08,
S4M = 0x10,
S2M = 0x20
};
struct Properties
{
int flags; // pageSize, type, level
u8 descriptor;
u8 associativity;
u16 entries;
};
const u8 F = x86_x64_fullyAssociative;
#define PROPERTIES(descriptor, flags, assoc, entries) { flags, descriptor, assoc, entries } #define PROPERTIES(descriptor, flags, assoc, entries) { flags, descriptor, assoc, entries }
// references: [accessed 2009-01-05]
// AP485 http://download.intel.com/design/processor/applnots/241618033.pdf // references: [accessed 2009-01-05]
// sandp http://www.sandpile.org/ia32/cpuid.htm // AP485 http://download.intel.com/design/processor/applnots/241618033.pdf
// opsol http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/i86pc/os/cpuid.c // sandp http://www.sandpile.org/ia32/cpuid.htm
static const Properties propertyTable[] = // opsol http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/i86pc/os/cpuid.c
{ static const Properties propertyTable[] =
PROPERTIES(0x01, I|S4K, 4, 32), {
PROPERTIES(0x02, I|S4M, F, 2), PROPERTIES(0x01, I|S4K, 4, 32),
PROPERTIES(0x03, D|S4K, 4, 64), PROPERTIES(0x02, I|S4M, F, 2),
PROPERTIES(0x04, D|S4M, 4, 8), PROPERTIES(0x03, D|S4K, 4, 64),
PROPERTIES(0x05, D|S4M, 4, 32), PROPERTIES(0x04, D|S4M, 4, 8),
PROPERTIES(0x0B, I|S4M, 4, 4), PROPERTIES(0x05, D|S4M, 4, 32),
PROPERTIES(0x4F, I|S4K, F, 32), // sandp: unknown assoc, opsol: full, AP485: unmentioned PROPERTIES(0x0B, I|S4M, 4, 4),
PROPERTIES(0x50, I|S4K, F, 64), PROPERTIES(0x4F, I|S4K, F, 32), // sandp: unknown assoc, opsol: full, AP485: unmentioned
PROPERTIES(0x50, I|S4M, F, 64), PROPERTIES(0x50, I|S4K, F, 64),
PROPERTIES(0x50, I|S2M, F, 64), PROPERTIES(0x50, I|S4M, F, 64),
PROPERTIES(0x51, I|S4K, F, 128), PROPERTIES(0x50, I|S2M, F, 64),
PROPERTIES(0x51, I|S4M, F, 128), PROPERTIES(0x51, I|S4K, F, 128),
PROPERTIES(0x51, I|S2M, F, 128), PROPERTIES(0x51, I|S4M, F, 128),
PROPERTIES(0x52, I|S4K, F, 256), PROPERTIES(0x51, I|S2M, F, 128),
PROPERTIES(0x52, I|S4M, F, 256), PROPERTIES(0x52, I|S4K, F, 256),
PROPERTIES(0x52, I|S2M, F, 256), PROPERTIES(0x52, I|S4M, F, 256),
PROPERTIES(0x55, I|S4M, F, 7), PROPERTIES(0x52, I|S2M, F, 256),
PROPERTIES(0x55, I|S2M, F, 7), PROPERTIES(0x55, I|S4M, F, 7),
PROPERTIES(0x56, D|S4M, 4, 16), PROPERTIES(0x55, I|S2M, F, 7),
PROPERTIES(0x57, D|S4K, 4, 16), PROPERTIES(0x56, D|S4M, 4, 16),
PROPERTIES(0x59, D|S4K, F, 16), PROPERTIES(0x57, D|S4K, 4, 16),
PROPERTIES(0x5A, D|S4M, 4, 32), PROPERTIES(0x59, D|S4K, F, 16),
PROPERTIES(0x5A, D|S2M, 4, 32), PROPERTIES(0x5A, D|S4M, 4, 32),
PROPERTIES(0x5B, D|S4K, F, 64), PROPERTIES(0x5A, D|S2M, 4, 32),
PROPERTIES(0x5B, D|S4M, F, 64), PROPERTIES(0x5B, D|S4K, F, 64),
PROPERTIES(0x5C, D|S4K, F, 128), PROPERTIES(0x5B, D|S4M, F, 64),
PROPERTIES(0x5C, D|S4M, F, 128), PROPERTIES(0x5C, D|S4K, F, 128),
PROPERTIES(0x5D, D|S4K, F, 256), PROPERTIES(0x5C, D|S4M, F, 128),
PROPERTIES(0x5D, D|S4M, F, 256), PROPERTIES(0x5D, D|S4K, F, 256),
PROPERTIES(0xB0, I|S4K, 4, 128), PROPERTIES(0x5D, D|S4M, F, 256),
PROPERTIES(0xB1, I|S2M, 4, 8), PROPERTIES(0xB0, I|S4K, 4, 128),
PROPERTIES(0xB1, I|S4M, 4, 4), PROPERTIES(0xB1, I|S2M, 4, 8),
PROPERTIES(0xB2, I|S4K, 4, 64), PROPERTIES(0xB1, I|S4M, 4, 4),
PROPERTIES(0xB3, D|S4K, 4, 128), PROPERTIES(0xB2, I|S4K, 4, 64),
PROPERTIES(0xB3, D|S4M, 4, 128), PROPERTIES(0xB3, D|S4K, 4, 128),
PROPERTIES(0xB4, D|S4K, 4, 256), PROPERTIES(0xB3, D|S4M, 4, 128),
PROPERTIES(0xB4, D|S4M, 4, 256), PROPERTIES(0xB4, D|S4K, 4, 256),
PROPERTIES(0xBA, D|S4K, 4, 64), PROPERTIES(0xB4, D|S4M, 4, 256),
PROPERTIES(0xC0, D|S4K, 4, 8), PROPERTIES(0xBA, D|S4K, 4, 64),
PROPERTIES(0xC0, D|S4M, 4, 8), PROPERTIES(0xC0, D|S4K, 4, 8),
PROPERTIES(0xCA, S4K|L2, 4, 512), PROPERTIES(0xC0, D|S4M, 4, 8),
}; PROPERTIES(0xCA, S4K|L2, 4, 512),
};
#undef PROPERTIES #undef PROPERTIES
static void DecodeDescriptor(u8 descriptor)
{
// note: we can't use bsearch because propertyTable may contain multiple // note: we can't use bsearch because propertyTable may contain multiple
// entries with the same descriptor key. // entries with the same descriptor key.
for(size_t i = 0; i < ARRAY_SIZE(propertyTable); i++) for(size_t i = 0; i < ARRAY_SIZE(propertyTable); i++)

View File

@ -32,7 +32,7 @@ static LibError SetClipboardText(const wchar_t* text, HGLOBAL* hMem)
wchar_t* lockedText = (wchar_t*)GlobalLock(*hMem); wchar_t* lockedText = (wchar_t*)GlobalLock(*hMem);
if(!lockedText) if(!lockedText)
WARN_RETURN(ERR::NO_MEM); WARN_RETURN(ERR::NO_MEM);
SAFE_WCSCPY(lockedText, text); wcscpy_s(lockedText, len, text);
GlobalUnlock(*hMem); GlobalUnlock(*hMem);
HANDLE hData = SetClipboardData(CF_UNICODETEXT, *hMem); HANDLE hData = SetClipboardData(CF_UNICODETEXT, *hMem);
@ -73,13 +73,13 @@ static wchar_t* CopyClipboardContents()
if(!hMem) if(!hMem)
return 0; return 0;
wchar_t* lockedText = (wchar_t*)GlobalLock(hMem); const wchar_t* lockedText = (const wchar_t*)GlobalLock(hMem);
if(!lockedText) if(!lockedText)
return 0; return 0;
const SIZE_T size = GlobalSize(hMem); const size_t numChars = GlobalSize(hMem)/sizeof(wchar_t) - 1;
wchar_t* text = new wchar_t[size+1]; wchar_t* text = new wchar_t[numChars+1];
SAFE_WCSCPY(text, lockedText); wcscpy_s(text, numChars+1, lockedText);
GlobalUnlock(hMem); GlobalUnlock(hMem);

View File

@ -511,7 +511,7 @@ static void out(const wchar_t* fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
int len = vswprintf(out_pos, out_chars_left, fmt, args); int len = vswprintf_s(out_pos, out_chars_left, fmt, args);
va_end(args); va_end(args);
// success // success
@ -545,7 +545,7 @@ static void out(const wchar_t* fmt, ...)
// we'll just put the warning before out_pos and eat into the // we'll just put the warning before out_pos and eat into the
// second newest text. // second newest text.
const wchar_t text[] = L"(no more room in buffer)"; const wchar_t text[] = L"(no more room in buffer)";
wcscpy(out_pos-ARRAY_SIZE(text), text); // safe wcscpy_s(out_pos-ARRAY_SIZE(text), ARRAY_SIZE(text), text); // safe
} }
} }
} }

View File

@ -22,7 +22,13 @@
#include "precompiled.h" #include "precompiled.h"
#include "hpet.h" #include "hpet.h"
#include <emmintrin.h> // for atomic 64-bit read/write // for atomic 64-bit read/write:
#define HAVE_X64_MOVD ARCH_AMD64 && (ICC_VERSION || MSC_VERSION >= 1500)
#if HAVE_X64_MOVD
# include <intrin.h>
#else
# include <emmintrin.h>
#endif
#include "counter.h" #include "counter.h"
@ -163,8 +169,6 @@ private:
return INFO::OK; return INFO::OK;
} }
#define HAVE_X64_MOVD ARCH_AMD64 && (ICC_VERSION || MSC_VERSION >= 1500)
// note: this is atomic even on 32-bit CPUs (Pentium MMX and // note: this is atomic even on 32-bit CPUs (Pentium MMX and
// above have a 64-bit data bus and MOVQ instruction) // above have a 64-bit data bus and MOVQ instruction)
u64 Read64(size_t offset) const u64 Read64(size_t offset) const

View File

@ -172,7 +172,7 @@ static bool IsAioPossible(int fd, bool is_com_port, int oflag)
int sys_wopen(const wchar_t* pathname, int oflag, ...) int sys_wopen(const wchar_t* pathname, int oflag, ...)
{ {
mode_t mode = 0; mode_t mode = _S_IREAD|_S_IWRITE;
if(oflag & O_CREAT) if(oflag & O_CREAT)
{ {
va_list args; va_list args;
@ -181,8 +181,15 @@ int sys_wopen(const wchar_t* pathname, int oflag, ...)
va_end(args); va_end(args);
} }
WinScopedPreserveLastError s; // _wopen's CreateFileW WinScopedPreserveLastError s; // _wsopen_s's CreateFileW
int fd = _wopen(pathname, oflag, mode); int fd;
errno_t ret = _wsopen_s(&fd, pathname, oflag, _SH_DENYNO, mode);
if(ret != 0)
{
errno = ret;
WARN_ERR(LibError_from_errno());
return -1;
}
// if possible, re-open the file for aio (this works because // if possible, re-open the file for aio (this works because
// the initial _wopen defaults to DENY_NONE sharing) // the initial _wopen defaults to DENY_NONE sharing)

View File

@ -35,7 +35,7 @@ int uname(struct utsname* un)
// release info // release info
const char* vs = vi.szCSDVersion; const char* vs = vi.szCSDVersion;
int sp; int sp;
if(sscanf(vs, "Service Pack %d", &sp) == 1) if(sscanf_s(vs, "Service Pack %d", &sp) == 1)
sprintf_s(un->release, ARRAY_SIZE(un->release), "SP %d", sp); sprintf_s(un->release, ARRAY_SIZE(un->release), "SP %d", sp);
// version // version

View File

@ -817,7 +817,7 @@ static void mouse_update()
active_change_state(LOSE, SDL_APPMOUSEFOCUS); active_change_state(LOSE, SDL_APPMOUSEFOCUS);
} }
static size_t mouse_buttons; static unsigned mouse_buttons;
// (we define a new function signature since the windowsx.h message crackers // (we define a new function signature since the windowsx.h message crackers
// don't provide for passing uMsg) // don't provide for passing uMsg)
@ -1256,7 +1256,9 @@ static LibError wsdl_Init()
// to avoid the OS opening a console on startup (ugly). that means // to avoid the OS opening a console on startup (ugly). that means
// stdout isn't associated with a lowio handle; _close ends up // stdout isn't associated with a lowio handle; _close ends up
// getting called with fd = -1. oh well, nothing we can do. // getting called with fd = -1. oh well, nothing we can do.
FILE* f = _wfreopen(path.string().c_str(), L"wt", stdout); FILE* f = 0;
errno_t ret = _wfreopen_s(&f, path.string().c_str(), L"wt", stdout);
debug_assert(ret == 0);
debug_assert(f); debug_assert(f);
#if CONFIG_PARANOIA #if CONFIG_PARANOIA

View File

@ -172,7 +172,7 @@ enum SDL_MouseButtonEvent_button
SDL_BUTTON_WHEELDOWN = 5 SDL_BUTTON_WHEELDOWN = 5
}; };
#define SDL_BUTTON(b) (SDL_PRESSED << (b-1)) #define SDL_BUTTON(b) (1u << (b-1))
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)

View File

@ -40,7 +40,7 @@ void snd_detect()
#else #else
// At least reset the values for unhandled platforms. // At least reset the values for unhandled platforms.
debug_assert(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8); // protect strcpy debug_assert(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8); // protect strcpy
SAFE_WCSCPY(snd_card, L"Unknown"); wcscpy_s(snd_card, ARRAY_SIZE(snd_card), L"Unknown");
SAFE_WCSCPY(snd_drv_ver, L"Unknown"); wcscpy_s(snd_drv_ver, ARRAY_SIZE(snd_drv_ver), L"Unknown");
#endif #endif
} }

View File

@ -178,7 +178,7 @@ void CLogger::Log(ELogMethod method, const wchar_t* UNUSED(category), const wcha
if (sys_vswprintf(buffer, ARRAY_SIZE(buffer), fmt, argp) == -1) if (sys_vswprintf(buffer, ARRAY_SIZE(buffer), fmt, argp) == -1)
{ {
// Buffer too small - ensure the string is nicely terminated // Buffer too small - ensure the string is nicely terminated
SAFE_WCSCPY(buffer+ARRAY_SIZE(buffer)-4, L"..."); wcscpy_s(buffer+ARRAY_SIZE(buffer)-4, 4, L"...");
} }
va_end(argp); va_end(argp);
@ -195,7 +195,7 @@ void CLogger::LogOnce(ELogMethod method, const wchar_t* UNUSED(category), const
if (sys_vswprintf(buffer, ARRAY_SIZE(buffer), fmt, argp) == -1) if (sys_vswprintf(buffer, ARRAY_SIZE(buffer), fmt, argp) == -1)
{ {
// Buffer too small - ensure the string is nicely terminated // Buffer too small - ensure the string is nicely terminated
SAFE_WCSCPY(buffer+ARRAY_SIZE(buffer)-4, L"..."); wcscpy_s(buffer+ARRAY_SIZE(buffer)-4, 4, L"...");
} }
va_end(argp); va_end(argp);
@ -219,7 +219,7 @@ void CLogger::LogMessage(const wchar_t* fmt, ...)
if (sys_vswprintf(buffer, sizeof(buffer), fmt, argp) == -1) if (sys_vswprintf(buffer, sizeof(buffer), fmt, argp) == -1)
{ {
// Buffer too small - ensure the string is nicely terminated // Buffer too small - ensure the string is nicely terminated
SAFE_WCSCPY(buffer+ARRAY_SIZE(buffer)-4, L"..."); wcscpy_s(buffer+ARRAY_SIZE(buffer)-4, 4, L"...");
} }
va_end(argp); va_end(argp);
@ -235,7 +235,7 @@ void CLogger::LogWarning(const wchar_t* fmt, ...)
if (sys_vswprintf(buffer, sizeof(buffer), fmt, argp) == -1) if (sys_vswprintf(buffer, sizeof(buffer), fmt, argp) == -1)
{ {
// Buffer too small - ensure the string is nicely terminated // Buffer too small - ensure the string is nicely terminated
SAFE_WCSCPY(buffer+ARRAY_SIZE(buffer)-4, L"..."); wcscpy_s(buffer+ARRAY_SIZE(buffer)-4, 4, L"...");
} }
va_end(argp); va_end(argp);
@ -251,7 +251,7 @@ void CLogger::LogError(const wchar_t* fmt, ...)
if (sys_vswprintf(buffer, sizeof(buffer), fmt, argp) == -1) if (sys_vswprintf(buffer, sizeof(buffer), fmt, argp) == -1)
{ {
// Buffer too small - ensure the string is nicely terminated // Buffer too small - ensure the string is nicely terminated
SAFE_WCSCPY(buffer+ARRAY_SIZE(buffer)-4, L"..."); wcscpy_s(buffer+ARRAY_SIZE(buffer)-4, 4, L"...");
} }
va_end(argp); va_end(argp);

View File

@ -89,7 +89,7 @@ namespace ConfigNamespace_JS
void SetNamespace(JSContext *cx, JSObject *obj, EConfigNamespace cfgNs) void SetNamespace(JSContext *cx, JSObject *obj, EConfigNamespace cfgNs)
{ {
JS_SetPrivate(cx, obj, (void *)((int)cfgNs << 1)); // JS requires bottom bit = 0 JS_SetPrivate(cx, obj, (void *)((uintptr_t)cfgNs << 1)); // JS requires bottom bit = 0
} }
JSBool WriteFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) JSBool WriteFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )

View File

@ -299,8 +299,8 @@ void ShadowMapInternals::CreateTexture()
else else
{ {
// get shadow map size as next power of two up from view width and height // get shadow map size as next power of two up from view width and height
Width = round_up_to_pow2(g_Renderer.GetWidth()); Width = (int)round_up_to_pow2((unsigned)g_Renderer.GetWidth());
Height = round_up_to_pow2(g_Renderer.GetHeight()); Height = (int)round_up_to_pow2((unsigned)g_Renderer.GetHeight());
} }
// Clamp to the maximum texture size // Clamp to the maximum texture size
Width = std::min(Width, (int)ogl_max_tex_size); Width = std::min(Width, (int)ogl_max_tex_size);

View File

@ -143,7 +143,7 @@ int WaterManager::LoadWaterTextures()
// the reflection/reflaction images will fit within the window // the reflection/reflaction images will fit within the window
// (alternative: use FBO's, which can have arbitrary size - but do we need // (alternative: use FBO's, which can have arbitrary size - but do we need
// the reflection/refraction textures to be that large?) // the reflection/refraction textures to be that large?)
int size = round_up_to_pow2(g_Renderer.GetHeight()); int size = (int)round_up_to_pow2((unsigned)g_Renderer.GetHeight());
if(size > g_Renderer.GetHeight()) size /= 2; if(size > g_Renderer.GetHeight()) size /= 2;
m_ReflectionTextureSize = size; m_ReflectionTextureSize = size;
m_RefractionTextureSize = size; m_RefractionTextureSize = size;