From a8d90a776ead891b8eedf25979c6ef4cccb6fe49 Mon Sep 17 00:00:00 2001 From: Amir Masoud Abdol Date: Mon, 3 Apr 2023 16:40:17 +0200 Subject: Silence warning about unsafe sprintf, use snprintf instead Apple Clang, and clang also complains about this, and warnings like this tend to break the unity build in certain situation. So, if possible, I rather address them. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I8e24267a1ebfc0c3ff4f2f8afdcb7c6aed62db80 Reviewed-by: Paul Lemire --- src/plugins/renderers/opengl/debug/imguirenderer.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/renderers/opengl/debug/imguirenderer.cpp b/src/plugins/renderers/opengl/debug/imguirenderer.cpp index 4a53117a0..6d52b515d 100644 --- a/src/plugins/renderers/opengl/debug/imguirenderer.cpp +++ b/src/plugins/renderers/opengl/debug/imguirenderer.cpp @@ -29,10 +29,6 @@ #define GL_VERTEX_ARRAY_BINDING 0x85B5 #endif -#ifdef _MSC_VER -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#endif - QT_BEGIN_NAMESPACE using namespace Qt3DRender; @@ -162,7 +158,7 @@ void ImGuiRenderer::renderDebugOverlay(const std::vector &renderVi { ImGui::Begin("Qt3D Profiling"); char caption[50]; - sprintf(caption, "Avg %.3f ms/frame (%.1f FPS)", static_cast(1000.0f / ImGui::GetIO().Framerate), static_cast(ImGui::GetIO().Framerate)); + snprintf(caption, sizeof(caption), "Avg %.3f ms/frame (%.1f FPS)", static_cast(1000.0f / ImGui::GetIO().Framerate), static_cast(ImGui::GetIO().Framerate)); ImGui::PlotLines("FPS", m_fpsLog, logIndex + 1, 0, caption, m_fpsRange.first, m_fpsRange.second, ImVec2(0, 80)); ImGui::PlotHistogram("Jobs", m_jobsLog, logIndex + 1, 0, nullptr, m_jobsRange.first, m_jobsRange.second, ImVec2(0, 80)); -- cgit v1.2.1