diff --git a/source/collada/CommonConvert.cpp b/source/collada/CommonConvert.cpp index 46b5c094d4..9ef77fe210 100644 --- a/source/collada/CommonConvert.cpp +++ b/source/collada/CommonConvert.cpp @@ -35,7 +35,7 @@ void require_(int line, bool value, const char* type, const char* message) { if (value) return; char linestr[16]; - sprintf(linestr, "%d", line); + sprintf_s(linestr, sizeof(linestr)/sizeof(linestr[0]), "%d", line); throw ColladaException(std::string(type) + " (line " + linestr + "): " + message); } @@ -79,9 +79,9 @@ void FColladaErrorHandler::OnError(FUError::Level errorLevel, uint32 errorCode, errorString = "Unknown error code"; if (errorLevel == FUError::DEBUG_LEVEL) - Log(LOG_INFO, "FCollada message %d: %hs", errorCode, errorString); + Log(LOG_INFO, "FCollada message %d: %s", errorCode, errorString); else if (errorLevel == FUError::WARNING_LEVEL) - Log(LOG_WARNING, "FCollada warning %d: %hs", errorCode, errorString); + Log(LOG_WARNING, "FCollada warning %d: %s", errorCode, errorString); else throw ColladaException(errorString); } @@ -97,7 +97,7 @@ void FColladaDocument::LoadFromText(const char *text) size_t newTextSize = 0; FixBrokenXML(text, &newText, &newTextSize); - // Log(LOG_INFO, "%hs", newText); + // Log(LOG_INFO, "%s", newText); bool status = FCollada::LoadDocumentFromMemory("unknown.dae", document.get(), (void*)newText, newTextSize); if (newText != text) @@ -143,7 +143,7 @@ CommonConvert::CommonConvert(const char* text, std::string& xmlErrors) throw ColladaException("Couldn't find object to convert"); assert(m_Instance); - Log(LOG_INFO, "Converting '%hs'", m_Instance->GetEntity()->GetName().c_str()); + Log(LOG_INFO, "Converting '%s'", m_Instance->GetEntity()->GetName().c_str()); m_IsXSI = false; FCDAsset* asset = m_Doc.GetDocument()->GetAsset(); @@ -254,7 +254,7 @@ static void FindInstances(FCDSceneNode* node, std::vector& instan f.transform = transform * node->ToMatrix(); f.instance = node->GetInstance(i); instances.push_back(f); - Log(LOG_INFO, "Found convertible object '%hs'", node->GetName().c_str()); + Log(LOG_INFO, "Found convertible object '%s'", node->GetName().c_str()); } } diff --git a/source/collada/DLL.cpp b/source/collada/DLL.cpp index 941de8bd38..2576fa12a1 100644 --- a/source/collada/DLL.cpp +++ b/source/collada/DLL.cpp @@ -27,7 +27,7 @@ void default_logger(int severity, const char* message) { - fprintf(stderr, "[%d] %hs\n", severity, message); + fprintf(stderr, "[%d] %s\n", severity, message); } static LogFn g_Logger = &default_logger; @@ -111,9 +111,9 @@ int convert_dae_to_whatever(const char* dae, OutputFn writer, void* cb_data, voi catch (const ColladaException& e) { if (! xmlErrors.empty()) - Log(LOG_ERROR, "%hs", xmlErrors.c_str()); + Log(LOG_ERROR, "%s", xmlErrors.c_str()); - Log(LOG_ERROR, "%hs", e.what()); + Log(LOG_ERROR, "%s", e.what()); FCollada::Release(); @@ -124,7 +124,7 @@ int convert_dae_to_whatever(const char* dae, OutputFn writer, void* cb_data, voi if (! xmlErrors.empty()) { - Log(LOG_ERROR, "%hs", xmlErrors.c_str()); + Log(LOG_ERROR, "%s", xmlErrors.c_str()); return -1; } @@ -152,9 +152,9 @@ EXPORT int set_skeleton_definitions(const char* xml, int length) catch (const ColladaException& e) { if (! xmlErrors.empty()) - Log(LOG_ERROR, "%hs", xmlErrors.c_str()); + Log(LOG_ERROR, "%s", xmlErrors.c_str()); - Log(LOG_ERROR, "%hs", e.what()); + Log(LOG_ERROR, "%s", e.what()); return -1; } diff --git a/source/collada/PMDConvert.cpp b/source/collada/PMDConvert.cpp index 9c7b240996..99b37f8aa1 100644 --- a/source/collada/PMDConvert.cpp +++ b/source/collada/PMDConvert.cpp @@ -152,9 +152,9 @@ public: Log(LOG_WARNING, "Mismatched bone counts (skin has %d, skeleton has %d)", skin->GetJointCount(), controllerInstance.GetJointCount()); for (size_t i = 0; i < skin->GetJointCount(); ++i) - Log(LOG_INFO, "Skin joint %d: %hs", i, skin->GetJoint(i)->GetId().c_str()); + Log(LOG_INFO, "Skin joint %d: %s", i, skin->GetJoint(i)->GetId().c_str()); for (size_t i = 0; i < controllerInstance.GetJointCount(); ++i) - Log(LOG_INFO, "Skeleton joint %d: %hs", i, controllerInstance.GetJoint(i)->GetName().c_str()); + Log(LOG_INFO, "Skeleton joint %d: %s", i, controllerInstance.GetJoint(i)->GetName().c_str()); } // Get the skinned mesh for this entity @@ -212,7 +212,7 @@ public: { // The relevant joint does exist, but it's not a recognised // bone in our chosen skeleton structure - Log(LOG_ERROR, "Vertex influenced by unrecognised bone '%hs'", joint->GetName().c_str()); + Log(LOG_ERROR, "Vertex influenced by unrecognised bone '%s'", joint->GetName().c_str()); continue; } @@ -287,7 +287,7 @@ public: // Strip off the "prop-" from the name std::string propPointName (child->GetName().substr(5)); - Log(LOG_INFO, "Adding prop point %hs", propPointName.c_str()); + Log(LOG_INFO, "Adding prop point %s", propPointName.c_str()); // Get translation and orientation of local transform diff --git a/source/collada/XMLFix.cpp b/source/collada/XMLFix.cpp index 419524c008..2f1d67770e 100644 --- a/source/collada/XMLFix.cpp +++ b/source/collada/XMLFix.cpp @@ -154,7 +154,7 @@ static bool processDocument(xmlNode* root) if (! authoring_tool_text) return false; if (authoring_tool_text->type != XML_TEXT_NODE) return false; xmlChar* toolname = authoring_tool_text->content; - Log(LOG_INFO, "Authoring tool: %hs", toolname); + Log(LOG_INFO, "Authoring tool: %s", toolname); if (strcmp((const char*)toolname, "FBX COLLADA exporter") == 0) return applyFBXFixes(root); else diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index e45a57f17c..29803cd746 100644 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -448,7 +448,7 @@ void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGU // Generate a unique name static int x=0; char buf[64]; - sprintf(buf, "__eventhandler%d", x++); + sprintf_s(buf, ARRAY_SIZE(buf), "__eventhandler%d", x++); JSFunction* func = JS_CompileFunction(g_ScriptingHost.getContext(), pGUI->m_ScriptObject, buf, paramCount, paramNames, (const char*)Code, Code.length(), CodeName, 0); @@ -511,7 +511,7 @@ void IGUIObject::ScriptEvent(const CStr& Action) JSBool ok = JS_CallFunctionValue(g_ScriptingHost.getContext(), jsGuiObject, OBJECT_TO_JSVAL(*it->second), 1, paramData, &result); if (!ok) { - JS_ReportError(g_ScriptingHost.getContext(), "Errors executing script action \"%hs\"", Action.c_str()); + JS_ReportError(g_ScriptingHost.getContext(), "Errors executing script action \"%s\"", Action.c_str()); } // Allow the temporary parameters to be garbage-collected diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index af4afef4e5..2227c6ae86 100644 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -111,7 +111,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval EGUISettingType Type; if (e->GetSettingType(propName, Type) != PSRETURN_OK) { - JS_ReportError(cx, "Invalid GUIObject property '%hs'", propName.c_str()); + JS_ReportError(cx, "Invalid GUIObject property '%s'", propName.c_str()); return JS_FALSE; } @@ -273,7 +273,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval } default: - JS_ReportError(cx, "Setting '%hs' uses an unimplemented type", propName.c_str()); + JS_ReportError(cx, "Setting '%s' uses an unimplemented type", propName.c_str()); debug_assert(0); return JS_FALSE; } @@ -313,7 +313,7 @@ JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval EGUISettingType Type; if (e->GetSettingType(propName, Type) != PSRETURN_OK) { - JS_ReportError(cx, "Invalid setting '%hs'", propName.c_str()); + JS_ReportError(cx, "Invalid setting '%s'", propName.c_str()); return JS_TRUE; } @@ -429,7 +429,7 @@ JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval { if (e->SetSetting(propName, JS_GetStringBytes(JS_ValueToString(cx, *vp))) != PSRETURN_OK) { - JS_ReportError(cx, "Invalid value for setting '%hs'", propName.c_str()); + JS_ReportError(cx, "Invalid value for setting '%s'", propName.c_str()); return JS_FALSE; } } @@ -466,7 +466,7 @@ JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval { if (e->SetSetting(propName, JS_GetStringBytes(JS_ValueToString(cx, *vp))) != PSRETURN_OK) { - JS_ReportError(cx, "Invalid value for setting '%hs'", propName.c_str()); + JS_ReportError(cx, "Invalid value for setting '%s'", propName.c_str()); return JS_FALSE; } } @@ -531,7 +531,7 @@ JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval // TODO Gee: (2004-09-01) EAlign and EVAlign too. default: - JS_ReportError(cx, "Setting '%hs' uses an unimplemented type", propName.c_str()); + JS_ReportError(cx, "Setting '%s' uses an unimplemented type", propName.c_str()); break; } @@ -587,7 +587,7 @@ JSBool JSI_IGUIObject::toString(JSContext* cx, JSObject* obj, uintN UNUSED(argc) IGUIObject* e = (IGUIObject*)JS_GetPrivate( cx, obj ); char buffer[256]; - snprintf(buffer, 256, "[GUIObject: %hs]", e->GetName().c_str()); + snprintf(buffer, 256, "[GUIObject: %s]", e->GetName().c_str()); buffer[255] = 0; *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buffer)); return JS_TRUE; diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 3413e7d809..b3edfdf371 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -532,7 +532,7 @@ ErrorReaction debug_OnError(LibError err, u8* suppress, const wchar_t* file, int const wchar_t* lastFuncToSkip = L"debug_OnError"; wchar_t buf[400]; wchar_t err_buf[200]; error_description_r(err, err_buf, ARRAY_SIZE(err_buf)); - swprintf_s(buf, ARRAY_SIZE(buf), L"Function call failed: return value was %d (%ls)", err, err_buf); + swprintf_s(buf, ARRAY_SIZE(buf), L"Function call failed: return value was %ld (%ls)", err, err_buf); return debug_DisplayError(buf, DE_MANUAL_BREAK, context, lastFuncToSkip, file,line,func, suppress); } diff --git a/source/lib/res/graphics/cursor.cpp b/source/lib/res/graphics/cursor.cpp index fae8f2ce5e..2db06df686 100644 --- a/source/lib/res/graphics/cursor.cpp +++ b/source/lib/res/graphics/cursor.cpp @@ -243,30 +243,30 @@ static LibError Cursor_validate(const Cursor* c) return INFO::OK; } -static LibError Cursor_to_string(const Cursor* c, char* buf) +static LibError Cursor_to_string(const Cursor* c, wchar_t* buf) { - const char* type; + const wchar_t* type; switch(c->kind) { case CK_Default: - type = "default"; + type = L"default"; break; case CK_System: - type = "sys"; + type = L"sys"; break; case CK_OpenGL: - type = "gl"; + type = L"gl"; break; default: debug_assert(0); - type = "?"; + type = L"?"; break; } - snprintf(buf, H_STRING_LEN, "cursor (%hs)", type); + swprintf_s(buf, H_STRING_LEN, L"cursor (%ls)", type); return INFO::OK; } diff --git a/source/lib/res/graphics/ogl_shader.cpp b/source/lib/res/graphics/ogl_shader.cpp index a62cf18d71..adf5f01772 100644 --- a/source/lib/res/graphics/ogl_shader.cpp +++ b/source/lib/res/graphics/ogl_shader.cpp @@ -46,18 +46,18 @@ ERROR_ASSOCIATE(ERR::SHDR_NO_PROGRAM, L"Invalid shader program reference", -1); // Convert a shader object type into a descriptive string. // If the type enum is not known, the given buffer is used as scratch space // to format the type number. If buf is null, a generic string is returned. -static const char* shader_type_to_string(GLenum type, char* buf, size_t buflen) +static const wchar_t* shader_type_to_string(GLenum type, wchar_t* buf, size_t buflen) { switch(type) { - case GL_VERTEX_SHADER_ARB: return "VERTEX_SHADER"; - case GL_FRAGMENT_SHADER_ARB: return "FRAGMENT_SHADER"; + case GL_VERTEX_SHADER_ARB: return L"VERTEX_SHADER"; + case GL_FRAGMENT_SHADER_ARB: return L"FRAGMENT_SHADER"; } if (!buf) - return "unknown type enum"; + return L"unknown type enum"; - snprintf(buf, buflen, "%u", type); + swprintf_s(buf, buflen, L"%u", type); return buf; } @@ -141,7 +141,7 @@ static LibError Ogl_Shader_reload(Ogl_Shader* shdr, const VfsPath& pathname, Han } { - char typenamebuf[32]; + wchar_t typenamebuf[32]; CStrW type(shader_type_to_string(shdr->type, typenamebuf, ARRAY_SIZE(typenamebuf))); GLint log_length; @@ -198,9 +198,9 @@ static LibError Ogl_Shader_validate(const Ogl_Shader* UNUSED(shdr)) return INFO::OK; } -static LibError Ogl_Shader_to_string(const Ogl_Shader* UNUSED(shdr), char* buf) +static LibError Ogl_Shader_to_string(const Ogl_Shader* shdr, wchar_t* buf) { - snprintf(buf, H_STRING_LEN, "-"); + swprintf_s(buf, H_STRING_LEN, L"Ogl_Shader %p", shdr); return INFO::OK; } @@ -416,9 +416,9 @@ static LibError Ogl_Program_validate(const Ogl_Program* UNUSED(p)) return INFO::OK; } -static LibError Ogl_Program_to_string(const Ogl_Program* UNUSED(p), char* buf) +static LibError Ogl_Program_to_string(const Ogl_Program* p, wchar_t* buf) { - snprintf(buf, H_STRING_LEN, "-"); + swprintf_s(buf, H_STRING_LEN, L"Ogl_Program %p", p); return INFO::OK; } diff --git a/source/lib/res/graphics/ogl_tex.cpp b/source/lib/res/graphics/ogl_tex.cpp index aaf8648f83..c012f59782 100644 --- a/source/lib/res/graphics/ogl_tex.cpp +++ b/source/lib/res/graphics/ogl_tex.cpp @@ -483,9 +483,9 @@ static LibError OglTex_validate(const OglTex* ot) return INFO::OK; } -static LibError OglTex_to_string(const OglTex* ot, char* buf) +static LibError OglTex_to_string(const OglTex* ot, wchar_t* buf) { - snprintf(buf, H_STRING_LEN, "OglTex id=%d flags=%x", ot->id, ot->flags); + swprintf_s(buf, H_STRING_LEN, L"OglTex id=%d flags=%x", ot->id, ot->flags); return INFO::OK; } diff --git a/source/lib/res/graphics/unifont.cpp b/source/lib/res/graphics/unifont.cpp index c08f6dc4d1..7f9047145d 100644 --- a/source/lib/res/graphics/unifont.cpp +++ b/source/lib/res/graphics/unifont.cpp @@ -191,15 +191,15 @@ static LibError UniFont_validate(const UniFont* f) return INFO::OK; } -static LibError UniFont_to_string(const UniFont* f, char* buf) +static LibError UniFont_to_string(const UniFont* f, wchar_t* buf) { if (f->ht) // not true if this is called after dtor (which it is) { const VfsPath& path = h_filename(f->ht); - snprintf(buf, H_STRING_LEN, "Font %ls", path.string().c_str()); + swprintf_s(buf, H_STRING_LEN, L"Font %ls", path.string().c_str()); } else - snprintf(buf, H_STRING_LEN, "Font"); + swprintf_s(buf, H_STRING_LEN, L"Font"); return INFO::OK; } diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index 70b4a0bc48..4af51a7455 100644 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -611,10 +611,10 @@ static LibError h_free_idx(ssize_t idx, HDATA* hd) // to_string is slow for some handles, so avoid calling it if unnecessary if(debug_filter_allows(L"H_MGR|")) { - char buf[H_STRING_LEN]; + wchar_t buf[H_STRING_LEN]; if(vtbl->to_string(hd->user, buf) < 0) - strcpy(buf, "(error)"); // safe - debug_printf(L"H_MGR| free %ls %ls accesses=%lu %hs\n", hd->type->name, hd->pathname.string().c_str(), (unsigned long)hd->num_derefs, buf); + SAFE_WCSCPY(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); } #endif diff --git a/source/lib/res/h_mgr.h b/source/lib/res/h_mgr.h index 6fc7476da7..2984f94190 100644 --- a/source/lib/res/h_mgr.h +++ b/source/lib/res/h_mgr.h @@ -292,7 +292,7 @@ struct H_VTbl LibError (*reload)(void* user, const VfsPath& pathname, Handle); void (*dtor)(void* user); LibError (*validate)(const void* user); - LibError (*to_string)(const void* user, char* buf); + LibError (*to_string)(const void* user, wchar_t* buf); size_t user_size; const wchar_t* name; }; @@ -305,14 +305,14 @@ typedef H_VTbl* H_Type; static LibError type##_reload(type*, const VfsPath&, Handle);\ static void type##_dtor(type*);\ static LibError type##_validate(const type*);\ - static LibError type##_to_string(const type*, char* buf);\ + static LibError type##_to_string(const type*, wchar_t* buf);\ static H_VTbl V_##type =\ {\ (void (*)(void*, va_list))type##_init,\ (LibError (*)(void*, const VfsPath&, Handle))type##_reload,\ (void (*)(void*))type##_dtor,\ (LibError (*)(const void*))type##_validate,\ - (LibError (*)(const void*, char*))type##_to_string,\ + (LibError (*)(const void*, wchar_t*))type##_to_string,\ sizeof(type), /* control block size */\ WIDEN(#type) /* name */\ };\ diff --git a/source/lib/res/sound/snd_mgr.cpp b/source/lib/res/sound/snd_mgr.cpp index dab23c75d4..395b7977b8 100644 --- a/source/lib/res/sound/snd_mgr.cpp +++ b/source/lib/res/sound/snd_mgr.cpp @@ -275,7 +275,7 @@ static LibError alc_init() // (e.g. DS3D, native, MMSYSTEM) - needed when reporting OpenAL bugs. const char* dev_name = (const char*)alcGetString(alc_dev, ALC_DEVICE_SPECIFIER); wchar_t buf[200]; - swprintf_s(buf, ARRAY_SIZE(buf), L"SND| alc_init: success, using %hs\n", dev_name); + swprintf_s(buf, ARRAY_SIZE(buf), L"SND| alc_init: success, using %s\n", dev_name); ah_log(buf); #if WIN_LOADLIBRARY_HACK @@ -838,10 +838,10 @@ static LibError SndData_validate(const SndData * sd) return INFO::OK; } -static LibError SndData_to_string(const SndData* sd, char* buf) +static LibError SndData_to_string(const SndData* sd, wchar_t* buf) { - const char* type = "clip"; - snprintf(buf, H_STRING_LEN, "%hs; al_buf=%d", type, sd->al_buf); + const wchar_t* type = L"clip"; + swprintf_s(buf, H_STRING_LEN, L"%ls; al_buf=%d", type, sd->al_buf); return INFO::OK; } @@ -1267,9 +1267,9 @@ static LibError VSrc_validate(const VSrc* vs) return INFO::OK; } -static LibError VSrc_to_string(const VSrc* vs, char* buf) +static LibError VSrc_to_string(const VSrc* vs, wchar_t* buf) { - snprintf(buf, H_STRING_LEN, "al_src = %d", vs->al_src); + swprintf_s(buf, H_STRING_LEN, L"al_src = %d", vs->al_src); return INFO::OK; } diff --git a/source/lib/sysdep/gfx.cpp b/source/lib/sysdep/gfx.cpp index b1c95c498c..e93a0c1c2a 100644 --- a/source/lib/sysdep/gfx.cpp +++ b/source/lib/sysdep/gfx.cpp @@ -56,7 +56,7 @@ void gfx_detect() // it's too risky, there are too many different strings) #define SHORTEN(what, chars_to_keep)\ if(!wcsncmp(gfx_card, what, ARRAY_SIZE(what)-1))\ - memmove(gfx_card+chars_to_keep, gfx_card+ARRAY_SIZE(what)-1, wcslen(gfx_card)-(ARRAY_SIZE(what)-1)+1); + memmove(gfx_card+chars_to_keep, gfx_card+ARRAY_SIZE(what)-1, (wcslen(gfx_card)-(ARRAY_SIZE(what)-1)+1)*sizeof(wchar_t)); SHORTEN(L"ATI Technologies Inc.", 3); SHORTEN(L"NVIDIA Corporation", 6); SHORTEN(L"S3 Graphics", 2); // returned by EnumDisplayDevices diff --git a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp index d5932b0f87..b9baf2c512 100644 --- a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -295,7 +295,7 @@ DIR* opendir(const char* path) // information about that directory; trailing slashes aren't allowed. // for dir entries to be returned, we have to append "\\*". char search_path[PATH_MAX]; - sprintf_s(search_path, ARRAY_SIZE(search_path), "%hs\\*", path); + sprintf_s(search_path, ARRAY_SIZE(search_path), "%s\\*", path); // note: we could store search_path and defer FindFirstFile until // readdir. this way is a bit more complex but required for diff --git a/source/lib/sysdep/os/win/wposix/wutsname.cpp b/source/lib/sysdep/os/win/wposix/wutsname.cpp index e2f32306a8..6d854ea3ca 100644 --- a/source/lib/sysdep/os/win/wposix/wutsname.cpp +++ b/source/lib/sysdep/os/win/wposix/wutsname.cpp @@ -36,10 +36,10 @@ int uname(struct utsname* un) const char* vs = vi.szCSDVersion; int sp; if(sscanf(vs, "Service Pack %d", &sp) == 1) - sprintf(un->release, "SP %d", sp); + sprintf_s(un->release, ARRAY_SIZE(un->release), "SP %d", sp); // version - sprintf(un->version, "%hs.%lu", wutil_WindowsVersionString(), vi.dwBuildNumber & 0xFFFF); + sprintf_s(un->version, ARRAY_SIZE(un->version), "%s.%lu", wutil_WindowsVersionString(), vi.dwBuildNumber & 0xFFFF); // node name DWORD buf_size = sizeof(un->nodename); diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index c7635d098b..1ebab34dfd 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -104,7 +104,7 @@ public: if (! tmpdir) tmpdir = P_tmpdir; char root[PATH_MAX]; - sprintf_s(root, PATH_MAX, "%hs/pyrogenesis-test-sysdep-XXXXXX", tmpdir); + sprintf_s(root, ARRAY_SIZE(root), "%s/pyrogenesis-test-sysdep-XXXXXX", tmpdir); TS_ASSERT(mkdtemp(root)); std::string rootstr(root); diff --git a/source/maths/scripting/JSInterface_Vector3D.cpp b/source/maths/scripting/JSInterface_Vector3D.cpp index 738f0864ce..d7e8569502 100644 --- a/source/maths/scripting/JSInterface_Vector3D.cpp +++ b/source/maths/scripting/JSInterface_Vector3D.cpp @@ -212,8 +212,7 @@ JSBool JSI_Vector3D::toString( JSContext* cx, JSObject* obj, if( vectorInfo->owner && vectorInfo->freshenFn ) ( (vectorInfo->owner)->*(vectorInfo->freshenFn) )(); CVector3D* vectorData = vectorInfo->vector; - snprintf( buffer, 256, "[object Vector3D: ( %f, %f, %f )]", vectorData->X, vectorData->Y, vectorData->Z ); - buffer[255] = 0; + sprintf_s( buffer, ARRAY_SIZE(buffer), "[object Vector3D: ( %f, %f, %f )]", vectorData->X, vectorData->Y, vectorData->Z ); *rval = STRING_TO_JSVAL( JS_NewStringCopyZ( cx, buffer ) ); return( JS_TRUE ); } diff --git a/source/network/NetLog.cpp b/source/network/NetLog.cpp index 4d3bc38124..2b21287ff6 100644 --- a/source/network/NetLog.cpp +++ b/source/network/NetLog.cpp @@ -1059,7 +1059,7 @@ void CNetLogger::GetStringTimeStamp( CStr& str ) { char buffer[ 128 ] = { 0 }; double timestamp = timer_Time(); - sprintf( buffer, "[%3u.%03u]", ( unsigned )timestamp, ( ( unsigned )( timestamp * 1000 ) % 1000 ) ); + sprintf_s( buffer, ARRAY_SIZE(buffer), "[%3u.%03u]", ( unsigned )timestamp, ( ( unsigned )( timestamp * 1000 ) % 1000 ) ); str = buffer; } diff --git a/source/network/NetSession.cpp b/source/network/NetSession.cpp index 9798d7641b..cb0a370a71 100644 --- a/source/network/NetSession.cpp +++ b/source/network/NetSession.cpp @@ -159,7 +159,7 @@ bool CNetHost::Connect( const CStr& host, uint port ) if ( !SetupSession( pNewSession ) ) return false; - NET_LOG3( "Successfully connected to server %hs:%d succeeded", host.c_str(), port ); + NET_LOG3( "Successfully connected to server %s:%d succeeded", host.c_str(), port ); // Successfully handled? if ( !HandleConnect( pNewSession ) ) @@ -177,7 +177,7 @@ bool CNetHost::Connect( const CStr& host, uint port ) return true; } - NET_LOG3( "Connection to server %hs:%d failed", host.c_str(), port ); + NET_LOG3( "Connection to server %s:%d failed", host.c_str(), port ); // 3 seconds are up or a host was disconnected enet_peer_reset( pPeer ); @@ -420,7 +420,7 @@ bool CNetHost::Poll( void ) CNetMessage* pNewMessage = CNetMessageFactory::CreateMessage( event.packet->data, event.packet->dataLength ); if ( !pNewMessage ) return false; - NET_LOG4( "Message %hs of size %lu was received from %p", pNewMessage->ToString().c_str(), (unsigned long)pNewMessage->GetSerializedLength(), event.peer->data ); + NET_LOG4( "Message %s of size %lu was received from %p", pNewMessage->ToString().c_str(), (unsigned long)pNewMessage->GetSerializedLength(), event.peer->data ); // Successfully handled? if ( !HandleMessageReceive( pNewMessage, it->pSession ) ) { @@ -526,7 +526,7 @@ bool CNetHost::SendMessage( } else { - NET_LOG4( "Message %hs of size %lu was sent to %p", + NET_LOG4( "Message %s of size %lu was sent to %p", pMessage->ToString().c_str(), (unsigned long)pMessage->GetSerializedLength(), pSession->m_Peer->data ); } diff --git a/source/network/Network.cpp b/source/network/Network.cpp index e8e4573d6f..50c0964ec9 100644 --- a/source/network/Network.cpp +++ b/source/network/Network.cpp @@ -139,7 +139,7 @@ CStr CCloseRequestMessage::ToString( void ) const void CMessageSocket::Push(CNetMessage *msg) { - NET_LOG2( "CMessageSocket::Push(): %hs", msg->ToString().c_str() ); + NET_LOG2( "CMessageSocket::Push(): %s", msg->ToString().c_str() ); m_OutQ.Lock(); m_OutQ.push_back(msg); @@ -222,7 +222,7 @@ void CMessageSocket::StartWriteNextMessage() PS_RESULT res=Write(m_pWrBuffer, hdr.m_MsgLength+HEADER_LENGTH); if (res != PS_OK) { - NET_LOG2( "CMessageSocket::StartWriteNextMessage(): %hs", res ); + NET_LOG2( "CMessageSocket::StartWriteNextMessage(): %s", res ); // Queue Error Message m_InQ.Lock(); @@ -246,7 +246,7 @@ void CMessageSocket::StartWriteNextMessage() void CMessageSocket::WriteComplete(PS_RESULT ec) { - NET_LOG2( "CMessageSocket::WriteComplete(): %hs", ec ); + NET_LOG2( "CMessageSocket::WriteComplete(): %s", ec ); if (ec == PS_OK) { @@ -285,7 +285,7 @@ void CMessageSocket::StartReadHeader() PS_RESULT res=Read(m_pRdBuffer, HEADER_LENGTH); if (res != PS_OK) { - NET_LOG2( "CMessageSocket::StartReadHeader(): %hs", res ); + NET_LOG2( "CMessageSocket::StartReadHeader(): %s", res ); // Push an error message CScopeLock scopeLock(m_InQ.m_Mutex); @@ -319,7 +319,7 @@ void CMessageSocket::StartReadMessage() PS_RESULT res=Read(m_pRdBuffer+HEADER_LENGTH, hdr.m_MsgLength); if (res != PS_OK) { - NET_LOG2( "CMessageSocket::StartReadMessage(): %hs", res ); + NET_LOG2( "CMessageSocket::StartReadMessage(): %s", res ); // Queue an error message CScopeLock scopeLock(m_InQ); @@ -330,7 +330,7 @@ void CMessageSocket::StartReadMessage() void CMessageSocket::ReadComplete(PS_RESULT ec) { - NET_LOG3( "CMessageSocket::ReadComplete(%ls): %hs", m_ReadingData ? L"data":L"header", ec ); + NET_LOG3( "CMessageSocket::ReadComplete(%ls): %s", m_ReadingData ? L"data":L"header", ec ); // Check if we were reading header or message // If header: @@ -368,7 +368,7 @@ void CMessageSocket::OnMessage(CNetMessage *pMsg) { m_InQ.Lock(); m_InQ.push_back(pMsg); - NET_LOG2( "CMessageSocket::OnMessage(): %hs", pMsg->ToString().c_str() ); + NET_LOG2( "CMessageSocket::OnMessage(): %s", pMsg->ToString().c_str() ); NET_LOG2( "CMessageSocket::OnMessage(): Queue size now %lu", (unsigned long)m_InQ.size() ); m_InQ.Unlock(); } diff --git a/source/network/ServerSocket.cpp b/source/network/ServerSocket.cpp index 1e7bbd8344..e78510fda8 100644 --- a/source/network/ServerSocket.cpp +++ b/source/network/ServerSocket.cpp @@ -37,7 +37,7 @@ void CServerSocket::OnRead() { // All errors are non-critical, so no need to do anything special besides // not calling OnAccept [ shouldn't be, that is ;-) ] - NET_LOG2( "CServerSocket::OnRead(): PreAccept returned an error: %hs", res ); + NET_LOG2( "CServerSocket::OnRead(): PreAccept returned an error: %s", res ); } } diff --git a/source/network/SocketBase.cpp b/source/network/SocketBase.cpp index f784172226..2be2bfa23e 100644 --- a/source/network/SocketBase.cpp +++ b/source/network/SocketBase.cpp @@ -160,7 +160,7 @@ CStr CSocketAddress::GetString() const if (m_Union.m_Family == IPv4) { - sprintf(convBuf, "%d.%d.%d.%d", + sprintf_s(convBuf, ARRAY_SIZE(convBuf), "%d.%d.%d.%d", m_Union.m_IPv4.sin_addr.s_addr&0xff, (m_Union.m_IPv4.sin_addr.s_addr>>8)&0xff, (m_Union.m_IPv4.sin_addr.s_addr>>16)&0xff, @@ -369,7 +369,7 @@ PS_RESULT CSocketBase::Read(void *buf, size_t len, size_t *bytesRead) case ETIMEDOUT:*/ default: Network_GetErrorString(error, errbuf, sizeof(errbuf)); - NET_LOG3("Read error %hs [%d]", errbuf, error); + NET_LOG3("Read error %s [%d]", errbuf, error); m_State=SS_UNCONNECTED; m_Error=GetPS_RESULT(error); return m_Error; @@ -420,7 +420,7 @@ PS_RESULT CSocketBase::Write(void *buf, size_t len, size_t *bytesWritten) case EHOSTUNREACH:*/ default: Network_GetErrorString(err, errbuf, sizeof(errbuf)); - NET_LOG3("Write error %hs [%d]", errbuf, err); + NET_LOG3("Write error %s [%d]", errbuf, err); m_State=SS_UNCONNECTED; return CONNECTION_BROKEN; } @@ -579,7 +579,7 @@ bool CSocketBase::ConnectError(CSocketBase *pSocket) { pSocket->m_State=SS_UNCONNECTED; PS_RESULT connErr=GetPS_RESULT(errno); - NET_LOG4("Connect error: %hs [%d:%hs]", connErr, errno, strerror(errno)); + NET_LOG4("Connect error: %s [%d:%s]", connErr, errno, strerror(errno)); pSocket->m_Error=connErr; return true; } @@ -644,7 +644,7 @@ void CSocketBase::SocketReadable(CSocketBase *pSock) // success, nRead != 0 means alive stream socket if (res == -1 && errno != EINVAL) { - NET_LOG3("RunWaitLoop:ioctl: Connection broken [%d:%hs]", errno, strerror(errno)); + NET_LOG3("RunWaitLoop:ioctl: Connection broken [%d:%s]", errno, strerror(errno)); // Don't use API function - we both hold a lock and // it is unnecessary to SendWaitLoopUpdate at this // stage @@ -880,7 +880,7 @@ void CSocketBase::RunWaitLoop() { ret=GetLastError(); Network_GetErrorString(ret, (LPSTR)&errBuf, 256); - NET_LOG3("RegisterClass: %hs [%d]", errBuf, ret); + NET_LOG3("RegisterClass: %s [%d]", errBuf, ret); return; } @@ -891,7 +891,7 @@ void CSocketBase::RunWaitLoop() { ret=GetLastError(); Network_GetErrorString(ret, errBuf, sizeof(errBuf)); - NET_LOG3("CreateWindowEx: %hs [%d]", errBuf, ret); + NET_LOG3("CreateWindowEx: %s [%d]", errBuf, ret); return; } @@ -915,7 +915,7 @@ void CSocketBase::RunWaitLoop() { ret=GetLastError(); Network_GetErrorString(ret, errBuf, sizeof(errBuf)); - NET_LOG3("GetMessage: %hs [%d]", errBuf, ret); + NET_LOG3("GetMessage: %s [%d]", errBuf, ret); } { TranslateMessage(&msg); diff --git a/source/network/StreamSocket.cpp b/source/network/StreamSocket.cpp index b9db7c6506..5c0e19083d 100644 --- a/source/network/StreamSocket.cpp +++ b/source/network/StreamSocket.cpp @@ -42,7 +42,7 @@ void *CStreamSocket_ConnectThread(void *data) CSocketAddress addr; res=CSocketAddress::Resolve(pSock->m_pConnectHost, pSock->m_ConnectPort, addr); - NET_LOG4("CStreamSocket_ConnectThread: Resolve: %hs -> %hs [%hs]", pSock->m_pConnectHost, addr.GetString().c_str(), res); + NET_LOG4("CStreamSocket_ConnectThread: Resolve: %s -> %s [%s]", pSock->m_pConnectHost, addr.GetString().c_str(), res); if (res == PS_OK) { pSock->Initialize(); @@ -53,7 +53,7 @@ void *CStreamSocket_ConnectThread(void *data) pSock->SetOpMask(0); pSock->SetNonBlocking(false); res=pSock->Connect(addr); - NET_LOG2("CStreamSocket_ConnectThread: Connect: %hs", res); + NET_LOG2("CStreamSocket_ConnectThread: Connect: %s", res); } if (res == PS_OK) @@ -128,7 +128,7 @@ PS_RESULT CStreamSocket::Write(void *buf, size_t len) } #define MakeDefaultCallback(_nm) void CStreamSocket::_nm(PS_RESULT error) \ - { NET_LOG2("CStreamSocket::"#_nm"(): %hs", error); } + { NET_LOG2("CStreamSocket::"#_nm"(): %s", error); } MakeDefaultCallback(OnClose) MakeDefaultCallback(ConnectComplete) @@ -173,7 +173,7 @@ void CStreamSocket::OnRead() ((u8 *)m_ReadContext.m_pBuffer)+m_ReadContext.m_Completed, m_ReadContext.m_Length-m_ReadContext.m_Completed, &bytes); - NET_LOG4("CStreamSocket::OnRead(): %hs, %lu bytes read of %lu", + NET_LOG4("CStreamSocket::OnRead(): %s, %lu bytes read of %lu", res, (unsigned long)bytes, (unsigned long)(m_ReadContext.m_Length-m_ReadContext.m_Completed)); if (res != PS_OK) diff --git a/source/ps/CStr.h b/source/ps/CStr.h index aa3b878917..30aad50e90 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -30,7 +30,7 @@ Examples: The following shows several examples of traditional ANSI vs UNICODE. // ANSI LPCSTR str = "PI"; - printf( "%hs = %fn", str, 3.1459f ); + printf( "%s = %fn", str, 3.1459f ); // UNICODE LPCWSTR str = L"PI"; diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index 9100109bd0..745cbab57f 100644 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -355,7 +355,7 @@ bool CConfigDB::WriteFile(EConfigNamespace ns, bool useVFS, const CStrW& path) TConfigMap &map=m_Map[ns]; for(TConfigMap::const_iterator it = map.begin(); it != map.end(); ++it) { - pos += sprintf(pos, "%hs = \"%hs\"\n", it->first.c_str(), it->second[0].m_String.c_str()); + pos += sprintf(pos, "%s = \"%s\"\n", it->first.c_str(), it->second[0].m_String.c_str()); } const size_t len = pos - (char*)buf.get(); diff --git a/source/ps/Profile.cpp b/source/ps/Profile.cpp index 359d949178..d5abe6366e 100644 --- a/source/ps/Profile.cpp +++ b/source/ps/Profile.cpp @@ -110,10 +110,7 @@ CStr CProfileNodeTable::GetName() CStr CProfileNodeTable::GetTitle() { char buf[512]; - - snprintf(buf, sizeof(buf), "Profiling Information for: %hs (Time in node: %.3f msec/frame)", node->GetName(), node->GetFrameTime() * 1000.0f ); - buf[sizeof(buf)-1] = '\0'; - + sprintf_s(buf, ARRAY_SIZE(buf), "Profiling Information for: %s (Time in node: %.3f msec/frame)", node->GetName(), node->GetFrameTime() * 1000.0f ); return buf; } @@ -167,14 +164,13 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col) } if (col == 2) - snprintf(buf, sizeof(buf), "%.3f", unlogged * 1000.0f); + sprintf_s(buf, sizeof(buf), "%.3f", unlogged * 1000.0f); else if (col == 3) - snprintf(buf, sizeof(buf), "%.1f", unlogged / g_Profiler.GetRoot()->GetFrameTime()); + sprintf_s(buf, sizeof(buf), "%.1f", unlogged / g_Profiler.GetRoot()->GetFrameTime()); else if (col == 4) - snprintf(buf, sizeof(buf), "%.1f", unlogged * 100.0f / g_Profiler.GetRoot()->GetFrameTime()); + sprintf_s(buf, sizeof(buf), "%.1f", unlogged * 100.0f / g_Profiler.GetRoot()->GetFrameTime()); else if (col == 5) - snprintf(buf, sizeof(buf), "%ld", unlogged_mallocs); - buf[sizeof(buf)-1] = '\0'; + sprintf_s(buf, sizeof(buf), "%ld", unlogged_mallocs); return CStr(buf); } @@ -187,25 +183,24 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col) case 1: #ifdef PROFILE_AMORTIZE - snprintf(buf, sizeof(buf), "%.3f", child->GetFrameCalls()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", child->GetFrameCalls()); #else - snprintf(buf, sizeof(buf), "%d", child->GetFrameCalls()); + sprintf_s(buf, sizeof(buf), "%d", child->GetFrameCalls()); #endif break; case 2: - snprintf(buf, sizeof(buf), "%.3f", child->GetFrameTime() * 1000.0f); + sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", child->GetFrameTime() * 1000.0f); break; case 3: - snprintf(buf, sizeof(buf), "%.1f", child->GetFrameTime() * 100.0 / g_Profiler.GetRoot()->GetFrameTime()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameTime() * 100.0 / g_Profiler.GetRoot()->GetFrameTime()); break; case 4: - snprintf(buf, sizeof(buf), "%.1f", child->GetFrameTime() * 100.0 / node->GetFrameTime()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameTime() * 100.0 / node->GetFrameTime()); break; case 5: - snprintf(buf, sizeof(buf), "%ld", child->GetFrameMallocs()); + sprintf_s(buf, ARRAY_SIZE(buf), "%ld", child->GetFrameMallocs()); break; } - buf[sizeof(buf)-1] = '\0'; return CStr(buf); } diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index 6549f2e1b3..343523c02b 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -90,11 +90,11 @@ void WriteSystemInfo() } // OS - fprintf(f, "OS : %hs %hs (%hs)\n", un.sysname, un.release, un.version); + fprintf(f, "OS : %s %s (%s)\n", un.sysname, un.release, un.version); // CPU const CpuTopology* topology = cpu_topology_Detect(); - fprintf(f, "CPU : %hs, %hs (%dx%dx%d)", un.machine, cpu_IdentifierString(), (int)cpu_topology_NumPackages(topology), (int)cpu_topology_CoresPerPackage(topology), (int)cpu_topology_LogicalPerCore(topology)); + fprintf(f, "CPU : %s, %s (%dx%dx%d)", un.machine, cpu_IdentifierString(), (int)cpu_topology_NumPackages(topology), (int)cpu_topology_CoresPerPackage(topology), (int)cpu_topology_LogicalPerCore(topology)); const double cpu_freq = os_cpu_ClockFrequency(); if(cpu_freq != 0.0f) { @@ -111,7 +111,7 @@ void WriteSystemInfo() // graphics fprintf(f, "Graphics Card : %ls\n", gfx_card); - fprintf(f, "OpenGL Drivers : %hs; %ls\n", glGetString(GL_VERSION), gfx_drv_ver); + fprintf(f, "OpenGL Drivers : %s; %ls\n", glGetString(GL_VERSION), gfx_drv_ver); fprintf(f, "Video Mode : %dx%d:%d@%d\n", g_xres, g_yres, g_bpp, g_freq); // sound @@ -129,7 +129,7 @@ void WriteSystemInfo() (void)gethostname(hostname, sizeof(hostname)-1); // -1 makes sure it's 0-terminated. if the function fails, // we display "(unknown)" and will skip IP output below. - fprintf(f, "Network Name : %hs", hostname); + fprintf(f, "Network Name : %s", hostname); { // ignore exception here - see https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=114032 @@ -147,7 +147,7 @@ void WriteSystemInfo() // separate entries but avoid trailing comma if(i != 0) fprintf(f, ", "); - fprintf(f, "%hs", inet_ntoa(*ips[i])); + fprintf(f, "%s", inet_ntoa(*ips[i])); } fprintf(f, ")"); } @@ -159,7 +159,7 @@ no_ip: // OpenGL extensions (write them last, since it's a lot of text) const char* exts = ogl_ExtensionString(); if (!exts) exts = "{unknown}"; - fprintf(f, "\nOpenGL Extensions: \n%hs\n", SplitExts(exts).c_str()); + fprintf(f, "\nOpenGL Extensions: \n%s\n", SplitExts(exts).c_str()); fclose(f); f = 0; diff --git a/source/ps/scripting/JSCollection.h b/source/ps/scripting/JSCollection.h index 239a999099..ca62540cc8 100644 --- a/source/ps/scripting/JSCollection.h +++ b/source/ps/scripting/JSCollection.h @@ -249,7 +249,7 @@ template bool CJSCollection::Get if( ToPrimitive( g_ScriptingHost.GetContext(), m, Storage ) ) return( true ); - JS_ReportError( g_ScriptingHost.GetContext(), "Only objects of type %hs can be stored in this collection.", ScriptType->name ); + JS_ReportError( g_ScriptingHost.GetContext(), "Only objects of type %s can be stored in this collection.", ScriptType->name ); return( false ); } @@ -263,7 +263,7 @@ template JSBool CJSCollection::T return( JS_FALSE ); // That's odd; we've lost the pointer. wchar_t buffer[256]; - int len = swprintf_s( buffer, ARRAY_SIZE(buffer), L"[object Collection: %hs: %d members]", ScriptType->name, set->size() ); + int len = swprintf_s( buffer, ARRAY_SIZE(buffer), L"[object Collection: %s: %d members]", ScriptType->name, set->size() ); buffer[255] = 0; if (len < 0 || len > 255) len=255; utf16string u16str(buffer, buffer+len); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 273346d5e1..e95db4cbc1 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -149,31 +149,31 @@ CStr CRendererStatsTable::GetCellText(size_t row, size_t col) case Row_Counter: if (col == 0) return "counter"; - snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_Counter); + sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_Counter); return buf; case Row_DrawCalls: if (col == 0) return "# draw calls"; - snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_DrawCalls); + sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_DrawCalls); return buf; case Row_TerrainTris: if (col == 0) return "# terrain tris"; - snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_TerrainTris); + sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_TerrainTris); return buf; case Row_ModelTris: if (col == 0) return "# model tris"; - snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_ModelTris); + sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_ModelTris); return buf; case Row_BlendSplats: if (col == 0) return "# blend splats"; - snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_BlendSplats); + sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_BlendSplats); return buf; default: diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 1750fe075e..3eac85abc8 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -187,7 +187,7 @@ JSBool GetEntityTemplate( JSContext* cx, JSObject*, uintN argc, jsval* argv, jsv CEntityTemplate* v = g_EntityTemplateCollection.GetTemplate( templateName, player ); if( !v ) { - JS_ReportError( cx, "No such template: %hs", CStr(templateName).c_str() ); + JS_ReportError( cx, "No such template: %s", CStr(templateName).c_str() ); return( JS_TRUE ); } @@ -1064,13 +1064,13 @@ JSBool GetBuildTimestamp( JSContext* cx, JSObject*, uintN argc, jsval* argv, jsv switch(mode) { case -1: - sprintf_s(buf, ARRAY_SIZE(buf), "%hs %hs (%ls)", __DATE__, __TIME__, svn_revision); + sprintf_s(buf, ARRAY_SIZE(buf), "%s %s (%ls)", __DATE__, __TIME__, svn_revision); break; case 0: - sprintf_s(buf, ARRAY_SIZE(buf), "%hs", __DATE__); + sprintf_s(buf, ARRAY_SIZE(buf), "%s", __DATE__); break; case 1: - sprintf_s(buf, ARRAY_SIZE(buf), "%hs", __TIME__); + sprintf_s(buf, ARRAY_SIZE(buf), "%s", __TIME__); break; case 2: sprintf_s(buf, ARRAY_SIZE(buf), "%ls", svn_revision); diff --git a/source/simulation/EntityHandles.cpp b/source/simulation/EntityHandles.cpp index 82b604f56c..1f0c3b2353 100644 --- a/source/simulation/EntityHandles.cpp +++ b/source/simulation/EntityHandles.cpp @@ -146,7 +146,7 @@ const u8* HEntity::Deserialize(const u8* buffer, const u8* UNUSED(end)) HEntity::operator CStr() const { char buf[16]; - sprintf(buf, "Entity#%04x", m_handle); + sprintf_s(buf, ARRAY_SIZE(buf), "Entity#%04x", m_handle); return CStr(buf); } diff --git a/source/simulation/EntityScriptInterface.cpp b/source/simulation/EntityScriptInterface.cpp index 5fe869c068..6df0f7e7cb 100644 --- a/source/simulation/EntityScriptInterface.cpp +++ b/source/simulation/EntityScriptInterface.cpp @@ -183,7 +183,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsv if( !baseEntity ) { *rval = JSVAL_NULL; - JS_ReportError( cx, "No such template: %hs", CStr8(templateName).c_str() ); + JS_ReportError( cx, "No such template: %s", CStr8(templateName).c_str() ); return( JS_TRUE ); } diff --git a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp index 042cfce3e0..bbd75ccd5c 100644 --- a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp +++ b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp @@ -35,7 +35,7 @@ MessagePasserImpl::MessagePasserImpl() while (tries++ < 16) // some arbitrary cut-off point to avoid infinite loops { static char name[64]; - sprintf(name, "/wfg-atlas-msgpass-%d-%d", + sprintf_s(name, ARRAY_SIZE(name), "/wfg-atlas-msgpass-%d-%d", (int)rand(1, 1000), (int)(time(0)%1000)); sem_t* sem = sem_open(name, O_CREAT | O_EXCL, 0700, 0);